AngularJS Callbacks on Rails
I have noticed that AngularJS requires the results in javascript from the
back-end server.
The current server in the example returns angular.callbacks._0({"key":
"value"}); with javascript headers. How to make the returns in the same
format on Rails? Thanks!
Here is my working example:
<!DOCTYPE html>
<html ng-app="Simple">
<body>
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script>
<div ng-controller="SimpleController">
{{some_item.key}}
</div>
<script>
angular.module('Simple', ['ngResource']);
function SimpleController($scope, $resource) {
$scope.simple = $resource('http://echo.jsontest.com/key/value',
{callback:'JSON_CALLBACK'},
{get:{method:'JSONP'}}
);
$scope.some_item = $scope.simple.get();
console.log($scope.some_item.key);
}
</script>
</body>
</html>
Saturday, 31 August 2013
IList Property stays null even when member is instantiated
IList Property stays null even when member is instantiated
I am having trouble using an IList property which always seems to return
null, even though the member is is getting is instantiated:
private List<ModelRootEntity> _validTargets = new
List<ModelRootEntity>();
public IList<IModelRootEntity> ValidTargets
{
get
{
return _validTargets as IList<IModelRootEntity>;
}
protected internal set
{
if (value == null)
_validTargets.Clear();
else
_validTargets = value as List<ModelRootEntity>;
}
}
ModelRootEntity implements IModelRootEntity. I watched both values during
debugging, whilst the member shows a positive count, the property stays
null.
I also tried raising an exception within the property getter to throw if
the counts of _validTargets and _validTargets as List<ModelRootEntity> are
different, but it never threw.
Found question [Dictionary properties are always null despite dictionaries
being instantiated, which seems similar, however in my case this seems to
happen regardless of serialization.
Any ideas?
I am having trouble using an IList property which always seems to return
null, even though the member is is getting is instantiated:
private List<ModelRootEntity> _validTargets = new
List<ModelRootEntity>();
public IList<IModelRootEntity> ValidTargets
{
get
{
return _validTargets as IList<IModelRootEntity>;
}
protected internal set
{
if (value == null)
_validTargets.Clear();
else
_validTargets = value as List<ModelRootEntity>;
}
}
ModelRootEntity implements IModelRootEntity. I watched both values during
debugging, whilst the member shows a positive count, the property stays
null.
I also tried raising an exception within the property getter to throw if
the counts of _validTargets and _validTargets as List<ModelRootEntity> are
different, but it never threw.
Found question [Dictionary properties are always null despite dictionaries
being instantiated, which seems similar, however in my case this seems to
happen regardless of serialization.
Any ideas?
Kendo UI Mobile forcing empty cell to not display in template
Kendo UI Mobile forcing empty cell to not display in template
Is it possible to force an empty cell to not display in a template?
Currently my template is:
template = kendo.template("#if (title != null){#<span class=\"box
favorable\">50</span><div class=\"title\">${ title }</div>#}else{}#");
However, if the else statement is called, it just displays an empty cell.
I want the cell to not be displayed, instead of being an empty cell.
Is it possible to force an empty cell to not display in a template?
Currently my template is:
template = kendo.template("#if (title != null){#<span class=\"box
favorable\">50</span><div class=\"title\">${ title }</div>#}else{}#");
However, if the else statement is called, it just displays an empty cell.
I want the cell to not be displayed, instead of being an empty cell.
NumPy : array methods and functions not working
NumPy : array methods and functions not working
I have a problem regarding NumPy arrays.
I cannot get array methods like .T or functions like numpy.concatenate to
work with arrays I create:
>>> a=np.array([1,2,3])
>>> a
array([1, 2, 3])
>>> a.T
array([1, 2, 3])
>>> np.concatenate((a,a),axis=0)
array([1, 2, 3, 1, 2, 3])
>>> np.concatenate((a,a),axis=1)
array([1, 2, 3, 1, 2, 3])
>>>
However when I create an array using bult-in functions like rand
everything is fine
>>> a=np.random.rand(1,4)
>>> a.T
array([[ 0.75973189],
[ 0.23873578],
[ 0.6422108 ],
[ 0.47079987]])
>>> np.concatenate((a,a),axis=0)
array([[ 0.92191111, 0.50662157, 0.75663621, 0.65802565],
[ 0.92191111, 0.50662157, 0.75663621, 0.65802565]])
Do you think it has to do with element types (int32 vs float64) ?
I anm running python 2.7 on windows 7
Any help would be greatly appreciated.
Thanks !
I have a problem regarding NumPy arrays.
I cannot get array methods like .T or functions like numpy.concatenate to
work with arrays I create:
>>> a=np.array([1,2,3])
>>> a
array([1, 2, 3])
>>> a.T
array([1, 2, 3])
>>> np.concatenate((a,a),axis=0)
array([1, 2, 3, 1, 2, 3])
>>> np.concatenate((a,a),axis=1)
array([1, 2, 3, 1, 2, 3])
>>>
However when I create an array using bult-in functions like rand
everything is fine
>>> a=np.random.rand(1,4)
>>> a.T
array([[ 0.75973189],
[ 0.23873578],
[ 0.6422108 ],
[ 0.47079987]])
>>> np.concatenate((a,a),axis=0)
array([[ 0.92191111, 0.50662157, 0.75663621, 0.65802565],
[ 0.92191111, 0.50662157, 0.75663621, 0.65802565]])
Do you think it has to do with element types (int32 vs float64) ?
I anm running python 2.7 on windows 7
Any help would be greatly appreciated.
Thanks !
flask-admin queryset analog from django-admin
flask-admin queryset analog from django-admin
I'm using SQLAlchemy ModelView
Well, I'm trying to manage per-item permissions in my admin. So, users can
change only that model instances, they created.
I can add column "author" with relation to "User" table.
After that, in django-admin typically we use
def queryset:
qs = super(...
qs = qs.filter(author = request.user)
return qs
So, how to do this in flask-admin. Mb, it's definitely another way, and
maybe there is "queryset" analog?
I'm using SQLAlchemy ModelView
Well, I'm trying to manage per-item permissions in my admin. So, users can
change only that model instances, they created.
I can add column "author" with relation to "User" table.
After that, in django-admin typically we use
def queryset:
qs = super(...
qs = qs.filter(author = request.user)
return qs
So, how to do this in flask-admin. Mb, it's definitely another way, and
maybe there is "queryset" analog?
Inserting class into database through PHP
Inserting class into database through PHP
<!DOCTYPE>
<html>
<head>
<meta charset=utf-8" />
<title> data input form </title>
<link rel="stylesheet" type="text/css" href="css/form.css"/>
</head>
<body>
<h1> Insert data here</h1>
<form method="get" action="insert-data.php">
<input type="hidden" name="submitted" value="true" />
<fieldset>
<ul>
<li><label> English Word <input type="text"
name="englishWord"/>
</label></li>
<li><label> Beginner German <input type="text"
name="beginnerGerman"/> </label></li>
</ul>
<input type="submit" value="add new record" />
</fieldset>
</form>
<? php
echo $newrecord;
?>
</body>
</html>
<?php
//connect to database
$host = "localhost";
$username = "root";
$password = "mypass";
$database = "dictionary";
$table = "engdic";
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$englishWord = $_GET['englishWord'];
$beginnerGerman=$_GET['beginnerGerman'];
$mysql = "INSERT INTO $table (englishWord,beginnerGerman) VALUES
('$englishWord','<div class='beginner_german'>$beginnerGerman</div>')";
if(!mysql_query($mysql))
die(mysql_error());
echo "data inserted";
mysql_close();
?>
//INSIDE DATABASE
<div class=`beginner_german`>Beginner German Word</div>
So I will have input form where user will add translation words in to
database, when user will add lets say word Apple, it will also add div
with css class to database.So that way when another user will search for
word Apple I can style it with css class. my problem is when I am trying
to add div with class="beginner_german" I am geting error in php, when I
am using clas='beginner_german' it inserts in database fine but when I
cant call the css class, because syntax must be class="beginner_german".
So what is the solution. Thank you for your time.
<!DOCTYPE>
<html>
<head>
<meta charset=utf-8" />
<title> data input form </title>
<link rel="stylesheet" type="text/css" href="css/form.css"/>
</head>
<body>
<h1> Insert data here</h1>
<form method="get" action="insert-data.php">
<input type="hidden" name="submitted" value="true" />
<fieldset>
<ul>
<li><label> English Word <input type="text"
name="englishWord"/>
</label></li>
<li><label> Beginner German <input type="text"
name="beginnerGerman"/> </label></li>
</ul>
<input type="submit" value="add new record" />
</fieldset>
</form>
<? php
echo $newrecord;
?>
</body>
</html>
<?php
//connect to database
$host = "localhost";
$username = "root";
$password = "mypass";
$database = "dictionary";
$table = "engdic";
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$englishWord = $_GET['englishWord'];
$beginnerGerman=$_GET['beginnerGerman'];
$mysql = "INSERT INTO $table (englishWord,beginnerGerman) VALUES
('$englishWord','<div class='beginner_german'>$beginnerGerman</div>')";
if(!mysql_query($mysql))
die(mysql_error());
echo "data inserted";
mysql_close();
?>
//INSIDE DATABASE
<div class=`beginner_german`>Beginner German Word</div>
So I will have input form where user will add translation words in to
database, when user will add lets say word Apple, it will also add div
with css class to database.So that way when another user will search for
word Apple I can style it with css class. my problem is when I am trying
to add div with class="beginner_german" I am geting error in php, when I
am using clas='beginner_german' it inserts in database fine but when I
cant call the css class, because syntax must be class="beginner_german".
So what is the solution. Thank you for your time.
How to directly use key as hash for std::unordered_map?
How to directly use key as hash for std::unordered_map?
The keys in my std::unordered_map are boost::uuids::uuids, thus 128 bit
hashes considered unique. However, the compiler can't know that and
therefore says this.
error C2338: The C++ Standard doesn't provide a hash for this type.
How can I make the map use the keys as hashes as they are?
The keys in my std::unordered_map are boost::uuids::uuids, thus 128 bit
hashes considered unique. However, the compiler can't know that and
therefore says this.
error C2338: The C++ Standard doesn't provide a hash for this type.
How can I make the map use the keys as hashes as they are?
LongListSelector's performance is very bad. How to improve?
LongListSelector's performance is very bad. How to improve?
here is my code
<phone:LongListSelector ItemsSource="{Binding
MovieTimeInDetailItems}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="24,0,0,12">
<TextBlock Text="{Binding Theater}"
FontSize="34"/>
<ListBox ItemsSource="{Binding TimeItems}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="115"
Margin="0,0,0,0">
<TextBlock Text="{Binding
Time}"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontSize="26"
Foreground="{StaticResource
PhoneSubtleBrush}"/>
<Border Margin="92,0,0,0"
HorizontalAlignment="Left"
Width="{Binding Width}"
Height="25"
BorderThickness="1.5,0,0,0"
BorderBrush="{StaticResource
PhoneSubtleBrush}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
In each LLS item contains a Listbox which display time list. my question
is ... Can I display a time list without Listbox ? It seems Listbox cause
the low performance.
here is my code
<phone:LongListSelector ItemsSource="{Binding
MovieTimeInDetailItems}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="24,0,0,12">
<TextBlock Text="{Binding Theater}"
FontSize="34"/>
<ListBox ItemsSource="{Binding TimeItems}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="115"
Margin="0,0,0,0">
<TextBlock Text="{Binding
Time}"
TextWrapping="Wrap"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontSize="26"
Foreground="{StaticResource
PhoneSubtleBrush}"/>
<Border Margin="92,0,0,0"
HorizontalAlignment="Left"
Width="{Binding Width}"
Height="25"
BorderThickness="1.5,0,0,0"
BorderBrush="{StaticResource
PhoneSubtleBrush}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
In each LLS item contains a Listbox which display time list. my question
is ... Can I display a time list without Listbox ? It seems Listbox cause
the low performance.
Friday, 30 August 2013
How to expand region of a plot saved through hgexport?
How to expand region of a plot saved through hgexport?
So I used the command
hgexport(gcf, 'figure1.jpg', hgexport('factorystyle'), 'Format', 'jpeg');
on my graph, and I get this weird graph below. Is there a way to auto-save
images I generate with Matlab - with all the axes expanded out to full
screen, so that all these plots won't be squished together?
So I used the command
hgexport(gcf, 'figure1.jpg', hgexport('factorystyle'), 'Format', 'jpeg');
on my graph, and I get this weird graph below. Is there a way to auto-save
images I generate with Matlab - with all the axes expanded out to full
screen, so that all these plots won't be squished together?
Thursday, 29 August 2013
Rotating around completely in 90 degree intervals
Rotating around completely in 90 degree intervals
I have a circular menu that rotates 90 degrees every time leftArrow_mc is
clicked but at 270 degrees the button stops working. Also will the
reseting the degrees back to 0 do anything for me?
import com.greensock.*;
import com.greensock.easing.*;
leftArrow_mc.addEventListener(MouseEvent.CLICK, rotateLeft1);
function rotateLeft1(event: MouseEvent):void {
if (bottomWheel_menu_mc.rotation==0) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 90,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 90) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 180,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 180) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 270,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 270) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 360,
ease:Bounce.easeOut});
}
else if (bottomWheel_menu_mc.rotation == 360) {
bottomWheel_menu_mc.rotation == 0
}
}
I have a circular menu that rotates 90 degrees every time leftArrow_mc is
clicked but at 270 degrees the button stops working. Also will the
reseting the degrees back to 0 do anything for me?
import com.greensock.*;
import com.greensock.easing.*;
leftArrow_mc.addEventListener(MouseEvent.CLICK, rotateLeft1);
function rotateLeft1(event: MouseEvent):void {
if (bottomWheel_menu_mc.rotation==0) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 90,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 90) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 180,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 180) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 270,
ease:Bounce.easeOut});
} else if (bottomWheel_menu_mc.rotation == 270) {
TweenLite.to(bottomWheel_menu_mc, 1, {rotation: 360,
ease:Bounce.easeOut});
}
else if (bottomWheel_menu_mc.rotation == 360) {
bottomWheel_menu_mc.rotation == 0
}
}
How do I silence mysqlcheck?
How do I silence mysqlcheck?
If I use for example:
mysqlcheck syscp --silent --auto-repair
I still get the note:
syscp.panel_sessions
note : The storage engine for the table doesn't support check
this is strange, cause in the manpage it sais:
--silent, -s
Silent mode. Print only error messages.
how can I suppress notes?
If I use for example:
mysqlcheck syscp --silent --auto-repair
I still get the note:
syscp.panel_sessions
note : The storage engine for the table doesn't support check
this is strange, cause in the manpage it sais:
--silent, -s
Silent mode. Print only error messages.
how can I suppress notes?
Wednesday, 28 August 2013
$.get() method JQuery reads nothing (html)
$.get() method JQuery reads nothing (html)
Goal:
When click_div is clicked, the script should read a file (text.html) from
my own computer using $.get() method, and set the html of a div (cont_div)
to the file's content.
Code:
$(document).ready(function() {
$('#click_div').click(function(){
var HTML_FILE_URL = 'text.html';
$.get(HTML_FILE_URL, function(data){
alert(data);
$('#cont_div').html(text);
});
});
});
Problem:
The content of cont_div keeps blank, after clicking click_div. I put an
alert to show the content of what the get method read, and it displays a
blank dialog.
Further information:
• The file is on the same folder as the .js file, and the index.html page
file.
• All the other javascript functions work well.
Question:
Given that the alert function displays nothing, but is still called, what
could I possibly be doing wrong? I've tried many things, but it really
doesn't work.
Goal:
When click_div is clicked, the script should read a file (text.html) from
my own computer using $.get() method, and set the html of a div (cont_div)
to the file's content.
Code:
$(document).ready(function() {
$('#click_div').click(function(){
var HTML_FILE_URL = 'text.html';
$.get(HTML_FILE_URL, function(data){
alert(data);
$('#cont_div').html(text);
});
});
});
Problem:
The content of cont_div keeps blank, after clicking click_div. I put an
alert to show the content of what the get method read, and it displays a
blank dialog.
Further information:
• The file is on the same folder as the .js file, and the index.html page
file.
• All the other javascript functions work well.
Question:
Given that the alert function displays nothing, but is still called, what
could I possibly be doing wrong? I've tried many things, but it really
doesn't work.
Inject beans from other projects into Vaadin view
Inject beans from other projects into Vaadin view
In one of my Vaadin views I'm trying to get hold of a business object that
resides in another project (bll) by injecting it with @Inject.
Vaadin view:
public class FruitSaladView extends VerticalLayout implements View {
@Inject
BananaService bananaService;
...
}
I can't do this, of course, the bananaService object is null at runtime,
because I have nowhere to do a component-scan for packages.
I'm using annotations so I have no web.xml in my Vaadin web project, I
don't even have a WEB-INF folder.
I also know there are some alternatives, like the CDI-Utils and the Vaadin
CDI Vaadin addons, as well as some other solutions to this, but they all
seem to inject stuff into the Main UI (not to the views) and from the web
application itself, not from other modules.
I'm using Vaadin 7 and Tomcat 7 (as long as it's feasible using Tomcat
given the answer to the question below)
Question: What would be the recommended way to inject a bean from another
module into a Vaadin view and what do I need to do in order to accomplish
this?
Follow-up question: Will using Tomcat for this application be a problem
after using above method?
In one of my Vaadin views I'm trying to get hold of a business object that
resides in another project (bll) by injecting it with @Inject.
Vaadin view:
public class FruitSaladView extends VerticalLayout implements View {
@Inject
BananaService bananaService;
...
}
I can't do this, of course, the bananaService object is null at runtime,
because I have nowhere to do a component-scan for packages.
I'm using annotations so I have no web.xml in my Vaadin web project, I
don't even have a WEB-INF folder.
I also know there are some alternatives, like the CDI-Utils and the Vaadin
CDI Vaadin addons, as well as some other solutions to this, but they all
seem to inject stuff into the Main UI (not to the views) and from the web
application itself, not from other modules.
I'm using Vaadin 7 and Tomcat 7 (as long as it's feasible using Tomcat
given the answer to the question below)
Question: What would be the recommended way to inject a bean from another
module into a Vaadin view and what do I need to do in order to accomplish
this?
Follow-up question: Will using Tomcat for this application be a problem
after using above method?
dispatcher throw Exception in Spring application
dispatcher throw Exception in Spring application
Hello I am New in new in MVC Spring.I have Create Simple Application using
Spring. i use etbeans 7.3.1 Ide,i use Spring version 2.5.6.when i try to
run my application it gives me error like dispatcher throw Exception . i
have create following class for my application. HelloController.java and
Name1.java which is given below.
package controller;
import java.net.BindException;
import java.util.jar.Attributes.Name;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import service.HelloService;
import controller.Name1;
public class HelloController extends SimpleFormController {
private HelloService helloService;
public HelloController()
{
setCommandClass(Name.class);
setCommandName("name");
setSuccessView("helloView");
setFormView("nameView");
}
protected ModelAndView onSubmit(HttpServletRequest
request,HttpServletResponse response,Object
command,BindException errors) throws Exception {
Name1 name = (Name1) command;
ModelAndView mv = new ModelAndView(getSuccessView());
mv.addObject("helloMessage", helloService.sayHello(name.getValue()));
return mv;
}
}
Now I am Showing Name1.java
package controller;
public class Name1
{
private String value;
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
}
HelloService.java
package service;
import controller.Name1;
public class HelloService
{
public static String sayHello(String name)
{
return "Hello " + name + "!";
}
}
Now I am Show dispatcher-servlet.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-
beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema
/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema
/tx/spring-tx-2.5.xsd">
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<bean class="controller.HelloController"
p:helloService-ref="helloService"/>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="hello.htm">indexController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<bean name="indexController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="hello" />
</beans>
Now I am showing you my 2 jsp file which is given below
Helloview.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<h1>${helloMessage}</h1>
</body>
</html>
nameView.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Name View</title>
</head>
<body>
<spring:nestedPath path="name">
<form action="" method="post">
Name:
<spring:bind path="value">
<input type="text" name="${status.expression}"
value="${status.value}">
</spring:bind>
<input type="submit" value="OK">
</form>
</spring:nestedPath>
</body>
</html>
My Trace is Given Below. type Exception report
message Servlet.init() for servlet dispatcher threw exception
description The server encountered an internal error that prevented it from
fulfilling this
request.
exception
javax.servlet.ServletException: Servlet.init() for servlet dispatcher threw
exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process
(AbstractHttp11Processor.java:1004)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
and i have also change property of project. from right click on project
then property->run->RelaticURL=hello.htm then I run My project I got The
Error which i mention in Title. So Kindly Help Me.. Where I made Mistake.
Thank you.
Hello I am New in new in MVC Spring.I have Create Simple Application using
Spring. i use etbeans 7.3.1 Ide,i use Spring version 2.5.6.when i try to
run my application it gives me error like dispatcher throw Exception . i
have create following class for my application. HelloController.java and
Name1.java which is given below.
package controller;
import java.net.BindException;
import java.util.jar.Attributes.Name;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import service.HelloService;
import controller.Name1;
public class HelloController extends SimpleFormController {
private HelloService helloService;
public HelloController()
{
setCommandClass(Name.class);
setCommandName("name");
setSuccessView("helloView");
setFormView("nameView");
}
protected ModelAndView onSubmit(HttpServletRequest
request,HttpServletResponse response,Object
command,BindException errors) throws Exception {
Name1 name = (Name1) command;
ModelAndView mv = new ModelAndView(getSuccessView());
mv.addObject("helloMessage", helloService.sayHello(name.getValue()));
return mv;
}
}
Now I am Showing Name1.java
package controller;
public class Name1
{
private String value;
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
}
HelloService.java
package service;
import controller.Name1;
public class HelloService
{
public static String sayHello(String name)
{
return "Hello " + name + "!";
}
}
Now I am Show dispatcher-servlet.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-
beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema
/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema
/tx/spring-tx-2.5.xsd">
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<bean class="controller.HelloController"
p:helloService-ref="helloService"/>
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="hello.htm">indexController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<bean name="indexController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="hello" />
</beans>
Now I am showing you my 2 jsp file which is given below
Helloview.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<h1>${helloMessage}</h1>
</body>
</html>
nameView.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Name View</title>
</head>
<body>
<spring:nestedPath path="name">
<form action="" method="post">
Name:
<spring:bind path="value">
<input type="text" name="${status.expression}"
value="${status.value}">
</spring:bind>
<input type="submit" value="OK">
</form>
</spring:nestedPath>
</body>
</html>
My Trace is Given Below. type Exception report
message Servlet.init() for servlet dispatcher threw exception
description The server encountered an internal error that prevented it from
fulfilling this
request.
exception
javax.servlet.ServletException: Servlet.init() for servlet dispatcher threw
exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.http11.AbstractHttp11Processor.process
(AbstractHttp11Processor.java:1004)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)
and i have also change property of project. from right click on project
then property->run->RelaticURL=hello.htm then I run My project I got The
Error which i mention in Title. So Kindly Help Me.. Where I made Mistake.
Thank you.
Tuesday, 27 August 2013
OpenGL Texture Data Corruption?
OpenGL Texture Data Corruption?
I have a simple BMP loading code that, until a while ago, was working
perfectly.
I had to restructure the code a bit, but everything is still the same, and
my texture suddenly stopped showing (instead, it shows only a darkish blue
color on the quad).
So for tests, I made a new BMP in 40x40 size, with a checkers like texture
divided in 4 regions of pure red, blue, green and yellow. It shows
perfectly.
I tried to display the other textures, no success. I tried other images as
well, no success. Just the same dark blue quad.
So I decided to take my checkers (the only working texture for some
reason), and copy 4 pixels of the texture I want to display in the first 4
pixels of my checkers texture.
So besides the first "red" region, there's 4 pixels of the texture that
isn't displaying.
When showing this, the first line is messed up with a dark/light blue, the
rest is okay.
If I do this (copy the pixels in any line) the entire line of the checkers
texture gets corrupted.
I'm completely out of ideas as I thought it was a code error, it seems to
be a texture corruption bug.
What could be causing this, or what suggestions would you have to debug
what could be causing this?
I have a simple BMP loading code that, until a while ago, was working
perfectly.
I had to restructure the code a bit, but everything is still the same, and
my texture suddenly stopped showing (instead, it shows only a darkish blue
color on the quad).
So for tests, I made a new BMP in 40x40 size, with a checkers like texture
divided in 4 regions of pure red, blue, green and yellow. It shows
perfectly.
I tried to display the other textures, no success. I tried other images as
well, no success. Just the same dark blue quad.
So I decided to take my checkers (the only working texture for some
reason), and copy 4 pixels of the texture I want to display in the first 4
pixels of my checkers texture.
So besides the first "red" region, there's 4 pixels of the texture that
isn't displaying.
When showing this, the first line is messed up with a dark/light blue, the
rest is okay.
If I do this (copy the pixels in any line) the entire line of the checkers
texture gets corrupted.
I'm completely out of ideas as I thought it was a code error, it seems to
be a texture corruption bug.
What could be causing this, or what suggestions would you have to debug
what could be causing this?
how to submit form to Google Docs URL from local site without Access-Control-Allow-Origin issues?
how to submit form to Google Docs URL from local site without
Access-Control-Allow-Origin issues?
Background
I have a form submission that I need to make to a Google Docs form
Unfortunately this is a hard requirement for the given situation.
I need to create a web page as a better interface to this form (long story
short: folks will be using an iPad to enter information and it needs
certain UI touches that the google form doesn't have by default).
I can make this submission via the "action" of the HTML form; however, I
need to override the form submit so that
Goal
When the submit button is clicked, submit the form via Ajax and do
something based on the success or failure of the response.
Problem / Question
As expected, I see the following error in Chrome (form key omitted);
XMLHttpRequest cannot load
https://docs.google.com/formResponse?formkey=[...]&ifq. Origin null is not
allowed by Access-Control-Allow-Origin.
How can I avoid this? Is there any way I can submit this data to the
Google Form without triggering this issue?
Code so Far
HTML page:
<form id="ss-form" name="googleform" class="pure-form pure-form-aligned">
<!-- Fields omitted for brevity -->
<input type="submit" class="pure-button pure-button-primary"
id="btnSubmit" />
</form>
JavaScript:
$(document).ready(function () {
console.log("Document Ready");
disableFormSubmissionEvent();
wireUpSubmitButton();
});
disableFormSubmissionEvent = function () {
console.log("Disabling sumission Event");
$('#ss-form').submit(function () {
return false;
});
wireUpSubmitButton = function () {
console.log("Wiring up submit button");
$("#btnSubmit").click(function () {
submitForm();
});
JavaScript that attempts the form submission (form key omitted):
submitForm = function (event) {
console.log("obtaining form data");
var thedata = $('#ss-form').serialize();
console.log("Attempting Form Submission");
var submissionUrl =
"https://docs.google.com/formResponse?formkey=[...]&ifq";
$.ajax({
type: 'POST',
url: submissionUrl,
contentType: 'multipart/form-data',
data: thedata
}).success(function () {
clearForm();
showSuccessMessage();
}
)
.fail(function (jqXHR, textStatus, errorThrown) {
showFailureMessage(jqXHR, textStatus, errorThrown,
submissionUrl);
});
Access-Control-Allow-Origin issues?
Background
I have a form submission that I need to make to a Google Docs form
Unfortunately this is a hard requirement for the given situation.
I need to create a web page as a better interface to this form (long story
short: folks will be using an iPad to enter information and it needs
certain UI touches that the google form doesn't have by default).
I can make this submission via the "action" of the HTML form; however, I
need to override the form submit so that
Goal
When the submit button is clicked, submit the form via Ajax and do
something based on the success or failure of the response.
Problem / Question
As expected, I see the following error in Chrome (form key omitted);
XMLHttpRequest cannot load
https://docs.google.com/formResponse?formkey=[...]&ifq. Origin null is not
allowed by Access-Control-Allow-Origin.
How can I avoid this? Is there any way I can submit this data to the
Google Form without triggering this issue?
Code so Far
HTML page:
<form id="ss-form" name="googleform" class="pure-form pure-form-aligned">
<!-- Fields omitted for brevity -->
<input type="submit" class="pure-button pure-button-primary"
id="btnSubmit" />
</form>
JavaScript:
$(document).ready(function () {
console.log("Document Ready");
disableFormSubmissionEvent();
wireUpSubmitButton();
});
disableFormSubmissionEvent = function () {
console.log("Disabling sumission Event");
$('#ss-form').submit(function () {
return false;
});
wireUpSubmitButton = function () {
console.log("Wiring up submit button");
$("#btnSubmit").click(function () {
submitForm();
});
JavaScript that attempts the form submission (form key omitted):
submitForm = function (event) {
console.log("obtaining form data");
var thedata = $('#ss-form').serialize();
console.log("Attempting Form Submission");
var submissionUrl =
"https://docs.google.com/formResponse?formkey=[...]&ifq";
$.ajax({
type: 'POST',
url: submissionUrl,
contentType: 'multipart/form-data',
data: thedata
}).success(function () {
clearForm();
showSuccessMessage();
}
)
.fail(function (jqXHR, textStatus, errorThrown) {
showFailureMessage(jqXHR, textStatus, errorThrown,
submissionUrl);
});
Files hiding inside a file with a mysterious way
Files hiding inside a file with a mysterious way
I know this looks crazy , but i'm pretty sure that you have a solution for
this!
and that's why i came here.
i have a file which ends with .p extension .
in decompression using WinRar's SFX with a configuration file (XML) it's
gonna extract those files!
Here we go..
i took a screenshot of the configuration file =>
And this is the screenshot of the .p file =>
Here you see the highlights i made in the pictures .. (1") and (2") in the
first and the second pic.
I really need those files right now , and i have them !! But can't just
use them !!
This file is one of 103 other files .. All have files inside that need to
extract !
Programatically, explain this to me ..
And generally please tell me how to take my files from those jails :-)
Your answer will not just make me use my files .. It's gonna give me an
idea of maybe an incoming project .
NOTE: This files was in ".exe" SFX and was damaged , i fixed the damage
and had to add it to an SFX again but i didn't know how to use the
configuration file and where.
Thank you :-)
I know this looks crazy , but i'm pretty sure that you have a solution for
this!
and that's why i came here.
i have a file which ends with .p extension .
in decompression using WinRar's SFX with a configuration file (XML) it's
gonna extract those files!
Here we go..
i took a screenshot of the configuration file =>
And this is the screenshot of the .p file =>
Here you see the highlights i made in the pictures .. (1") and (2") in the
first and the second pic.
I really need those files right now , and i have them !! But can't just
use them !!
This file is one of 103 other files .. All have files inside that need to
extract !
Programatically, explain this to me ..
And generally please tell me how to take my files from those jails :-)
Your answer will not just make me use my files .. It's gonna give me an
idea of maybe an incoming project .
NOTE: This files was in ".exe" SFX and was damaged , i fixed the damage
and had to add it to an SFX again but i didn't know how to use the
configuration file and where.
Thank you :-)
Add a class every 2.5 seconds to an element
Add a class every 2.5 seconds to an element
I'm trying to add a class to an element every 2.5 seconds using delay():
$(".play").click(function(e) {
e.preventDefault();
$('#productimage').addClass('step1');
$('#productimage').delay(2500).addClass('step2');
$('#productimage').delay(5000).addClass('step3');
$('#productimage').delay(7500).addClass('step4');
$('#productimage').delay(10000).addClass('step5');
});
It doesn't seeem to be working because it adds the class step5 straight
away. Is this the wrong way to go about it?
Thanks.
I'm trying to add a class to an element every 2.5 seconds using delay():
$(".play").click(function(e) {
e.preventDefault();
$('#productimage').addClass('step1');
$('#productimage').delay(2500).addClass('step2');
$('#productimage').delay(5000).addClass('step3');
$('#productimage').delay(7500).addClass('step4');
$('#productimage').delay(10000).addClass('step5');
});
It doesn't seeem to be working because it adds the class step5 straight
away. Is this the wrong way to go about it?
Thanks.
CMD runtime error:"application has requested runtime to terminate in an unusual way"
CMD runtime error:"application has requested runtime to terminate in an
unusual way"
hi i have a problem while running a cpp exe file in cmd, actually it's a
SVM training code. in the middle of proess i get this error and it stops:
"application has requested runtime to terminate in an unusual way" do yo
think it's a code problem or system problem? code works correctly for
little amount of data thanks
unusual way"
hi i have a problem while running a cpp exe file in cmd, actually it's a
SVM training code. in the middle of proess i get this error and it stops:
"application has requested runtime to terminate in an unusual way" do yo
think it's a code problem or system problem? code works correctly for
little amount of data thanks
Monday, 26 August 2013
Extjs empty combo box value on expand click
Extjs empty combo box value on expand click
i have created lazy loading combo box, which queries data by entered
value. But i have issue when value is loaded from database and i click
expand list button, it sends request with empty mask instead of taking
value of combobox, it seems, that empty value is taken for some reason.
Here is my combo box :
editor : {
xtype : 'lazycombo',
minChars : 1,
pageSize : 20,
id : 'tax-code-combo',
store : 'TaxCodesStore',
triggerAction : 'all'
}
and here is request params :
limit 20
mask
organizationId 108
start 0
mask is empty instead of before set value.
Thanks for help
i have created lazy loading combo box, which queries data by entered
value. But i have issue when value is loaded from database and i click
expand list button, it sends request with empty mask instead of taking
value of combobox, it seems, that empty value is taken for some reason.
Here is my combo box :
editor : {
xtype : 'lazycombo',
minChars : 1,
pageSize : 20,
id : 'tax-code-combo',
store : 'TaxCodesStore',
triggerAction : 'all'
}
and here is request params :
limit 20
mask
organizationId 108
start 0
mask is empty instead of before set value.
Thanks for help
Theming DialogPreferences
Theming DialogPreferences
I'm using a theme to customize the look and feel of a settings dialog. The
preferences are defined in XML and inflated by a PreferenceFragment. The
way of attaching the fragment is basically as described in the developer
guide.
It works totally fine customizing the first screen via a custom theme
applied to the hosting activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_Preferences_Dialog);
...
With the style:
<style name="Theme.Preferences.Dialog"
parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:colorBackground">#fff0f0f0</item>
<item name="android:background">#fff0f0f0</item>
<item name="android:divider">#ffe0e0e0</item>
<item name="android:textColorPrimary">#ff555555</item>
<item name="android:textColorSecondary">#ff808080</item>
<item
name="android:textAppearanceLarge">@style/preferences_large_text</item>
<item
name="android:textAppearanceMedium">@style/preferences_medium_text</item>
</style>
The trouble is that all preferences that are opening up a dialog (like a
ListPreference), have a different style than the rest of the dialog and
having a non transparent region around the dialog:
I'm using a theme to customize the look and feel of a settings dialog. The
preferences are defined in XML and inflated by a PreferenceFragment. The
way of attaching the fragment is basically as described in the developer
guide.
It works totally fine customizing the first screen via a custom theme
applied to the hosting activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_Preferences_Dialog);
...
With the style:
<style name="Theme.Preferences.Dialog"
parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:colorBackground">#fff0f0f0</item>
<item name="android:background">#fff0f0f0</item>
<item name="android:divider">#ffe0e0e0</item>
<item name="android:textColorPrimary">#ff555555</item>
<item name="android:textColorSecondary">#ff808080</item>
<item
name="android:textAppearanceLarge">@style/preferences_large_text</item>
<item
name="android:textAppearanceMedium">@style/preferences_medium_text</item>
</style>
The trouble is that all preferences that are opening up a dialog (like a
ListPreference), have a different style than the rest of the dialog and
having a non transparent region around the dialog:
printf on linux vs windows
printf on linux vs windows
here is some C code :
int i;
printf("This text is printed\nThis text is not until the for loop end.");
for (i = 5; i > 0; i--)
{
printf("%d", i);
sleep(1);
}
Why the rest of the text after the '\n' is not printed before the for loop
start? Even the printf inside the for loop is only printed after the loop
end. If I put a '\n' at the end of the text, it print, but I do not want a
new line.
This only happen on Linux and not on Windows (just changed sleep(1) to
Sleep(1000) and added windows.h).
Thanks
here is some C code :
int i;
printf("This text is printed\nThis text is not until the for loop end.");
for (i = 5; i > 0; i--)
{
printf("%d", i);
sleep(1);
}
Why the rest of the text after the '\n' is not printed before the for loop
start? Even the printf inside the for loop is only printed after the loop
end. If I put a '\n' at the end of the text, it print, but I do not want a
new line.
This only happen on Linux and not on Windows (just changed sleep(1) to
Sleep(1000) and added windows.h).
Thanks
Converting to sql style string
Converting to sql style string
I have 3 variables:
var1="abc"
var2="def"
sqlPrefix = "select x,y in myTable where myVar in "
I want to create a string of ('abc','def'), so I can directly concatenate
that to the end of sqlPrefx, so my final string is select x,y in myTable
where myVar in ('abc','def')
I have 3 variables:
var1="abc"
var2="def"
sqlPrefix = "select x,y in myTable where myVar in "
I want to create a string of ('abc','def'), so I can directly concatenate
that to the end of sqlPrefx, so my final string is select x,y in myTable
where myVar in ('abc','def')
IronRouter authorisation controller
IronRouter authorisation controller
I'm wondering if anyone could demonstrate how to use a global 'before'
action on a router controller class that handles user authentication and
displays the appropriate route/template based on the result.
My use case is to have an AppController that acts as an authentication
firewall and blocks any child controller actions when a user is logged
out. E.g.
// Create a primary app controller stub with the auth firewall
AppController = RouteController.extend({});
// Extend the AppController with all the other app routes
MainController = AppController.extend({});
Any help would be appreciated!
I'm wondering if anyone could demonstrate how to use a global 'before'
action on a router controller class that handles user authentication and
displays the appropriate route/template based on the result.
My use case is to have an AppController that acts as an authentication
firewall and blocks any child controller actions when a user is logged
out. E.g.
// Create a primary app controller stub with the auth firewall
AppController = RouteController.extend({});
// Extend the AppController with all the other app routes
MainController = AppController.extend({});
Any help would be appreciated!
Is there a way to put Haskell code before the token rules in an Alex source file?
Is there a way to put Haskell code before the token rules in an Alex
source file?
Consider the following, working, Alex source file:
{
module Main (main) where
}
%wrapper "basic"
tokens :-
$white ;
. { rule "!"}
{
type Token = String
rule tok = \s -> tok
main = do
s <- getContents
mapM_ print (alexScanTokens s)
}
I would love to put my helper code closer to the top of the file, before
all the rules. I tried doing this:
{
module Main (main) where
}
%wrapper "basic"
{
type Token = String
rule tok = \s -> tok
}
tokens :-
$white ;
. { rule "!"}
{
main = do
s <- getContents
mapM_ print (alexScanTokens s)
}
but got the following error:
test.x:11:2: parse error
(line 11 is the closing curly brace after my helper code)
Is there a way to move my helper code closer to the top of the file?
I also tried putting the helper code in the first block, together with
"module Main" declaration but that didn't work because the "%wrapper" bit
generates some import statements that need to appear right as the first
thing in the generated file.
source file?
Consider the following, working, Alex source file:
{
module Main (main) where
}
%wrapper "basic"
tokens :-
$white ;
. { rule "!"}
{
type Token = String
rule tok = \s -> tok
main = do
s <- getContents
mapM_ print (alexScanTokens s)
}
I would love to put my helper code closer to the top of the file, before
all the rules. I tried doing this:
{
module Main (main) where
}
%wrapper "basic"
{
type Token = String
rule tok = \s -> tok
}
tokens :-
$white ;
. { rule "!"}
{
main = do
s <- getContents
mapM_ print (alexScanTokens s)
}
but got the following error:
test.x:11:2: parse error
(line 11 is the closing curly brace after my helper code)
Is there a way to move my helper code closer to the top of the file?
I also tried putting the helper code in the first block, together with
"module Main" declaration but that didn't work because the "%wrapper" bit
generates some import statements that need to appear right as the first
thing in the generated file.
Grouping algorithm for combinations
Grouping algorithm for combinations
Let's say I have a list of items, each item is defined by a simple structure
struct simpleItem
{
String Category1;
String Category2;
...
String CategoryN;
}
Each item have a series of values belonging to some categories. The number
of categories N is known at the time of processing a list and each items
have the same amount of categories and only one value per category, there
are no duplicate items. However, each list can have a different category
set.
I'm looking for a way to group these items by categories in a way that if
those groups are deconstructed into single items by combining each
permutations of categories, I'll end up with the original combinaisons,
with no duplicates.
A group result will be:
struct grouped
{
String[] Category1;
String[] Category2;
...
String[] CategoryN;
}
Example
For the sake of this example, we'll limit to 3 categories, but there can
be N.
Categories
Animal, Eye Color, Fur
Choices for "Animal" category: Cat, Dog, Rat, Horse
Choices for "Eye Color" category: Blue, Yellow, Green, Red, Orange
Choices for "Fur" category: Long, Short, Curly
If the list had all the permutations for those 3 categories, the end
result would be
Group 1 :
Animal [Cat, Dog, Rat, Horse]
Eye Color [Blue, Yellow, Green, Red, Orange]
Fur [Long, Short, Curly]
If I have a sublist, for example:
Cat, Blue, Long
Cat, Blue, Short
Dog, Blue, Long
Dog, Blue, Short
Dog, Green Long
Rat, Red, Short
Rat, Blue, Short
Let's call this list, Input (A)
After grouping these items into group we could end up with : (there could
be other possibilities)
Group 1:
Animal [Cat, Dog]
Eye Color [Blue ]
Fur [Long, Short]
Group 2:
Animal [Dog]
Eye Color [Green ]
Fur [Long]
Group 3:
Animal [Rat ]
Eye Color [Red, Blue]
Fur [Short ]
Let's call these groups, Output (B)
As we can see, by combining each items of the resulting groups, we'll end
back to the original input list of 7 elements in (A).
Question
So, I'm trying to write an algorithm that generates these groups. I am
trying to do this with LINQ, but I am also open for other suggestions. Any
suggestion on how to get to (B) from (A)?
Let's say I have a list of items, each item is defined by a simple structure
struct simpleItem
{
String Category1;
String Category2;
...
String CategoryN;
}
Each item have a series of values belonging to some categories. The number
of categories N is known at the time of processing a list and each items
have the same amount of categories and only one value per category, there
are no duplicate items. However, each list can have a different category
set.
I'm looking for a way to group these items by categories in a way that if
those groups are deconstructed into single items by combining each
permutations of categories, I'll end up with the original combinaisons,
with no duplicates.
A group result will be:
struct grouped
{
String[] Category1;
String[] Category2;
...
String[] CategoryN;
}
Example
For the sake of this example, we'll limit to 3 categories, but there can
be N.
Categories
Animal, Eye Color, Fur
Choices for "Animal" category: Cat, Dog, Rat, Horse
Choices for "Eye Color" category: Blue, Yellow, Green, Red, Orange
Choices for "Fur" category: Long, Short, Curly
If the list had all the permutations for those 3 categories, the end
result would be
Group 1 :
Animal [Cat, Dog, Rat, Horse]
Eye Color [Blue, Yellow, Green, Red, Orange]
Fur [Long, Short, Curly]
If I have a sublist, for example:
Cat, Blue, Long
Cat, Blue, Short
Dog, Blue, Long
Dog, Blue, Short
Dog, Green Long
Rat, Red, Short
Rat, Blue, Short
Let's call this list, Input (A)
After grouping these items into group we could end up with : (there could
be other possibilities)
Group 1:
Animal [Cat, Dog]
Eye Color [Blue ]
Fur [Long, Short]
Group 2:
Animal [Dog]
Eye Color [Green ]
Fur [Long]
Group 3:
Animal [Rat ]
Eye Color [Red, Blue]
Fur [Short ]
Let's call these groups, Output (B)
As we can see, by combining each items of the resulting groups, we'll end
back to the original input list of 7 elements in (A).
Question
So, I'm trying to write an algorithm that generates these groups. I am
trying to do this with LINQ, but I am also open for other suggestions. Any
suggestion on how to get to (B) from (A)?
RubyTest has no output in Sublime Text 2
RubyTest has no output in Sublime Text 2
I have seen lots of people talking about this, but yet a solution that
solves my particular problem. I have RubyTest installed for Sublime Text 2
and when I try to run the tests within Sublime, once I see the log for
what happened, this is what I see:
Traceback (most recent call last):
File "./sublime_plugin.py", line 337, in run_
File "./exec.py", line 145, in run
OSError: [Errno 20] Not a directory: '/Users/myuser/code/ruby/movie_spec.rb'
reloading /Users/myuser/Library/Application Support/Sublime Text
2/Packages/User/RubyTest.last-run
Package Control: No updated packages
Any ideas? Rspec runs just fine when I use it in the console
I have seen lots of people talking about this, but yet a solution that
solves my particular problem. I have RubyTest installed for Sublime Text 2
and when I try to run the tests within Sublime, once I see the log for
what happened, this is what I see:
Traceback (most recent call last):
File "./sublime_plugin.py", line 337, in run_
File "./exec.py", line 145, in run
OSError: [Errno 20] Not a directory: '/Users/myuser/code/ruby/movie_spec.rb'
reloading /Users/myuser/Library/Application Support/Sublime Text
2/Packages/User/RubyTest.last-run
Package Control: No updated packages
Any ideas? Rspec runs just fine when I use it in the console
What is the most suitable way to work with databases in Zend Framework?
What is the most suitable way to work with databases in Zend Framework?
I'm developing web application with Zend Framework. In the documentation
it says ...
"Be aware though that the Table Data Gateway pattern can become limiting
in larger systems."
What are the drawbacks of using Table Data Gateway ?
What is the most suitable way to handle database with Zend ?
I'm developing web application with Zend Framework. In the documentation
it says ...
"Be aware though that the Table Data Gateway pattern can become limiting
in larger systems."
What are the drawbacks of using Table Data Gateway ?
What is the most suitable way to handle database with Zend ?
Solution to Linear Nonhomogeneous Differential Equation
Solution to Linear Nonhomogeneous Differential Equation
Consider system:
$x'(t) = 3x(t) +e^(3t)$
$y'(t) = 2x(t) -y(t) -2z(t)$
$z'(t) = 3x(t) +6y(t) +6z(t)$
by first finding 3 lin. indep. solutions to the homogeneous Vector ODE:
$x'(t) = C x(t)$
then constructing the fundamental matrix $M(t|0)$
and hence finding the solution for $x(t)$ , $y(t)$ , $z(t)$ given ,
$x(0)=1$, $y(0)=0$, $z(0)=0$
Consider system:
$x'(t) = 3x(t) +e^(3t)$
$y'(t) = 2x(t) -y(t) -2z(t)$
$z'(t) = 3x(t) +6y(t) +6z(t)$
by first finding 3 lin. indep. solutions to the homogeneous Vector ODE:
$x'(t) = C x(t)$
then constructing the fundamental matrix $M(t|0)$
and hence finding the solution for $x(t)$ , $y(t)$ , $z(t)$ given ,
$x(0)=1$, $y(0)=0$, $z(0)=0$
Sunday, 25 August 2013
Lock specific app in iphone
Lock specific app in iphone
I am working as an ios developer.
I want to make an application for my personal use that can lock another apps.
This is for my personal use so i dont need apple permission or dont need
to place on app store.
Thanks
I am working as an ios developer.
I want to make an application for my personal use that can lock another apps.
This is for my personal use so i dont need apple permission or dont need
to place on app store.
Thanks
How to use %debug_package while using rpmbuild?
How to use %debug_package while using rpmbuild?
Linux version 2.6.18-131.el5 gcc version 4.1.2 RPM version 4.4.2.3
I use the following command to build packages: $ sudo rpmbuild -ba xxx.spec
I thought that the debuginfo package should be built by default, but only
get the xxx.src.rpm and xxx.x86_64.rpm, with no debuginfo package.
Then I add a line in my xxx.spec, "#%debug_package":
Then the debug package is built! But I thought that a line with a '#' in
the front is considered as comment! How does this work?
I'm totally confused.
Linux version 2.6.18-131.el5 gcc version 4.1.2 RPM version 4.4.2.3
I use the following command to build packages: $ sudo rpmbuild -ba xxx.spec
I thought that the debuginfo package should be built by default, but only
get the xxx.src.rpm and xxx.x86_64.rpm, with no debuginfo package.
Then I add a line in my xxx.spec, "#%debug_package":
Then the debug package is built! But I thought that a line with a '#' in
the front is considered as comment! How does this work?
I'm totally confused.
[ Singles & Dating ] Open Question : Is he attractive at all?
[ Singles & Dating ] Open Question : Is he attractive at all?
He doesn't have any confidence and has low self-esteem. Do you think he's
at least average? Is he ugly, average, or cute? Rate him for 10 pts? Be
honest!
http://i136.photobucket.com/albums/q167/mikeytheactor/438b0564-fb56-4100-a9fd-a34b11b93e42_zps7d6cb7b5.jpg?t=1377402312
He doesn't have any confidence and has low self-esteem. Do you think he's
at least average? Is he ugly, average, or cute? Rate him for 10 pts? Be
honest!
http://i136.photobucket.com/albums/q167/mikeytheactor/438b0564-fb56-4100-a9fd-a34b11b93e42_zps7d6cb7b5.jpg?t=1377402312
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or FTS_NUMB
or '('
I have many messages like the following in /var/log/mysqld.log What does
it mean?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$
centos 6.4 Server version: 5.6.12-56 Percona Server (GPL), Release rc60.4,
Revision 393
or '('
I have many messages like the following in /var/log/mysqld.log What does
it mean?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
syntax error, unexpected $end, expecting FTS_TEXT or FTS_TERM or
FTS_NUMB or '('
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$
centos 6.4 Server version: 5.6.12-56 Percona Server (GPL), Release rc60.4,
Revision 393
[ Maintenance & Repairs ] Open Question : Can the wheel bearing be damaged even if the wheel does not shake?
[ Maintenance & Repairs ] Open Question : Can the wheel bearing be damaged
even if the wheel does not shake?
even if the wheel does not shake?
Saturday, 24 August 2013
How to resolve Failed to connect to remote VM?
How to resolve Failed to connect to remote VM?
Launch error: Failed to connect to remote VM
Failed to connect to remote VM Can't connect to SOCKS proxy:Connection
refused: connect
Launch error: Failed to connect to remote VM
Failed to connect to remote VM Can't connect to SOCKS proxy:Connection
refused: connect
How can I use the par in R ?
How can I use the par in R ?
I read the instruction of it, but I still do not understand how it works.
Is it the same as using hold on and hold off in MATLAB ? and Where should
I place this function in plots ?
I read the instruction of it, but I still do not understand how it works.
Is it the same as using hold on and hold off in MATLAB ? and Where should
I place this function in plots ?
Jquery - slideshow buttons function code
Jquery - slideshow buttons function code
I have this very simple slideshow here
Jquery codes:
$("#slideshow > div:gt(0)").hide();
var maxindex = $('#slideshow > div').length;
var index = 0
var interval = 3 * 1000; // 3 seconds
var timerJob = setInterval(traverseSlideShow, interval);
function traverseSlideShow() {
console.log("current index: " + index);
$('#slideshow > div')
.stop()
.fadeOut(1000);
$('#slideshow > div').eq(index)
.stop()
.fadeIn(1000);
$('ul li').removeClass('active');
$('ul li:eq(' + index + ')').addClass('active');
index = (index < maxindex - 1) ? index + 1 : 0;
}
for (var i = 0; i < maxindex; i++) {
$('ul').append('<li class="' + (i == 0 ? 'active' : '') + '"></li>');
}
$(document).on('click', 'ul li', function () {
index = $(this).index();
traverseSlideShow();
clearInterval(timerJob);
timerJob = setInterval(traverseSlideShow, interval);
});
As you can see there's three buttons, on clicking any button the slideshow
automatically goes to the photo related with the button you click, and you
can see the style of this button changes(on click and after passing 3
seconds).
I have one problem with this code that I'm trying to fix.
Well, I'm trying to prevent clicking any button for one second after any
button's style is changed, simple, if you click any button you can not re
click another button within 1 second, and as well, if the slideshow
automatically loads a photo you can not load any other photo before 1
second.
I have this very simple slideshow here
Jquery codes:
$("#slideshow > div:gt(0)").hide();
var maxindex = $('#slideshow > div').length;
var index = 0
var interval = 3 * 1000; // 3 seconds
var timerJob = setInterval(traverseSlideShow, interval);
function traverseSlideShow() {
console.log("current index: " + index);
$('#slideshow > div')
.stop()
.fadeOut(1000);
$('#slideshow > div').eq(index)
.stop()
.fadeIn(1000);
$('ul li').removeClass('active');
$('ul li:eq(' + index + ')').addClass('active');
index = (index < maxindex - 1) ? index + 1 : 0;
}
for (var i = 0; i < maxindex; i++) {
$('ul').append('<li class="' + (i == 0 ? 'active' : '') + '"></li>');
}
$(document).on('click', 'ul li', function () {
index = $(this).index();
traverseSlideShow();
clearInterval(timerJob);
timerJob = setInterval(traverseSlideShow, interval);
});
As you can see there's three buttons, on clicking any button the slideshow
automatically goes to the photo related with the button you click, and you
can see the style of this button changes(on click and after passing 3
seconds).
I have one problem with this code that I'm trying to fix.
Well, I'm trying to prevent clicking any button for one second after any
button's style is changed, simple, if you click any button you can not re
click another button within 1 second, and as well, if the slideshow
automatically loads a photo you can not load any other photo before 1
second.
Confusion on using super with new style classes
Confusion on using super with new style classes
I have this:
#! /usr/bin/env python
class myclass1(object):
def __new__(cls,arg):
print cls, arg, "in new"
ss = super(object,cls)
print ss, type(ss)
ss.__new__(cls,arg)
# super(object,cls).__new__(cls,arg)
# return object.__new__(cls,arg)
def __init__(self,arg):
self.arg = arg + 1
print self, self.arg, "in init"
if __name__ == '__main__':
m = myclass1(56)
It gives an error:
$ ./newtest.py
<class '__main__.myclass1'> 56 in new
<super: <class 'object'>, <myclass1 object>> <type 'super'>
Traceback (most recent call last):
File "./newtest.py", line 23, in <module>
m = myclass1(56)
File "./newtest.py", line 9, in __new__
ss.__new__(cls,arg)
TypeError: super.__new__(myclass1): myclass1 is not a subtype of super
The error is valid. I get that. However I am now confused as to what the
documentation is saying on this page for __new__:
http://docs.python.org/2.6/reference/datamodel.html#object.__new__
Question: What am I doing wrong as per the documentation above. Where is
the gap in my understanding of the documention ?
I have this:
#! /usr/bin/env python
class myclass1(object):
def __new__(cls,arg):
print cls, arg, "in new"
ss = super(object,cls)
print ss, type(ss)
ss.__new__(cls,arg)
# super(object,cls).__new__(cls,arg)
# return object.__new__(cls,arg)
def __init__(self,arg):
self.arg = arg + 1
print self, self.arg, "in init"
if __name__ == '__main__':
m = myclass1(56)
It gives an error:
$ ./newtest.py
<class '__main__.myclass1'> 56 in new
<super: <class 'object'>, <myclass1 object>> <type 'super'>
Traceback (most recent call last):
File "./newtest.py", line 23, in <module>
m = myclass1(56)
File "./newtest.py", line 9, in __new__
ss.__new__(cls,arg)
TypeError: super.__new__(myclass1): myclass1 is not a subtype of super
The error is valid. I get that. However I am now confused as to what the
documentation is saying on this page for __new__:
http://docs.python.org/2.6/reference/datamodel.html#object.__new__
Question: What am I doing wrong as per the documentation above. Where is
the gap in my understanding of the documention ?
Redis-cli not syncing with node
Redis-cli not syncing with node
Currently I have been doing some testing with my database by adding users.
I check the list of my users by displaying them in the web application and
by using HGETALL "players" in redis-cli at command line.
It has come time for me to delete this key for a fresh production start.
Naturally I use the command DEL "players" in redis-cli and it returns
successfull. Checking the key again returns an empty result.
Awesome!
Checking in the web-app however, the same user list appears. When I
restart my the redis server, the users still appear. Also, using HGETALL
"players" also returns the same list of users I tested with.
How do I make redis-cli correspond to actually delete a key?
Thanks
Currently I have been doing some testing with my database by adding users.
I check the list of my users by displaying them in the web application and
by using HGETALL "players" in redis-cli at command line.
It has come time for me to delete this key for a fresh production start.
Naturally I use the command DEL "players" in redis-cli and it returns
successfull. Checking the key again returns an empty result.
Awesome!
Checking in the web-app however, the same user list appears. When I
restart my the redis server, the users still appear. Also, using HGETALL
"players" also returns the same list of users I tested with.
How do I make redis-cli correspond to actually delete a key?
Thanks
Instant read from CSV
Instant read from CSV
I have found a very nice working code which reads the data from the file.
http://www.cgrats.com/javascript-csv-file-reader.html
I am quite new in reading data from files and this code seems complicated
to me.
Now, the program asks you for location of the file, and then writes it to
console.
What I need is that it will read the files 'base_1.txt' and 'base_2.txt',
and then insert data to the array base_1_array, base_2_array, instantly,
wiwouth asking for any event.
Something like this
readCSV(file_name,array_name){
//function from link(file_name,array_name)
}
Thanks for all your help :)
I have found a very nice working code which reads the data from the file.
http://www.cgrats.com/javascript-csv-file-reader.html
I am quite new in reading data from files and this code seems complicated
to me.
Now, the program asks you for location of the file, and then writes it to
console.
What I need is that it will read the files 'base_1.txt' and 'base_2.txt',
and then insert data to the array base_1_array, base_2_array, instantly,
wiwouth asking for any event.
Something like this
readCSV(file_name,array_name){
//function from link(file_name,array_name)
}
Thanks for all your help :)
tomcat takes two attempts to start on windows server 2008
tomcat takes two attempts to start on windows server 2008
I have windows server with tomcat7 installed on it, it always take two
attempts to start, can any one give some idea why this happens , I tried
to google it but did'nt got any clue
I have windows server with tomcat7 installed on it, it always take two
attempts to start, can any one give some idea why this happens , I tried
to google it but did'nt got any clue
Any portable Database that supports procedures
Any portable Database that supports procedures
I am creating a Desktop application in .Net for which I need a database
which is
Portable i.e. like MS-Access
Have facility of stored procedures like SQL Server.
All the databases that I look for do not have both of this facilities. For
e.g. MS Access and SQL lite do not support procedures and SQL Server do
not support portability.
Or there are alternate databases having these two qualities?
I am creating a Desktop application in .Net for which I need a database
which is
Portable i.e. like MS-Access
Have facility of stored procedures like SQL Server.
All the databases that I look for do not have both of this facilities. For
e.g. MS Access and SQL lite do not support procedures and SQL Server do
not support portability.
Or there are alternate databases having these two qualities?
Friday, 23 August 2013
How do you solve this differential equation using variation of parameters?
How do you solve this differential equation using variation of parameters?
$\color{green}{question}$:
How do you solve this differential equation using variation of parameters?
$$y"-\frac{2x}{x^2+1}y'+\frac{2}{x^2+1}y=6(x^2+1)$$
$\color{green}{I~tried}$ . . .
$using~the~\color{blue}{Laplace~transform}~method$ . . .
$$L[\int_{0}^{\infty }\frac{sinxt}{1+t^{2}}dt]$$
$$=\int_{0}^{\infty }e^{-sx}(\int_{0}^{\infty }\frac{sinxt}{1+t^{2}}dt)$$
$$=\int_{0}^{\infty }\frac{1}{1+t^{2}}(\int_{0}^{\infty
}e^{-px}sinxtdx)dt\\\\\\=\int_{0}^{\infty
}\frac{1}{1+t^{2}}\frac{t}{s^{2}+t^{2}}dt$$
$$=\int_{0 }^{\infty
}\frac{1}{s^{2}-1}(\frac{t}{1+t^{2}}-\frac{t}{s^{2}+t^{2}})$$
$$=\frac{Lns}{s^{2}-1}$$
Is my solution correct?
Should I use the inverse Laplace?
How can I get a complete and correct answer?
Thanks for any hint.
$\color{green}{question}$:
How do you solve this differential equation using variation of parameters?
$$y"-\frac{2x}{x^2+1}y'+\frac{2}{x^2+1}y=6(x^2+1)$$
$\color{green}{I~tried}$ . . .
$using~the~\color{blue}{Laplace~transform}~method$ . . .
$$L[\int_{0}^{\infty }\frac{sinxt}{1+t^{2}}dt]$$
$$=\int_{0}^{\infty }e^{-sx}(\int_{0}^{\infty }\frac{sinxt}{1+t^{2}}dt)$$
$$=\int_{0}^{\infty }\frac{1}{1+t^{2}}(\int_{0}^{\infty
}e^{-px}sinxtdx)dt\\\\\\=\int_{0}^{\infty
}\frac{1}{1+t^{2}}\frac{t}{s^{2}+t^{2}}dt$$
$$=\int_{0 }^{\infty
}\frac{1}{s^{2}-1}(\frac{t}{1+t^{2}}-\frac{t}{s^{2}+t^{2}})$$
$$=\frac{Lns}{s^{2}-1}$$
Is my solution correct?
Should I use the inverse Laplace?
How can I get a complete and correct answer?
Thanks for any hint.
Write text on an image
Write text on an image
I am developing an image editor in which I have implemented rectangle,
lines and ellipse drawing functionality using mouse event and by using
Graphics.DrawLine(), Graphics.DrawRectangle() and Graphics.DrawEllipse().
I was searching for writing text on image but could not find any solution,
So what I mean is whenever click on image at any location the cursor will
change (like writing text in textbox) and I can start typing on that
location.
The Graphics.DrawString method is similar to what I am looking for but it
does not support dynamic typing
I am developing an image editor in which I have implemented rectangle,
lines and ellipse drawing functionality using mouse event and by using
Graphics.DrawLine(), Graphics.DrawRectangle() and Graphics.DrawEllipse().
I was searching for writing text on image but could not find any solution,
So what I mean is whenever click on image at any location the cursor will
change (like writing text in textbox) and I can start typing on that
location.
The Graphics.DrawString method is similar to what I am looking for but it
does not support dynamic typing
Calculate a variable using 2 Mysql tables and make a select based on that variable
Calculate a variable using 2 Mysql tables and make a select based on that
variable
I own an online game in which you become the coach of a rugby team and I
recently started to optimize my database. The website uses CodeIgniter
framework.
I have the following tables (the tables have more fields but I posted only
those which are important now):
LEAGUES: id
STANDINGS: league_id, team_id, points
TEAMS: id, active
Previously, I was having in the LEAGUES table a field named teams. This
was representing the number of active teams in that league (of which users
logged in recently). So, I was doing the following select to get a random
league that has between 0 and 4 active teams (leagues with less teams
first).
SELECT id FROM LEAGUES WHERE teams>0 AND teams<4 ORDER BY teams ASC, RAND(
) LIMIT 1
Is there any way I can do the same command now without having to add the
teams field? Is it efficient? Or It's better to keep the teams field in
the database?
variable
I own an online game in which you become the coach of a rugby team and I
recently started to optimize my database. The website uses CodeIgniter
framework.
I have the following tables (the tables have more fields but I posted only
those which are important now):
LEAGUES: id
STANDINGS: league_id, team_id, points
TEAMS: id, active
Previously, I was having in the LEAGUES table a field named teams. This
was representing the number of active teams in that league (of which users
logged in recently). So, I was doing the following select to get a random
league that has between 0 and 4 active teams (leagues with less teams
first).
SELECT id FROM LEAGUES WHERE teams>0 AND teams<4 ORDER BY teams ASC, RAND(
) LIMIT 1
Is there any way I can do the same command now without having to add the
teams field? Is it efficient? Or It's better to keep the teams field in
the database?
R - How to draw an empty plot with no height?
R - How to draw an empty plot with no height?
I can make an empty plot in R by using:
plot.new()
That create a blank plot with the default width and height.
I want to create an empty plot with minimal height. I tried png('z.png',
height=1), but that got me:
> png('x.png', height=1)
> plot.new()
Error in plot.new() : figure margins too large
How can I create such a plot? I guess I have to zero the margins too.
I can make an empty plot in R by using:
plot.new()
That create a blank plot with the default width and height.
I want to create an empty plot with minimal height. I tried png('z.png',
height=1), but that got me:
> png('x.png', height=1)
> plot.new()
Error in plot.new() : figure margins too large
How can I create such a plot? I guess I have to zero the margins too.
why the border in Photoshop turn out blurry?
why the border in Photoshop turn out blurry?
I'm using photoshop cs 6. when i try to make a border, it turn out blurry.
I've check feather, and stroke. All set in 0px. Here's the image of the
border. http://postimg.org/image/da4xs1xbx/
Thanks in advance
I'm using photoshop cs 6. when i try to make a border, it turn out blurry.
I've check feather, and stroke. All set in 0px. Here's the image of the
border. http://postimg.org/image/da4xs1xbx/
Thanks in advance
Nginx match multiple paths in location directive
Nginx match multiple paths in location directive
I have the following directives in my nginx conf, that are working correctly:
location = /favicon.ico {
root /home/www/myapp/static/ico;
}
location ^~ /apple-touch-icon {
root /home/www/myapp/static/ico;
}
I would to merge those expression in one directive but I cant figure out
how to correctly build the regex. I tried the following but it works only
for favicon.ico and I get 404 requesting /apple-touch-icon-precomposed.png
location ~* ^/(apple-touch-icon(.)*\.png|favicon.ico) {
root /home/www/myapp/static/ico;
}
It is a problem of what is matched I think.
I have the following directives in my nginx conf, that are working correctly:
location = /favicon.ico {
root /home/www/myapp/static/ico;
}
location ^~ /apple-touch-icon {
root /home/www/myapp/static/ico;
}
I would to merge those expression in one directive but I cant figure out
how to correctly build the regex. I tried the following but it works only
for favicon.ico and I get 404 requesting /apple-touch-icon-precomposed.png
location ~* ^/(apple-touch-icon(.)*\.png|favicon.ico) {
root /home/www/myapp/static/ico;
}
It is a problem of what is matched I think.
Thursday, 22 August 2013
find instructor free times in mysql ph
find instructor free times in mysql ph
I have a table in mysql like this:
+------------+------------+------------+------------+
| user_id | inst_id | date_start | date_end |
+------------+------------+------------+------------+
| 20 | 1 |1375344000 |1375351200 |
+------------+------------+------------+------------+
it tried about 20 queries but couldn't come up with an idea to get inst_id
result within any given range time. for example i want to know which
inst_id are available from 2013-08-01 8:00 to 2013-08-01 10:00
I have a table in mysql like this:
+------------+------------+------------+------------+
| user_id | inst_id | date_start | date_end |
+------------+------------+------------+------------+
| 20 | 1 |1375344000 |1375351200 |
+------------+------------+------------+------------+
it tried about 20 queries but couldn't come up with an idea to get inst_id
result within any given range time. for example i want to know which
inst_id are available from 2013-08-01 8:00 to 2013-08-01 10:00
How can I use a variable's value in a variable name in JavaScript?
How can I use a variable's value in a variable name in JavaScript?
I have a dynamically allocated array and I'm making a switch function that
starts like this:
switch (Years['year'].StartDay) {
The function that it's in passes a value called year and has a value in
it, like this:
function CalendarData(year, month) {
var Years = new Object();
Years.['2013'].StartDay = 'Sunday';
switch (Years['year'].StartDay) {
case 'Sunday':
this.Day = 1;
break;
}
}
I would like to make a new Object and get the data from the object, like
this:
var CalendayDay = new CalendarData('2013','February');
The issue is it's not reading Years['year'].StartDay
I have a dynamically allocated array and I'm making a switch function that
starts like this:
switch (Years['year'].StartDay) {
The function that it's in passes a value called year and has a value in
it, like this:
function CalendarData(year, month) {
var Years = new Object();
Years.['2013'].StartDay = 'Sunday';
switch (Years['year'].StartDay) {
case 'Sunday':
this.Day = 1;
break;
}
}
I would like to make a new Object and get the data from the object, like
this:
var CalendayDay = new CalendarData('2013','February');
The issue is it's not reading Years['year'].StartDay
Insert comma(,) into a value using jQuery
Insert comma(,) into a value using jQuery
Hello there i have problem in jQuery. Suppose i have a value like 20000.
And i want the value like 20,000 that after two number a comma will be
inserted. I can't do it using jQuery. Please anyone help me out.
Hello there i have problem in jQuery. Suppose i have a value like 20000.
And i want the value like 20,000 that after two number a comma will be
inserted. I can't do it using jQuery. Please anyone help me out.
html and php variables
html and php variables
I am using a while loop to retrieve data from a database and i require a
html entities halfway through my script(refer to image below)
However, the html tag takes into account the last result which i have
retrieved from the while loop, does anyone have a solution whereby the
variable will coincide accordingly to the retrieved result instead of the
last result?($name and $date_posted variable changes accordingly to the
results retrieved from database in a while loop)
I am using a while loop to retrieve data from a database and i require a
html entities halfway through my script(refer to image below)
However, the html tag takes into account the last result which i have
retrieved from the while loop, does anyone have a solution whereby the
variable will coincide accordingly to the retrieved result instead of the
last result?($name and $date_posted variable changes accordingly to the
results retrieved from database in a while loop)
Socket.io xdomain https flashsockets
Socket.io xdomain https flashsockets
Is it possible to have a secure flashsocket connection with a XDomain
socket.io app? On the socket.io-client I see the following comment:
* The FlashSocket transport. This is a API wrapper for the HTML5 WebSocket
* specification. It uses a .swf file to communicate with the server. If
you want
* to serve the .swf file from a other server than where the Socket.IO
script is
* coming from you need to use the insecure version of the .swf. More
information
* about this can be found on the github page.
but cant find the spot on the github page that talks about why it's not
possible to use https, xdomain flashsockets with socket.io. I'm using
flashsockets for older IE... Seems more reliable than other transports.
On my app, the js is served from a subdomain of my domain on server X, and
the .swf would be server from another server, on a different subdomain of
the same domain:
script is served from sub1.mydomain.com on server X
flash is served and connects to sub2.mydomain.com on server Y (holds
socket.io server)
Thanks for your help!
Is it possible to have a secure flashsocket connection with a XDomain
socket.io app? On the socket.io-client I see the following comment:
* The FlashSocket transport. This is a API wrapper for the HTML5 WebSocket
* specification. It uses a .swf file to communicate with the server. If
you want
* to serve the .swf file from a other server than where the Socket.IO
script is
* coming from you need to use the insecure version of the .swf. More
information
* about this can be found on the github page.
but cant find the spot on the github page that talks about why it's not
possible to use https, xdomain flashsockets with socket.io. I'm using
flashsockets for older IE... Seems more reliable than other transports.
On my app, the js is served from a subdomain of my domain on server X, and
the .swf would be server from another server, on a different subdomain of
the same domain:
script is served from sub1.mydomain.com on server X
flash is served and connects to sub2.mydomain.com on server Y (holds
socket.io server)
Thanks for your help!
Some characters are called evil for not encodeing
Some characters are called evil for not encodeing
i am .net programmer and i use vb.net I am writing a program to get data
from a Html File But my problem is that badly written characters that are
received in Farsi In other languages: Some characters are called evil for
not encodeing For example, the The ����
� �����
������
my html file:my html I get data from it
my code is :
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
OpenFileDialog1.ShowDialog()
Dim pfile As String
pfile = OpenFileDialog1.FileName.ToString
Dim a As System.Text.Encoding
a = System.Text.Encoding.UTF8 '' I used other encoding Such as default
assci windows-1257 and ... but not fix!!
Dim k_reader As New StreamReader(pfile.ToString, a)
RichTextBox1.Text = k_reader.ReadToEnd
End Sub
End Class
tnx i love stackoverflow.com
i am .net programmer and i use vb.net I am writing a program to get data
from a Html File But my problem is that badly written characters that are
received in Farsi In other languages: Some characters are called evil for
not encodeing For example, the The ����
� �����
������
my html file:my html I get data from it
my code is :
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
OpenFileDialog1.ShowDialog()
Dim pfile As String
pfile = OpenFileDialog1.FileName.ToString
Dim a As System.Text.Encoding
a = System.Text.Encoding.UTF8 '' I used other encoding Such as default
assci windows-1257 and ... but not fix!!
Dim k_reader As New StreamReader(pfile.ToString, a)
RichTextBox1.Text = k_reader.ReadToEnd
End Sub
End Class
tnx i love stackoverflow.com
Michael Hartl's Rails Tutorial - Syntax Error with Bundle Exec Guard
Michael Hartl's Rails Tutorial - Syntax Error with Bundle Exec Guard
I'm attempting to get through Michael Hartl's tutorial here, and I can't
seem to figure out why when I run 'bundle exec guard', it presents a
syntax error, from what I believe it to be. I am new to Ruby on Rails, new
to coding, and new to web development.
This is what I am getting:
Corey-M-Kimball:sample_app coreymkimball$ bundle exec guard
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:119:in
instance_eval': /Users/coreymkimball/Canvi/sample_app/Guardfile:50: syntax
error, unexpected '.' (SyntaxError)
/Users/coreymkimball/Canvi/sample_app/Guardfile:86: syntax error,
unexpected '.' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:119:ininstance_eval_guardfile'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:74:in
evaluate_guardfile' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:166:insetup_from_guardfile'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:68:in
setup' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:207:instart'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/cli.rb:110:in
start' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/command.rb:27:inrun'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in
invoke_command' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor.rb:363:indispatch'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/base.rb:439:in
start' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/bin/guard:6:in'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/guard:23:in
load' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/guard:23:in'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in
eval' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in'
And even if I remove and delete all the content in the Guardfile, it still
presents a 'syntax error'.
Can anyone help?
I'm attempting to get through Michael Hartl's tutorial here, and I can't
seem to figure out why when I run 'bundle exec guard', it presents a
syntax error, from what I believe it to be. I am new to Ruby on Rails, new
to coding, and new to web development.
This is what I am getting:
Corey-M-Kimball:sample_app coreymkimball$ bundle exec guard
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:119:in
instance_eval': /Users/coreymkimball/Canvi/sample_app/Guardfile:50: syntax
error, unexpected '.' (SyntaxError)
/Users/coreymkimball/Canvi/sample_app/Guardfile:86: syntax error,
unexpected '.' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:119:ininstance_eval_guardfile'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/dsl.rb:74:in
evaluate_guardfile' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:166:insetup_from_guardfile'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:68:in
setup' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard.rb:207:instart'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/lib/guard/cli.rb:110:in
start' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/command.rb:27:inrun'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in
invoke_command' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor.rb:363:indispatch'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/thor-0.18.1/lib/thor/base.rb:439:in
start' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/guard-1.8.2/bin/guard:6:in'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/guard:23:in
load' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/guard:23:in'
from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in
eval' from
/Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/bin/ruby_noexec_wrapper:14:in'
And even if I remove and delete all the content in the Guardfile, it still
presents a 'syntax error'.
Can anyone help?
Wednesday, 21 August 2013
How many concurrent request can tomcat handle by Default
How many concurrent request can tomcat handle by Default
How many requests Tomcat7.0.42 handle at a time.Can we configure the same
in any external File.If so where.
How many requests Tomcat7.0.42 handle at a time.Can we configure the same
in any external File.If so where.
Missing indexes statistics is missing on SQL Server 2008 R2
Missing indexes statistics is missing on SQL Server 2008 R2
I have an installation of SQL Server 2008 R2 (one of a few) and it's
reasonably busy system. I'm trying to optimise some of the indexes like
I've done in the past by using information from missing indexes tables.
What seems to be strange is that sys.dm_db_missing_index_group_stats table
is empty?!
Now I don't believe for a second that none of the databases on that server
misses a beat and other tables like sys.dm_db_missing_index_group_stats,
sys.dm_db_missing_index_group_stats, etc contain plenty of records.
Just now I've seen 1 (one) record briefly appearing in that table and it's
gone since then.
I wonder if something is seriously wrong with that server or if I'm
missing a trivial
I have an installation of SQL Server 2008 R2 (one of a few) and it's
reasonably busy system. I'm trying to optimise some of the indexes like
I've done in the past by using information from missing indexes tables.
What seems to be strange is that sys.dm_db_missing_index_group_stats table
is empty?!
Now I don't believe for a second that none of the databases on that server
misses a beat and other tables like sys.dm_db_missing_index_group_stats,
sys.dm_db_missing_index_group_stats, etc contain plenty of records.
Just now I've seen 1 (one) record briefly appearing in that table and it's
gone since then.
I wonder if something is seriously wrong with that server or if I'm
missing a trivial
Fast algorithm to find one path through a tree
Fast algorithm to find one path through a tree
I have a finite rooted tree where each vertex has the same number of
children (except terminal vertices). Some edges are "free" and some are
"blocked". I am looking for an efficient algorithm to find just ONE path
from the root to any of the ends using "free" edges only, or determine
that none exist. Any ideas about the best way to do that? I wrote one
that's faster than checking all terminal nodes, but I am not sure if it's
the best.
I am more interested in the theoretical aspects of the different ways to
solve this problem, so a reference to a known algorithm or class of
algorithms would be most helpful.
I have a finite rooted tree where each vertex has the same number of
children (except terminal vertices). Some edges are "free" and some are
"blocked". I am looking for an efficient algorithm to find just ONE path
from the root to any of the ends using "free" edges only, or determine
that none exist. Any ideas about the best way to do that? I wrote one
that's faster than checking all terminal nodes, but I am not sure if it's
the best.
I am more interested in the theoretical aspects of the different ways to
solve this problem, so a reference to a known algorithm or class of
algorithms would be most helpful.
Batch Code Formatting (PHP) Eclipse
Batch Code Formatting (PHP) Eclipse
I've finally gotten eclipse set up with some good code formatting. However
I cannot seem to find a way for it to format entire batches of files.
Does anyone know if there is a way to do that?
I've finally gotten eclipse set up with some good code formatting. However
I cannot seem to find a way for it to format entire batches of files.
Does anyone know if there is a way to do that?
curl to xively using python
curl to xively using python
I'm looking to push json packets to xively using this command:
jstr = '''{ "version":"1.0.0",
"datastreams":[{"id":"one","current_value":"100.00"},{"id":"two","current_value":"022.02"},{"id":"three","current_value":"033.03"},{"id":"four","current_value":"044.04"}]
}'''
and running it by calling this cmd = "curl --request PUT %s --header %s
--verbose %s" % (jstr,apiKey,feedId)
I'm doing it this way so I can manipulate the JSON between transmissions
(I change it to a dict and back).
Its throwing an error saying that there is no data sent. Help I'm new to
curl, xively and python so its really confusing me. Any help would be
greatly appreciated please.
I'm looking to push json packets to xively using this command:
jstr = '''{ "version":"1.0.0",
"datastreams":[{"id":"one","current_value":"100.00"},{"id":"two","current_value":"022.02"},{"id":"three","current_value":"033.03"},{"id":"four","current_value":"044.04"}]
}'''
and running it by calling this cmd = "curl --request PUT %s --header %s
--verbose %s" % (jstr,apiKey,feedId)
I'm doing it this way so I can manipulate the JSON between transmissions
(I change it to a dict and back).
Its throwing an error saying that there is no data sent. Help I'm new to
curl, xively and python so its really confusing me. Any help would be
greatly appreciated please.
How to bypass the exif_imagetype function to upload php code?
How to bypass the exif_imagetype function to upload php code?
I read that exif_imagetype is secure function to avoid uploading php or
other shell code instead of image file. Recently i read another article
that we can bypass this secure function by some simple methods. So if
someone knows the exact method to bypass can u share your answers.
I read that exif_imagetype is secure function to avoid uploading php or
other shell code instead of image file. Recently i read another article
that we can bypass this secure function by some simple methods. So if
someone knows the exact method to bypass can u share your answers.
WinRAR Recovery Records not adding?
WinRAR Recovery Records not adding?
I have this 218 GB worth of personal data, which I'm trying to backup for
myself .. I tried creating an archive yesterday (200 MB splits) and I
ticked the Put Recovery Record option .. However when the archiving was
complete, I saw that they were no rev files .. Not even one ..
So how can I add about 20 or so Recovery Record rev files to this archive ?
I have this 218 GB worth of personal data, which I'm trying to backup for
myself .. I tried creating an archive yesterday (200 MB splits) and I
ticked the Put Recovery Record option .. However when the archiving was
complete, I saw that they were no rev files .. Not even one ..
So how can I add about 20 or so Recovery Record rev files to this archive ?
Tuesday, 20 August 2013
Warning: Division by zero PHP check
Warning: Division by zero PHP check
I am using symfony 1.1 to read an API and store the values in DB
if(($xmlArray->{'MDD'} == 0) || ($xmlArray->{'MDD'} == '0') ){
$autoStraObj->setRisk(' - ');
}else{
$autoStraObj->setRisk(round(($xmlArray->{'Pips'} /
$xmlArray->{'MDD'}), 10));
}
For Some Records, the above code results with
Warning: Division by zero in.... Not sure, that is the issue here
I am using symfony 1.1 to read an API and store the values in DB
if(($xmlArray->{'MDD'} == 0) || ($xmlArray->{'MDD'} == '0') ){
$autoStraObj->setRisk(' - ');
}else{
$autoStraObj->setRisk(round(($xmlArray->{'Pips'} /
$xmlArray->{'MDD'}), 10));
}
For Some Records, the above code results with
Warning: Division by zero in.... Not sure, that is the issue here
jquery mobile css override not working
jquery mobile css override not working
I've tried many different approaches to override the body color of my jqm
site but no luck. Something seemed broken because firebug shows me the
correct colour but the remote jqm.min.css is still overriding mine. I'm
wondering whether my html file is corrupt.
http://qandaapp.scienceacademy.org.au/publish/index6.html
Order of css files
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.3.2/jquery.mobile- 1.3.2.min.css"
/>
<link rel="stylesheet" href="themes/custom-1/Q.css">
<link rel="stylesheet" type="text/css" href="includes/myoverrides.css">
Added a custom class colorOverride to
<body class="colorOverride ui-mobile-viewport ui-overlay-a">
CSS Rule
body.colorOverride.ui-mobile-viewport.ui-overlay-a,
body.colorOverride.ui-mobile-viewport.ui-body-a, ui-overlay-a, ui-body-a {
background-color:#4b5561 !important;
}
I've tried many different approaches to override the body color of my jqm
site but no luck. Something seemed broken because firebug shows me the
correct colour but the remote jqm.min.css is still overriding mine. I'm
wondering whether my html file is corrupt.
http://qandaapp.scienceacademy.org.au/publish/index6.html
Order of css files
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.3.2/jquery.mobile- 1.3.2.min.css"
/>
<link rel="stylesheet" href="themes/custom-1/Q.css">
<link rel="stylesheet" type="text/css" href="includes/myoverrides.css">
Added a custom class colorOverride to
<body class="colorOverride ui-mobile-viewport ui-overlay-a">
CSS Rule
body.colorOverride.ui-mobile-viewport.ui-overlay-a,
body.colorOverride.ui-mobile-viewport.ui-body-a, ui-overlay-a, ui-body-a {
background-color:#4b5561 !important;
}
ABS with both Navigation Drawer and DropDown Menu
ABS with both Navigation Drawer and DropDown Menu
Does anybody know if you can use both NavigationDrawer (slideMenu, such as
FourSquare) and DropDown Menu? I'm using ActionBar Sherlock, since I have
to support versions from Android 2.3. First one, NavigationDrawer is to
navigate among activities. About DropDown Menu, I want to use it to change
the content of some lists. Thanks in advance.
Does anybody know if you can use both NavigationDrawer (slideMenu, such as
FourSquare) and DropDown Menu? I'm using ActionBar Sherlock, since I have
to support versions from Android 2.3. First one, NavigationDrawer is to
navigate among activities. About DropDown Menu, I want to use it to change
the content of some lists. Thanks in advance.
Spring is not Autowiring my filter class
Spring is not Autowiring my filter class
I have a servlet filter declared like so:
@Component
public class BlahBlahFilter extends OncePerRequestFilter implements Filter {
with a property declared like so:
@Autowired
@Qualifier("appProperties")
AppProperties properties;
I have the same Autowired declaration in many of my components in the app
and no problems with them - but they are all controllers, services and
other misc stuff with @Component tag
But just this filter class is being ignored, and I cannot figure out how
to get Spring to inject the property into it.
I noticed in my debug log file this was written next to this class name
during component scan:
"Ignored because not a concrete top-level class"
Huh? Yes it is a concrete class, it is not abstract nor is it an
interface. Seems very fishy....
What can I do?
I saw some other topics on this and they were absolutely no help. Neither
of them have an accepted answer and none of the posts helped my situation
either.
Other relevant code snippets which may help:
web.xml:
<filter>
<filter-name>blahBlahFilter</filter-name>
<filter-class>com.blah.BlahBlahFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>blahBlahFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
spring-mvc.xml:
<context:annotation-config/>
<context:component-scan base-package="com.blah"/>
<mvc:annotation-driven/>
I have a servlet filter declared like so:
@Component
public class BlahBlahFilter extends OncePerRequestFilter implements Filter {
with a property declared like so:
@Autowired
@Qualifier("appProperties")
AppProperties properties;
I have the same Autowired declaration in many of my components in the app
and no problems with them - but they are all controllers, services and
other misc stuff with @Component tag
But just this filter class is being ignored, and I cannot figure out how
to get Spring to inject the property into it.
I noticed in my debug log file this was written next to this class name
during component scan:
"Ignored because not a concrete top-level class"
Huh? Yes it is a concrete class, it is not abstract nor is it an
interface. Seems very fishy....
What can I do?
I saw some other topics on this and they were absolutely no help. Neither
of them have an accepted answer and none of the posts helped my situation
either.
Other relevant code snippets which may help:
web.xml:
<filter>
<filter-name>blahBlahFilter</filter-name>
<filter-class>com.blah.BlahBlahFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>blahBlahFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
spring-mvc.xml:
<context:annotation-config/>
<context:component-scan base-package="com.blah"/>
<mvc:annotation-driven/>
Javascript event fired on long press/tap on tablets
Javascript event fired on long press/tap on tablets
I am developing a website using RWD priciples and it is supposed to self
adjust and work in both desktop and in tablets, and eventually in Mobiles
as well.
I know in android development we can catch a long tap event and do some
actions.
But my question is that, is it possible to do it in HTML/HTML5 and
javascript?
Basically looking for a predefined event which gets fired on long press on
html elements.
I have gone through This and understood all the alternatives suggested.
Looking if anything new has been introduced in HTML5.
Thanks
I am developing a website using RWD priciples and it is supposed to self
adjust and work in both desktop and in tablets, and eventually in Mobiles
as well.
I know in android development we can catch a long tap event and do some
actions.
But my question is that, is it possible to do it in HTML/HTML5 and
javascript?
Basically looking for a predefined event which gets fired on long press on
html elements.
I have gone through This and understood all the alternatives suggested.
Looking if anything new has been introduced in HTML5.
Thanks
reading images from memory card ANDROID
reading images from memory card ANDROID
int image[] =
{R.drawable.d002_p001,R.drawable.d002_p002,R.drawable.d002_p003,
R.drawable.d002_p004,R.drawable.d002_p005,R.drawable.d002_p006};
showPhoto(imCurrentPhotoIndex);
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("photo_index", imCurrentPhotoIndex);
super.onSaveInstanceState(outState);
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
imCurrentPhotoIndex = savedInstanceState.getInt("photo_index");
showPhoto(imCurrentPhotoIndex);
super.onRestoreInstanceState(savedInstanceState);
}
private void showPhoto(int photoIndex) {
ImageView imageView = (ImageView) findViewById(R.id.image_view);
// imageView.setImageResource(imPhotoIds[photoIndex]);
imageView.setImageResource(imPhotoIds[photoIndex]);
}
above code is used to read and display images from drawable folder. I want
read images from a folder in memory card; what i should do?
int image[] =
{R.drawable.d002_p001,R.drawable.d002_p002,R.drawable.d002_p003,
R.drawable.d002_p004,R.drawable.d002_p005,R.drawable.d002_p006};
showPhoto(imCurrentPhotoIndex);
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("photo_index", imCurrentPhotoIndex);
super.onSaveInstanceState(outState);
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
imCurrentPhotoIndex = savedInstanceState.getInt("photo_index");
showPhoto(imCurrentPhotoIndex);
super.onRestoreInstanceState(savedInstanceState);
}
private void showPhoto(int photoIndex) {
ImageView imageView = (ImageView) findViewById(R.id.image_view);
// imageView.setImageResource(imPhotoIds[photoIndex]);
imageView.setImageResource(imPhotoIds[photoIndex]);
}
above code is used to read and display images from drawable folder. I want
read images from a folder in memory card; what i should do?
Spring MVC REST JsonSerializer serialize long in exponential notation format
Spring MVC REST JsonSerializer serialize long in exponential notation format
There is custom Json serializer(for ObjectMapper) in my Spring MVC REST
application:
public class DateSerializer extends JsonSerializer<LocalDate>
{
public LocalDateSerializer()
{
super();
}
@Override
public void serialize(LocalDate value, JsonGenerator jgen,
SerializerProvider provider) throws IOException
{
if (value != null)
{
jgen.writeNumber(value.toDateTimeAtStartOfDay().getMillis());
}
}
}
and service returns json representation of this field with exponential
notation format e.g. 1.377216E12 instead of normal timestamp format
Many thanks in advance.
There is custom Json serializer(for ObjectMapper) in my Spring MVC REST
application:
public class DateSerializer extends JsonSerializer<LocalDate>
{
public LocalDateSerializer()
{
super();
}
@Override
public void serialize(LocalDate value, JsonGenerator jgen,
SerializerProvider provider) throws IOException
{
if (value != null)
{
jgen.writeNumber(value.toDateTimeAtStartOfDay().getMillis());
}
}
}
and service returns json representation of this field with exponential
notation format e.g. 1.377216E12 instead of normal timestamp format
Many thanks in advance.
Monday, 19 August 2013
How to pass jquery values to php without page loading
How to pass jquery values to php without page loading
i want to pass the jquery value "selected" to fetchdata.php without
reloading page. please help me
here is my code
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"
type="text/javascript">
</script>
<script>
$(document).ready(function () {
$("#buttonClass").click(function() {
getValueUsingClass();
});
});
function getValueUsingClass(){
var chkArray = [];
$(".chk:checked").each(function() {
chkArray.push($(this).val());
});
/* we join the array separated by the comma */
var selected;
selected = chkArray.join('#') + "#";
if(selected.length > 1)
{
$.ajax({
url: "fetchdata.php", //This is the page where you will handle your SQL
insert
type: "GET",
data: "val=" + selected, //The data your sending to some-page.php
success: function()
{
console.log("AJAX request was successfull");
},
error:function()
{
console.log("AJAX request was a failure");
}
});
//alert("You have selected " + selected);
}else
{
alert("Please at least one of the checkbox");
}
}
</script>
</head>
<body>
<div id="checkboxlist">
<div><input type="checkbox" value="1" class="chk"> Value 1</div>
<div><input type="checkbox" value="2" class="chk"> Value 2</div>
<div><input type="checkbox" value="3" class="chk"> Value 3</div>
<div><input type="checkbox" value="4" class="chk"> Value 4</div>
<div><input type="checkbox" value="5" class="chk"> Value 5</div>
<div>
<input type="button" value="Get Value Using Class" id="buttonClass">
</div>
</html>
fetchdata.php
<?php
foreach($_GET['val'] as $r)
{
print_r($r);
}
?>
i am use get method to receive the data.foreach loop for printing array...
But i am not getting any values in the php file
i want to pass the jquery value "selected" to fetchdata.php without
reloading page. please help me
here is my code
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"
type="text/javascript">
</script>
<script>
$(document).ready(function () {
$("#buttonClass").click(function() {
getValueUsingClass();
});
});
function getValueUsingClass(){
var chkArray = [];
$(".chk:checked").each(function() {
chkArray.push($(this).val());
});
/* we join the array separated by the comma */
var selected;
selected = chkArray.join('#') + "#";
if(selected.length > 1)
{
$.ajax({
url: "fetchdata.php", //This is the page where you will handle your SQL
insert
type: "GET",
data: "val=" + selected, //The data your sending to some-page.php
success: function()
{
console.log("AJAX request was successfull");
},
error:function()
{
console.log("AJAX request was a failure");
}
});
//alert("You have selected " + selected);
}else
{
alert("Please at least one of the checkbox");
}
}
</script>
</head>
<body>
<div id="checkboxlist">
<div><input type="checkbox" value="1" class="chk"> Value 1</div>
<div><input type="checkbox" value="2" class="chk"> Value 2</div>
<div><input type="checkbox" value="3" class="chk"> Value 3</div>
<div><input type="checkbox" value="4" class="chk"> Value 4</div>
<div><input type="checkbox" value="5" class="chk"> Value 5</div>
<div>
<input type="button" value="Get Value Using Class" id="buttonClass">
</div>
</html>
fetchdata.php
<?php
foreach($_GET['val'] as $r)
{
print_r($r);
}
?>
i am use get method to receive the data.foreach loop for printing array...
But i am not getting any values in the php file
smoothdivscroller slow loading
smoothdivscroller slow loading
i am using smoothdivscroller on a photogrphy website, so there are plenty
of large images to load. the problem i have is this. the first image will
load into the scroller, but the page would then be static on that image
without any scrolling. only once all the images are loaded will the slider
start to scroll.
is this the way it normaly works, or did i impliment it wrong?
is there a way that i can get the scroller to start scrolling right from
the start with the available images?
any help or suggestions would be great
thanks
i am using smoothdivscroller on a photogrphy website, so there are plenty
of large images to load. the problem i have is this. the first image will
load into the scroller, but the page would then be static on that image
without any scrolling. only once all the images are loaded will the slider
start to scroll.
is this the way it normaly works, or did i impliment it wrong?
is there a way that i can get the scroller to start scrolling right from
the start with the available images?
any help or suggestions would be great
thanks
Translating this XML to JSON using XSLT
Translating this XML to JSON using XSLT
I am attempting to translate some trivial XML to JSON using XSLT.
My XML looks like the following:
<some_xml>
<a>
<b>
<c foo="bar1">
<listing n="1">a</listing>
<listing n="2">b</listing>
<listing n="3">c</listing>
<listing n="4">d</listing>
</c>
<c foo="bar2">
<listing n="1">e</listing>
<listing n="2">b</listing>
<listing n="3">n</listing>
<listing n="4">d</listing>
</c>
</b>
</a>
</some_xml>
The output should look something like the following:
{
"my_c": [
{
"c": {
"foo_id": "bar1",
"listing_1": "a",
"listing_2": "b",
"listing_3": "c",
"listing_4": "d"
}
},
{
"c": {
"foo_id": "bar2",
"listing_1": "e",
"listing_2": "b",
"listing_3": "n",
"listing_4": "d"
}
}
],
}
my XSLT to attempt to get this translation to work:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:template match="/some_xml">
{
"my_c": [
<xsl:for-each select="a/b/c">
{
"c": {
"foo_id": <xsl:value-of select="@foo">,
"listing_1": <xsl:value-of
select="current()/listing[@n='1']" />,
"listing_2": <xsl:value-of
select="current()/listing[@n='2']" />,
"listing_3": <xsl:value-of
select="current()/listing[@n='3']" />,
"listing_4": <xsl:value-of
select="current()/listing[@n='4']" />
}
},
</xsl:for-each>
],
}
</xsl:template>
</xsl:stylesheet>
And the following broken output is what results:
{
"my_c": [
{
"c": {
"foo_id": "bar1"
],
}
}
{
"c": {
"foo_id": "bar2"
],
}
}
Where did I go wrong in my XSLT?
I am attempting to translate some trivial XML to JSON using XSLT.
My XML looks like the following:
<some_xml>
<a>
<b>
<c foo="bar1">
<listing n="1">a</listing>
<listing n="2">b</listing>
<listing n="3">c</listing>
<listing n="4">d</listing>
</c>
<c foo="bar2">
<listing n="1">e</listing>
<listing n="2">b</listing>
<listing n="3">n</listing>
<listing n="4">d</listing>
</c>
</b>
</a>
</some_xml>
The output should look something like the following:
{
"my_c": [
{
"c": {
"foo_id": "bar1",
"listing_1": "a",
"listing_2": "b",
"listing_3": "c",
"listing_4": "d"
}
},
{
"c": {
"foo_id": "bar2",
"listing_1": "e",
"listing_2": "b",
"listing_3": "n",
"listing_4": "d"
}
}
],
}
my XSLT to attempt to get this translation to work:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:template match="/some_xml">
{
"my_c": [
<xsl:for-each select="a/b/c">
{
"c": {
"foo_id": <xsl:value-of select="@foo">,
"listing_1": <xsl:value-of
select="current()/listing[@n='1']" />,
"listing_2": <xsl:value-of
select="current()/listing[@n='2']" />,
"listing_3": <xsl:value-of
select="current()/listing[@n='3']" />,
"listing_4": <xsl:value-of
select="current()/listing[@n='4']" />
}
},
</xsl:for-each>
],
}
</xsl:template>
</xsl:stylesheet>
And the following broken output is what results:
{
"my_c": [
{
"c": {
"foo_id": "bar1"
],
}
}
{
"c": {
"foo_id": "bar2"
],
}
}
Where did I go wrong in my XSLT?
Match determined char between chars
Match determined char between chars
I have the following code:
<?php
<div>
<p>some text</p>
<code>
<span>some code</span>
</code>
<p>another text</p>
<code>
<span>another code</span>
</code>
</div>
?>
All the code is a string.
I want some REGEX to match all "<", but only those which is surrounded by
<code></code>.
I tried a lot and made a lot of research in internet and failed to find
some REGEX that matches it. I'm not good with REGEX yet. Can someone help
me, plz?
Thx a lot!
I have the following code:
<?php
<div>
<p>some text</p>
<code>
<span>some code</span>
</code>
<p>another text</p>
<code>
<span>another code</span>
</code>
</div>
?>
All the code is a string.
I want some REGEX to match all "<", but only those which is surrounded by
<code></code>.
I tried a lot and made a lot of research in internet and failed to find
some REGEX that matches it. I'm not good with REGEX yet. Can someone help
me, plz?
Thx a lot!
Insert or update sqlite3
Insert or update sqlite3
I'm facing a small problem here. I have a table with multiple columns but
what i want to is write a sqlite query that to be used in my python script
so that i can insert if the key is not found or else update other values
if the key is already found. I researched a little and came through this
answer but my concern in my content it's not working and keeps on adding
the new rows even if it exists.
Using this i wrote a query since my update/insert is dependent on a column
called as id which is a foreign key constraint to this table. Other two
columns that i want to update are say name and role. so what i want to do
is insert all three if the id is not found. if found then see if it has
got same values or not for other two columns and update it. here is my
attempt.
INSERT OR REPLACE INTO tblExample(id, name, role) VALUES (
COALESCE((SELECT id FROM tblExample WHERE id = 1),'1'),'name','role');
But it's still inserting new rows. why? how can i avoid it? any simpler
solution?
I'm facing a small problem here. I have a table with multiple columns but
what i want to is write a sqlite query that to be used in my python script
so that i can insert if the key is not found or else update other values
if the key is already found. I researched a little and came through this
answer but my concern in my content it's not working and keeps on adding
the new rows even if it exists.
Using this i wrote a query since my update/insert is dependent on a column
called as id which is a foreign key constraint to this table. Other two
columns that i want to update are say name and role. so what i want to do
is insert all three if the id is not found. if found then see if it has
got same values or not for other two columns and update it. here is my
attempt.
INSERT OR REPLACE INTO tblExample(id, name, role) VALUES (
COALESCE((SELECT id FROM tblExample WHERE id = 1),'1'),'name','role');
But it's still inserting new rows. why? how can i avoid it? any simpler
solution?
Sunday, 18 August 2013
Series k^2/k! with k=1 to infinity
Series k^2/k! with k=1 to infinity
A practice Math Subject GRE asked me to compute $\sum_{k=1}^\infty
\frac{k^2}{k!}$. The sum is equal to 2e, but I wasn't able to figure this
out using Maclarin series or discrete PDFs. What's the most elementary way
to solve this?
A practice Math Subject GRE asked me to compute $\sum_{k=1}^\infty
\frac{k^2}{k!}$. The sum is equal to 2e, but I wasn't able to figure this
out using Maclarin series or discrete PDFs. What's the most elementary way
to solve this?
Is this normal in CSS?
Is this normal in CSS?
pa href=http://jsfiddle.net/Hud5T/
rel=nofollowhttp://jsfiddle.net/Hud5T//a/p pThe background of the BODY tag
extends to fit the sidebar, but the background of the code#wrap/code
element doesn't. Why?/p
pa href=http://jsfiddle.net/Hud5T/
rel=nofollowhttp://jsfiddle.net/Hud5T//a/p pThe background of the BODY tag
extends to fit the sidebar, but the background of the code#wrap/code
element doesn't. Why?/p
ServiceStack UpdateUserAuth RegistrationService
ServiceStack UpdateUserAuth RegistrationService
I'm implementing my own IAuthRepository, but I can't figure out how
UpdateUserAuth should be. the signature in IUserAuthRepository is:
UserAuth UpdateUserAuth(UserAuth existingUser, UserAuth newUser, string
password);
in ServiceStack code, it's used in RegistrationService in 2 different
manners:
UserAuthRepo.UpdateUserAuth(newUserAuth, existingUser, request.Password)
in UpdateUserAuth method
this.UserAuthRepo.UpdateUserAuth(existingUser, newUserAuth,
request.Password);
in Post method
Is it a mistake or the desired feature?
I'm implementing my own IAuthRepository, but I can't figure out how
UpdateUserAuth should be. the signature in IUserAuthRepository is:
UserAuth UpdateUserAuth(UserAuth existingUser, UserAuth newUser, string
password);
in ServiceStack code, it's used in RegistrationService in 2 different
manners:
UserAuthRepo.UpdateUserAuth(newUserAuth, existingUser, request.Password)
in UpdateUserAuth method
this.UserAuthRepo.UpdateUserAuth(existingUser, newUserAuth,
request.Password);
in Post method
Is it a mistake or the desired feature?
Centering ProgressBar Programmatically in Android
Centering ProgressBar Programmatically in Android
I'm trying to center a ProgressBar programmatically using the following:
ViewGroup layout = (ViewGroup)
findViewById(android.R.id.content).getRootView();
progressBar =
newProgressBar(SignInActivity.this,null,android.R.attr.progressBarStyleLarge);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(progressBar,params);
The size setting seems to work okay, but the ProgressBar doesn't center in
the existing layout (defined by xml with a relative layout). Is there
something obviously wrong here?
Thanks.
I'm trying to center a ProgressBar programmatically using the following:
ViewGroup layout = (ViewGroup)
findViewById(android.R.id.content).getRootView();
progressBar =
newProgressBar(SignInActivity.this,null,android.R.attr.progressBarStyleLarge);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(progressBar,params);
The size setting seems to work okay, but the ProgressBar doesn't center in
the existing layout (defined by xml with a relative layout). Is there
something obviously wrong here?
Thanks.
How to extract the words through pattern matching in perl
How to extract the words through pattern matching in perl
! /usr/bin/perl
use strict;
use warnings;
my $string = "praveen is a good boy";
my @try = split(/([a,e,i,o,u]).*\1/,$string);
print "@try\n";
I was trying to print all words containing 2 adjacent vowels in a string.
o/p : has to be "praveen" and "good" .
! /usr/bin/perl
use strict;
use warnings;
my $string = "praveen is a good boy";
my @try = split(/([a,e,i,o,u]).*\1/,$string);
print "@try\n";
I was trying to print all words containing 2 adjacent vowels in a string.
o/p : has to be "praveen" and "good" .
jquery jDialog deson't work properly when we call it many times
jquery jDialog deson't work properly when we call it many times
I'm using jdialog, everything works fine, but when I show up the same div
many times it freezes, if i refresh the page everything works fine again.
I even tried to generate a dynamic id for the div
here the code:
/* * */ function open_jdialog(url, div_id,dialog_title, dialog_width,
dialog_height,top_position) { try { if (trim(div_id)=="") {
div_id="host_div_id" }
if (typeof(top_position)==='undefined')
{
top_position=100
}
host_div=document.getElementById(div_id)
key=generate_key();
host_div.innerHTML="<div id=" + key + "></div>"
url=url + "&div_to_close=" + key
get_data_via_ajax( url ,key)//get
//
if (dialog_width==0) dialog_height="auto"
if (dialog_height==0) dialog_height="auto"
//
$("#" + key).dialog({
width: dialog_width,
height: dialog_height,//$(window).height(),
modal: true,
title:dialog_title,
position: ["centre",top_position],
zIndex: 0,
});
$('#' + key).bind('dialogclose', function(event)
{
document.getElementById(div_id).innerHTML=""
//document.getElementById(div_id).reset();
});
}//end try
catch(err)
{
}
}
I'm using jdialog, everything works fine, but when I show up the same div
many times it freezes, if i refresh the page everything works fine again.
I even tried to generate a dynamic id for the div
here the code:
/* * */ function open_jdialog(url, div_id,dialog_title, dialog_width,
dialog_height,top_position) { try { if (trim(div_id)=="") {
div_id="host_div_id" }
if (typeof(top_position)==='undefined')
{
top_position=100
}
host_div=document.getElementById(div_id)
key=generate_key();
host_div.innerHTML="<div id=" + key + "></div>"
url=url + "&div_to_close=" + key
get_data_via_ajax( url ,key)//get
//
if (dialog_width==0) dialog_height="auto"
if (dialog_height==0) dialog_height="auto"
//
$("#" + key).dialog({
width: dialog_width,
height: dialog_height,//$(window).height(),
modal: true,
title:dialog_title,
position: ["centre",top_position],
zIndex: 0,
});
$('#' + key).bind('dialogclose', function(event)
{
document.getElementById(div_id).innerHTML=""
//document.getElementById(div_id).reset();
});
}//end try
catch(err)
{
}
}
Raising Custom Class Events In Windows Service C#
Raising Custom Class Events In Windows Service C#
I did write a windows service that can connect to a network device using a
dll. so everything works fine, but The event handler does not work in win
service! here is my code :
My Custom Class Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyNewService
{
public class zkemkeeperHandler
{
public event EventHandler OnFinger;
public event EventHandler<VerifyEventArgs> OnVerify;
private System.Diagnostics.EventLog eventLog1 = new
System.Diagnostics.EventLog();
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
private bool bIsConnected = false;
private int iMachineNumber = 1;
public zkemkeeperHandler()
{
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "DoDyLog";
this.eventLog1.Source = "DoDyLogSource";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
eventLog1.WriteEntry("zkemkeeperHandler constructor");
}
public void startService()
{
eventLog1.WriteEntry("start service for (192.168.0.77:4370)");
bIsConnected = axCZKEM1.Connect_Net("192.168.0.77",
Convert.ToInt32("4370"));
if (bIsConnected == true)
{
eventLog1.WriteEntry("bIsConnected == true !");
iMachineNumber = 1;
if (axCZKEM1.RegEvent(iMachineNumber, 65535))
{
this.axCZKEM1.OnFinger += new
kemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
this.axCZKEM1.OnVerify += new
zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
//This Log Appears in Event Viewer
eventLog1.WriteEntry("Define events (OnFingers and
OnVerify) !");
//But This Line Does Not Raising Event in Service1.cs :(
Finger(EventArgs.Empty);
}
}
else
{
eventLog1.WriteEntry("Unable to connect the device");
}
}
public void stopService()
{
if (bIsConnected) {axCZKEM1.Disconnect(); bIsConnected = false;}
}
//This method doesn't run :(
private void axCZKEM1_OnFinger()
{
Finger(EventArgs.Empty);
}
//This method doesn't run too :(
private void axCZKEM1_OnVerify(int iUserID)
{
VerifyEventArgs args = new VerifyEventArgs();
args.UserID = iUserID;
Verify(args);
}
public class VerifyEventArgs : EventArgs
{
public int UserID { get; set; }
}
protected virtual void Finger(EventArgs e)
{
EventHandler handler = OnFinger;
if (handler != null)
handler(this, e);
}
protected virtual void Verify(VerifyEventArgs e)
{
EventHandler<VerifyEventArgs> handler = OnVerify;
if (handler != null)
handler(this, e);
}
}
}
My Main Service Class Code :
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Linq;
using System.Threading;
namespace MyNewService
{
public class Service1 : System.ServiceProcess.ServiceBase
{
private System.Diagnostics.EventLog eventLog1;
private System.ComponentModel.Container components = null;
zkemkeeperHandler zkh;
public Service1()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("DoDyLogSource"))
{
System.Diagnostics.EventLog.CreateEventSource("DoDyLogSource",
"DoDyLog");
}
eventLog1.Source = "DoDyLogSource";
eventLog1.Log = "DoDyLog";
eventLog1.WriteEntry("Preparing to start service");
try
{
startZKHandler();
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.InnerException.Message);
}
}
private void startZKHandler()
{
eventLog1.WriteEntry("creating zkemkeeper handler class");
zkh = new zkemkeeperHandler();
zkh.OnFinger += OnFinger;
zkh.OnVerify += OnVerify;
zkh.startService();
}
private void stopZKHandler()
{
eventLog1.WriteEntry("Disconnecting from device
(192.168.0.77)...");
zkh.stopService();
}
private void writeLog2DB(string message)
{
try
{
eventLog1.WriteEntry("writing to database");
DB.DBase.LogTable.AddObject(new LogTable
{
ID = ++DB.IDCounter,
deviceLog = message
});
DB.DBase.SaveChanges();
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.Message + " - " +
ex.InnerException.Message);
}
this.EventLog.Log = "Event Stored in DB.";
}
// The main entry point for the process
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
MyNewService.Service1()};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "DoDyLog";
this.eventLog1.Source = "DoDyLogSource";
this.ServiceName = "MyNewService";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
eventLog1.WriteEntry("my service started");
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to
stop your service.
eventLog1.WriteEntry("my service stoped");
stopZKHandler();
}
protected override void OnContinue()
{
eventLog1.WriteEntry("my service is continuing in working");
}
private void OnFinger(object sender, EventArgs e)
{
eventLog1.WriteEntry("Finger Event Raised");
}
private void OnVerify(object sender,
zkemkeeperHandler.VerifyEventArgs e)
{
eventLog1.WriteEntry("Verify Event Raised");
}
}
}
What is my mistake? please help me!
I did write a windows service that can connect to a network device using a
dll. so everything works fine, but The event handler does not work in win
service! here is my code :
My Custom Class Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyNewService
{
public class zkemkeeperHandler
{
public event EventHandler OnFinger;
public event EventHandler<VerifyEventArgs> OnVerify;
private System.Diagnostics.EventLog eventLog1 = new
System.Diagnostics.EventLog();
public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
private bool bIsConnected = false;
private int iMachineNumber = 1;
public zkemkeeperHandler()
{
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "DoDyLog";
this.eventLog1.Source = "DoDyLogSource";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
eventLog1.WriteEntry("zkemkeeperHandler constructor");
}
public void startService()
{
eventLog1.WriteEntry("start service for (192.168.0.77:4370)");
bIsConnected = axCZKEM1.Connect_Net("192.168.0.77",
Convert.ToInt32("4370"));
if (bIsConnected == true)
{
eventLog1.WriteEntry("bIsConnected == true !");
iMachineNumber = 1;
if (axCZKEM1.RegEvent(iMachineNumber, 65535))
{
this.axCZKEM1.OnFinger += new
kemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
this.axCZKEM1.OnVerify += new
zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
//This Log Appears in Event Viewer
eventLog1.WriteEntry("Define events (OnFingers and
OnVerify) !");
//But This Line Does Not Raising Event in Service1.cs :(
Finger(EventArgs.Empty);
}
}
else
{
eventLog1.WriteEntry("Unable to connect the device");
}
}
public void stopService()
{
if (bIsConnected) {axCZKEM1.Disconnect(); bIsConnected = false;}
}
//This method doesn't run :(
private void axCZKEM1_OnFinger()
{
Finger(EventArgs.Empty);
}
//This method doesn't run too :(
private void axCZKEM1_OnVerify(int iUserID)
{
VerifyEventArgs args = new VerifyEventArgs();
args.UserID = iUserID;
Verify(args);
}
public class VerifyEventArgs : EventArgs
{
public int UserID { get; set; }
}
protected virtual void Finger(EventArgs e)
{
EventHandler handler = OnFinger;
if (handler != null)
handler(this, e);
}
protected virtual void Verify(VerifyEventArgs e)
{
EventHandler<VerifyEventArgs> handler = OnVerify;
if (handler != null)
handler(this, e);
}
}
}
My Main Service Class Code :
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Linq;
using System.Threading;
namespace MyNewService
{
public class Service1 : System.ServiceProcess.ServiceBase
{
private System.Diagnostics.EventLog eventLog1;
private System.ComponentModel.Container components = null;
zkemkeeperHandler zkh;
public Service1()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("DoDyLogSource"))
{
System.Diagnostics.EventLog.CreateEventSource("DoDyLogSource",
"DoDyLog");
}
eventLog1.Source = "DoDyLogSource";
eventLog1.Log = "DoDyLog";
eventLog1.WriteEntry("Preparing to start service");
try
{
startZKHandler();
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.InnerException.Message);
}
}
private void startZKHandler()
{
eventLog1.WriteEntry("creating zkemkeeper handler class");
zkh = new zkemkeeperHandler();
zkh.OnFinger += OnFinger;
zkh.OnVerify += OnVerify;
zkh.startService();
}
private void stopZKHandler()
{
eventLog1.WriteEntry("Disconnecting from device
(192.168.0.77)...");
zkh.stopService();
}
private void writeLog2DB(string message)
{
try
{
eventLog1.WriteEntry("writing to database");
DB.DBase.LogTable.AddObject(new LogTable
{
ID = ++DB.IDCounter,
deviceLog = message
});
DB.DBase.SaveChanges();
}
catch (Exception ex)
{
eventLog1.WriteEntry(ex.Message + " - " +
ex.InnerException.Message);
}
this.EventLog.Log = "Event Stored in DB.";
}
// The main entry point for the process
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
MyNewService.Service1()};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "DoDyLog";
this.eventLog1.Source = "DoDyLogSource";
this.ServiceName = "MyNewService";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
eventLog1.WriteEntry("my service started");
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to
stop your service.
eventLog1.WriteEntry("my service stoped");
stopZKHandler();
}
protected override void OnContinue()
{
eventLog1.WriteEntry("my service is continuing in working");
}
private void OnFinger(object sender, EventArgs e)
{
eventLog1.WriteEntry("Finger Event Raised");
}
private void OnVerify(object sender,
zkemkeeperHandler.VerifyEventArgs e)
{
eventLog1.WriteEntry("Verify Event Raised");
}
}
}
What is my mistake? please help me!
Saturday, 17 August 2013
mount error, special device does not exists
mount error, special device does not exists
I have a hard disk of 320 GB on ubuntu 12.04 64-bit.
2 drives of my hard (sda7 and sda8 of ext3 type) cannot be mounted.
output of sudo mount /dev/sda7 /home -t ext3 :
mount: special device /dev/sda7 does not exists!
/dev/ contains the following:
sda sda1 sda5 sda6
but GParted shows sda7 and sda8:
output of blkid:
/dev/sda1: UUID="a898f3ad-11d9-4dbb-9ea8-71a819dc8f70" TYPE="ext4"
/dev/sda5: UUID="998c7c6f-5ff8-426c-83d4-1a309b7cdc4f" TYPE="swap"
/dev/sda6: UUID="da0460d0-714e-40ae-b88b-a0deca87087c" TYPE="ext4"
/dev/sdb1: LABEL="FLASH DRIVE" UUID="8A24-B5CD" TYPE="vfat"
output of fdisk -l:
Disk /dev/sda: 320.1 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625140335 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x17ea17ea
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 194559 96256 83 Linux
/dev/sda2 196607 625121279 312462336+ f W95 Ext'd (LBA)
/dev/sda5 196608 8007679 3905536 82 Linux swap / Solaris
/dev/sda6 8009728 61431807 26711040 83 Linux
/dev/sda7 61432623 337911209 138239293+ 83 Linux
/dev/sda8 337911273 625121279 143605003+ 83 Linux
I have a hard disk of 320 GB on ubuntu 12.04 64-bit.
2 drives of my hard (sda7 and sda8 of ext3 type) cannot be mounted.
output of sudo mount /dev/sda7 /home -t ext3 :
mount: special device /dev/sda7 does not exists!
/dev/ contains the following:
sda sda1 sda5 sda6
but GParted shows sda7 and sda8:
output of blkid:
/dev/sda1: UUID="a898f3ad-11d9-4dbb-9ea8-71a819dc8f70" TYPE="ext4"
/dev/sda5: UUID="998c7c6f-5ff8-426c-83d4-1a309b7cdc4f" TYPE="swap"
/dev/sda6: UUID="da0460d0-714e-40ae-b88b-a0deca87087c" TYPE="ext4"
/dev/sdb1: LABEL="FLASH DRIVE" UUID="8A24-B5CD" TYPE="vfat"
output of fdisk -l:
Disk /dev/sda: 320.1 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625140335 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x17ea17ea
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 194559 96256 83 Linux
/dev/sda2 196607 625121279 312462336+ f W95 Ext'd (LBA)
/dev/sda5 196608 8007679 3905536 82 Linux swap / Solaris
/dev/sda6 8009728 61431807 26711040 83 Linux
/dev/sda7 61432623 337911209 138239293+ 83 Linux
/dev/sda8 337911273 625121279 143605003+ 83 Linux
Change color of vertex outline in tkz-graph
Change color of vertex outline in tkz-graph
Suppose I have the following graph:
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\thispagestyle{empty}
\begin{document}
\SetVertexNormal[Shape = circle,
LineWidth = 1pt]
\SetUpEdge[lw = 1pt,
color = black,
labelcolor = white,
labelstyle = {sloped,text=black}]
\begin{center}
\begin{tikzpicture}
\Vertex[x=0 ,y=0]{A}
\Vertex[x=3 ,y=3]{B}
\tikzset{EdgeStyle/.style={->}}
\Edge[label = $1$](A)(B)
\end{tikzpicture}
\end{center}
\end{document}
I know how to change the vertex fill color and the vertex text color, but
I'd like to be able to change the color of the actual outline of the
vertex--i.e., the vertices in this code should have a red outline. Any
ideas?
Suppose I have the following graph:
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\thispagestyle{empty}
\begin{document}
\SetVertexNormal[Shape = circle,
LineWidth = 1pt]
\SetUpEdge[lw = 1pt,
color = black,
labelcolor = white,
labelstyle = {sloped,text=black}]
\begin{center}
\begin{tikzpicture}
\Vertex[x=0 ,y=0]{A}
\Vertex[x=3 ,y=3]{B}
\tikzset{EdgeStyle/.style={->}}
\Edge[label = $1$](A)(B)
\end{tikzpicture}
\end{center}
\end{document}
I know how to change the vertex fill color and the vertex text color, but
I'd like to be able to change the color of the actual outline of the
vertex--i.e., the vertices in this code should have a red outline. Any
ideas?
Command to uncomment multiple lines without selecting them
Command to uncomment multiple lines without selecting them
Is there a command in emacs to uncomment an entire comment block without
having to mark it first?
For instance, let's say the point is inside a comment in the following code:
(setq doing-this t)
;; (progn |<--This is the point
;; (er/expand-region 1)
;; (uncomment-region (region-beginning) (region-end)))
I would like a command that turns that into this:
(setq doing-this t)
(progn
(er/expand-region 1)
(uncomment-region (region-beginning) (region-end)))
It's fairly easy to write a command that (un)comments a single line, but
I've yet to find one that uncomments as many lines as possible. Is there
one available?
Is there a command in emacs to uncomment an entire comment block without
having to mark it first?
For instance, let's say the point is inside a comment in the following code:
(setq doing-this t)
;; (progn |<--This is the point
;; (er/expand-region 1)
;; (uncomment-region (region-beginning) (region-end)))
I would like a command that turns that into this:
(setq doing-this t)
(progn
(er/expand-region 1)
(uncomment-region (region-beginning) (region-end)))
It's fairly easy to write a command that (un)comments a single line, but
I've yet to find one that uncomments as many lines as possible. Is there
one available?
save image to mysql with php
save image to mysql with php
i created this form to add my images to mysql database,and i think i did
it right-cause it saves something :D - but it wont show me the image, what
should i do to "SEE" the image from mysql?!
this is my form php:
$tmp_name=$_FILES['file']['tmp_name'];
if (isset($_POST['submit'])) {
if ((($_FILES['file']['type']) == "image/jpeg")
|| ($_FILES['file']['type']) == "image/gif"
|| ($_FILES['file']['type']) == "image/pjpeg"
&& ($_FILES['file']['size']) > 200000) {
$tmp_name=$_FILES['file']['tmp_name'];
// i also tried addslasheds
$image =
mysql_real_escape_string(file_get_contents($_FILES['file']['tmp_name']));
if ($_FILES['file']['error'] > 0) {
echo "return code : " . $_FILES['FILES']['error'];
}else{
if (file_exists($_FILES['file']['name'])) {
echo "your file is already exists!";
}else{
Query("INSERT INTO image(image) VALUES ('".$tmp_name."')");
echo "FILES has been stored";
}
}
}
}else{
echo "invalid file";
}?>
and my code to show the image is:
<?php
require 'lib.php';
$request=Query('SELECT * FROM image');
while ($row = mysql_fetch_array($request)) {
echo $row['image'];
}?>
i created this form to add my images to mysql database,and i think i did
it right-cause it saves something :D - but it wont show me the image, what
should i do to "SEE" the image from mysql?!
this is my form php:
$tmp_name=$_FILES['file']['tmp_name'];
if (isset($_POST['submit'])) {
if ((($_FILES['file']['type']) == "image/jpeg")
|| ($_FILES['file']['type']) == "image/gif"
|| ($_FILES['file']['type']) == "image/pjpeg"
&& ($_FILES['file']['size']) > 200000) {
$tmp_name=$_FILES['file']['tmp_name'];
// i also tried addslasheds
$image =
mysql_real_escape_string(file_get_contents($_FILES['file']['tmp_name']));
if ($_FILES['file']['error'] > 0) {
echo "return code : " . $_FILES['FILES']['error'];
}else{
if (file_exists($_FILES['file']['name'])) {
echo "your file is already exists!";
}else{
Query("INSERT INTO image(image) VALUES ('".$tmp_name."')");
echo "FILES has been stored";
}
}
}
}else{
echo "invalid file";
}?>
and my code to show the image is:
<?php
require 'lib.php';
$request=Query('SELECT * FROM image');
while ($row = mysql_fetch_array($request)) {
echo $row['image'];
}?>
what's the output of following code and why?
what's the output of following code and why?
The following code is an interview qusetion and I can't understand the
output. Can anyone help? Thanks.
#include <stdio.h>
char* string_1()
{
char* p = "ABCD";
return p;
}
char* string_2()
{
char p[] = "ABCD";
return p;
}
int main(void)
{
printf("%s\n",string_1());
printf("%s\n",string_2());
}
The following code is an interview qusetion and I can't understand the
output. Can anyone help? Thanks.
#include <stdio.h>
char* string_1()
{
char* p = "ABCD";
return p;
}
char* string_2()
{
char p[] = "ABCD";
return p;
}
int main(void)
{
printf("%s\n",string_1());
printf("%s\n",string_2());
}
working with Unity3d existing project
working with Unity3d existing project
I'm using that demo project:
http://u3d.as/content/unity-technologies/third-person-mmo-controller/1Wt
I'm trying to understand the read me file but I'm very new to this kind of
work with unity.
can anyone explain how should I make the initial setup to make the
character move?
this is what I don't know how to do: "As specified in the
ThirdPersonController inspector, a custom axis and a custom button needs
to be defined before use. This applies to the demo as well."
I'm using that demo project:
http://u3d.as/content/unity-technologies/third-person-mmo-controller/1Wt
I'm trying to understand the read me file but I'm very new to this kind of
work with unity.
can anyone explain how should I make the initial setup to make the
character move?
this is what I don't know how to do: "As specified in the
ThirdPersonController inspector, a custom axis and a custom button needs
to be defined before use. This applies to the demo as well."
SIP Client - Peers Register failed
SIP Client - Peers Register failed
I have to integrate the text, voice and video chat via SIP server into my
application. So that I have chosen the "Peers" from
http://peers.sourceforge.net/.
I have downloaded the code, registered a sip addressz(peers sip client)
and call to another sip account(peers sip client). I can't receive a call
in that peers client. If I call to another sip client(X-Lite), I can able
to receive a call.
Can anybody tell me what may be the problem and how to fix?
I have to integrate the text, voice and video chat via SIP server into my
application. So that I have chosen the "Peers" from
http://peers.sourceforge.net/.
I have downloaded the code, registered a sip addressz(peers sip client)
and call to another sip account(peers sip client). I can't receive a call
in that peers client. If I call to another sip client(X-Lite), I can able
to receive a call.
Can anybody tell me what may be the problem and how to fix?
Thursday, 8 August 2013
Twitter Bootstrap Tabbable Navbar
Twitter Bootstrap Tabbable Navbar
I'm using twitter bootstrap to create a navbar at the top of my page. I
want the nav elements to work like tabs instead of links. I see that
others have been able to achieve this, but I am still not able.
I'm following this section of the documents to create a navbar, and the
"Tabbable Nav" section from here to add the tab functionality.
Here's a jsfiddle if you prefer that, but also, here it is pasted here:
<head>
<meta charset="utf-8">
<title>Course Manager</title>
<link rel="stylesheet"
href="http://netdna.bootstrapcdn.com/bootswatch/2.3.2/cerulean/bootstrap.min.css"/>
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="#">Training Courses</a>
<ul class="nav nav-tabs">
<li><a href="#courses" data-toggle="tab">Manage Courses</a></li>
<li><a href="#tools" data-toggle="tab">Manage Tools</a></li>
</ul>
</div>
</div>
<div class="tab-content">
<div class="tab-pane fade" id="courses">
<p>Courses</p>
</div>
<div class="tab-pane fade" id="tools">
<p>Tools</p>
</div>
</div>
</div>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script
src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</body>
I'm using twitter bootstrap to create a navbar at the top of my page. I
want the nav elements to work like tabs instead of links. I see that
others have been able to achieve this, but I am still not able.
I'm following this section of the documents to create a navbar, and the
"Tabbable Nav" section from here to add the tab functionality.
Here's a jsfiddle if you prefer that, but also, here it is pasted here:
<head>
<meta charset="utf-8">
<title>Course Manager</title>
<link rel="stylesheet"
href="http://netdna.bootstrapcdn.com/bootswatch/2.3.2/cerulean/bootstrap.min.css"/>
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="#">Training Courses</a>
<ul class="nav nav-tabs">
<li><a href="#courses" data-toggle="tab">Manage Courses</a></li>
<li><a href="#tools" data-toggle="tab">Manage Tools</a></li>
</ul>
</div>
</div>
<div class="tab-content">
<div class="tab-pane fade" id="courses">
<p>Courses</p>
</div>
<div class="tab-pane fade" id="tools">
<p>Tools</p>
</div>
</div>
</div>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script
src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</body>
Subscribe to:
Comments (Atom)