question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
6,277,637
6,277,748
Instance variable vs method calling in Controller
I have the following code in my controller. def index @customer = Customer.find(params[:customer_id]) @current_orders = @customer.current_orders @pending_orders = @customer.pending_orders @previous_orders = @customer.previous_orders @recurring_orders = @customer.recurring_orders end As you see, all the instance variab...
If you reference the customer methods directly in the view you are tying the view directly to your model i.e. if for some reason you needed to change the name of the previous_orders method on customer you'd have to go through all your views and change it there, whereas with the instance variables you've used you'd only...
Instance variable vs method calling in Controller I have the following code in my controller. def index @customer = Customer.find(params[:customer_id]) @current_orders = @customer.current_orders @pending_orders = @customer.pending_orders @previous_orders = @customer.previous_orders @recurring_orders = @customer.recurr...
TITLE: Instance variable vs method calling in Controller QUESTION: I have the following code in my controller. def index @customer = Customer.find(params[:customer_id]) @current_orders = @customer.current_orders @pending_orders = @customer.pending_orders @previous_orders = @customer.previous_orders @recurring_orders ...
[ "ruby-on-rails" ]
0
2
55
1
0
2011-06-08T10:56:37.480000
2011-06-08T11:04:45.840000
6,277,638
6,277,702
How to format the DateTimePicker into hh:mm:ss and What is the appropriate type to save time in mysql?
I want to save the time in the format hh:mm:ss from the DateTimePicker to MySQL database, How to format the DateTimePicker into hh:mm:ss only without date and What is the appropriate type to save time in mysql? Regards & Thanks, Putri Diana
You can format it to show time by dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "hh:mm:ss"; dateTimePicker1.ShowUpDown = true; Get the value into a Timespan object in this way for processing in your code TimeSpan ts1 = TimeSpan.Parse(dateTimePicker1.Text); I think MySql has got a ...
How to format the DateTimePicker into hh:mm:ss and What is the appropriate type to save time in mysql? I want to save the time in the format hh:mm:ss from the DateTimePicker to MySQL database, How to format the DateTimePicker into hh:mm:ss only without date and What is the appropriate type to save time in mysql? Regard...
TITLE: How to format the DateTimePicker into hh:mm:ss and What is the appropriate type to save time in mysql? QUESTION: I want to save the time in the format hh:mm:ss from the DateTimePicker to MySQL database, How to format the DateTimePicker into hh:mm:ss only without date and What is the appropriate type to save tim...
[ "c#", "mysql", "vb.net", "datetimepicker" ]
2
2
4,449
1
0
2011-06-08T10:56:39.973000
2011-06-08T11:02:09.363000
6,277,646
6,277,674
In C++ check if std::vector<string> contains a certain value
Is there any built in function which tells me that my vector contains a certain element or not e.g. std::vector v; v.push_back("abc"); v.push_back("xyz"); if (v.contains("abc")) // I am looking for one such feature, is there any // such function or i need to loop through whole vector?
You can use std::find as follows: if (std::find(v.begin(), v.end(), "abc")!= v.end()) { // Element in vector. } To be able to use std::find: include.
In C++ check if std::vector<string> contains a certain value Is there any built in function which tells me that my vector contains a certain element or not e.g. std::vector v; v.push_back("abc"); v.push_back("xyz"); if (v.contains("abc")) // I am looking for one such feature, is there any // such function or i need to...
TITLE: In C++ check if std::vector<string> contains a certain value QUESTION: Is there any built in function which tells me that my vector contains a certain element or not e.g. std::vector v; v.push_back("abc"); v.push_back("xyz"); if (v.contains("abc")) // I am looking for one such feature, is there any // such fun...
[ "c++", "vector", "std", "stdvector" ]
108
235
297,511
5
0
2011-06-08T10:57:24.067000
2011-06-08T10:59:50.757000
6,277,649
6,277,838
Implicit type unknown when passing pointer to function
I'm looking at some code at the moment which has been ported and is failing to compile. The code has been written in a rather 'C' like way and is passing function pointers in order to set particular mutators on an object. The object being populated is declared as follows: class Person { std::string n_; int a_; public:...
First change the declaration: typedef void (Person::*FnSetStr)(const std::string& s); typedef void (Person::*FnSetInt)(const int& i); Then change the call: setMem("Name", person, &Person::name ); // (1) setMem("Age", person, &Person::age ); // (2) Builds clean at warning level 4 in VS 2010.
Implicit type unknown when passing pointer to function I'm looking at some code at the moment which has been ported and is failing to compile. The code has been written in a rather 'C' like way and is passing function pointers in order to set particular mutators on an object. The object being populated is declared as f...
TITLE: Implicit type unknown when passing pointer to function QUESTION: I'm looking at some code at the moment which has been ported and is failing to compile. The code has been written in a rather 'C' like way and is passing function pointers in order to set particular mutators on an object. The object being populate...
[ "c++", "function", "pointers" ]
3
5
631
1
0
2011-06-08T10:57:57.233000
2011-06-08T11:12:19.307000
6,277,653
6,277,931
How to set a column in gridview as hyperlink which is autogenerated
I want to make the gridview.columns[0] as hyperlink. I tried so many work around mentioned in different sites. I am binding a list<> to the grid. and I need to make the first column as hyperlink and upon clicking that link, it should be redirected to a page with the corresponding item. Which event I need to use and how...
void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var firstCell = e.Row.Cells[0]; firstCell.Controls.Clear(); firstCell.Controls.Add(new HyperLink { NavigateUrl = firstCell.Text, Text = firstCell.Text }); } } Be warned that if you bind data to grid o...
How to set a column in gridview as hyperlink which is autogenerated I want to make the gridview.columns[0] as hyperlink. I tried so many work around mentioned in different sites. I am binding a list<> to the grid. and I need to make the first column as hyperlink and upon clicking that link, it should be redirected to a...
TITLE: How to set a column in gridview as hyperlink which is autogenerated QUESTION: I want to make the gridview.columns[0] as hyperlink. I tried so many work around mentioned in different sites. I am binding a list<> to the grid. and I need to make the first column as hyperlink and upon clicking that link, it should ...
[ "c#", ".net", "asp.net", "gridview" ]
3
8
15,872
2
0
2011-06-08T10:58:09.463000
2011-06-08T11:19:54.377000
6,277,661
6,277,840
Installing service using SC/ service control
I had a windows service installed on my computer. I deleted it with sc delete myservice Then I recreated it with sc create collector binpath = "path of service" but service is not listed under services in control panel. I tried to recreate the service and got: [SC] CreateService FAILED 1073: The specified service alrea...
Try using installutil instead, this fixed similar problem for me.
Installing service using SC/ service control I had a windows service installed on my computer. I deleted it with sc delete myservice Then I recreated it with sc create collector binpath = "path of service" but service is not listed under services in control panel. I tried to recreate the service and got: [SC] CreateSer...
TITLE: Installing service using SC/ service control QUESTION: I had a windows service installed on my computer. I deleted it with sc delete myservice Then I recreated it with sc create collector binpath = "path of service" but service is not listed under services in control panel. I tried to recreate the service and g...
[ "c#", "asp.net", "visual-studio-2010", "windows-services" ]
4
3
6,343
2
0
2011-06-08T10:58:53.657000
2011-06-08T11:12:36.197000
6,277,662
6,277,742
How to pass the selectedListItem's object to another activity?
I have designed an activity in which there is a listView. I want that on click of the list item a new Activity should start and it should contain detail data related to the ListItem clicked.Please help me out in doing this.Thanks in advance.
While starting an activity use putExtra to send data to another activity Intent i = new Intent(this, SecondActivity.class); i.putExtra("listitemselected", listitemvalue); startActivity(i); In SecondActivity.java use getStringExtra to get the values. Intent i = getIntent(); String listItem = i.getStringExtra("listitemse...
How to pass the selectedListItem's object to another activity? I have designed an activity in which there is a listView. I want that on click of the list item a new Activity should start and it should contain detail data related to the ListItem clicked.Please help me out in doing this.Thanks in advance.
TITLE: How to pass the selectedListItem's object to another activity? QUESTION: I have designed an activity in which there is a listView. I want that on click of the list item a new Activity should start and it should contain detail data related to the ListItem clicked.Please help me out in doing this.Thanks in advanc...
[ "android" ]
0
3
3,752
4
0
2011-06-08T10:58:56.427000
2011-06-08T11:04:25.987000
6,277,669
6,277,734
Detect changes in Label
I've got a Form with some labels on it. From time to time the program changes the text on the labels with label1.Text = "some message" I want to create a function that is executed every time the label text is assigned and implemented an event handler like this: this.label1.TextChanged += new System.EventHandler(this.la...
The Control's Text property is virtual so you can create your own label control and add custom functionality there, such as raising an event when the property's setter is called even if it doesn't result in changed text.
Detect changes in Label I've got a Form with some labels on it. From time to time the program changes the text on the labels with label1.Text = "some message" I want to create a function that is executed every time the label text is assigned and implemented an event handler like this: this.label1.TextChanged += new Sys...
TITLE: Detect changes in Label QUESTION: I've got a Form with some labels on it. From time to time the program changes the text on the labels with label1.Text = "some message" I want to create a function that is executed every time the label text is assigned and implemented an event handler like this: this.label1.Text...
[ "c#", ".net", "winforms" ]
1
4
1,793
2
0
2011-06-08T10:59:30.987000
2011-06-08T11:04:08.413000
6,277,678
6,277,726
stream output and implicit void* cast operator function invocation
a code like cin>> grade; where grade is a standard data type returns a reference to cin(istream object) which enables cascaded inputs.... but i read that if cin >>grade; is used as a condition say in a while statement...the stream's void* cast operator function is called implicitly...and it converts reference to istrea...
1.what is the void * cast operator function and how does it work here It looks something like this: operator void* () const { return fail()? 0: this; } The question is: why isn’t an operator bool used here? The answer is: because that allows invalid conversions which may hide bugs. The above is an example of the safe b...
stream output and implicit void* cast operator function invocation a code like cin>> grade; where grade is a standard data type returns a reference to cin(istream object) which enables cascaded inputs.... but i read that if cin >>grade; is used as a condition say in a while statement...the stream's void* cast operator ...
TITLE: stream output and implicit void* cast operator function invocation QUESTION: a code like cin>> grade; where grade is a standard data type returns a reference to cin(istream object) which enables cascaded inputs.... but i read that if cin >>grade; is used as a condition say in a while statement...the stream's vo...
[ "c++" ]
6
10
1,807
1
0
2011-06-08T11:00:15.543000
2011-06-08T11:03:32.737000
6,277,684
6,277,985
Selecting the first xml node using xslt
I've the following xml, KK-888 KK-888-1 1 ARC Deposit 0.0000 KK-888 KK-888-2 2 Assessments and Dues This is the primary account for all associations dues and assessments. 170 KK-888 KK-888-4 4 Fines/Compliance 0.0000 I need this result xml from above through xslt, I'll pass the SubAccountNumber to the xslt and I need t...
A starting point... Note that this will produce In the case $SAN is not present in the input document. Otherwise how you'd like to return in case of not matching at all?
Selecting the first xml node using xslt I've the following xml, KK-888 KK-888-1 1 ARC Deposit 0.0000 KK-888 KK-888-2 2 Assessments and Dues This is the primary account for all associations dues and assessments. 170 KK-888 KK-888-4 4 Fines/Compliance 0.0000 I need this result xml from above through xslt, I'll pass the S...
TITLE: Selecting the first xml node using xslt QUESTION: I've the following xml, KK-888 KK-888-1 1 ARC Deposit 0.0000 KK-888 KK-888-2 2 Assessments and Dues This is the primary account for all associations dues and assessments. 170 KK-888 KK-888-4 4 Fines/Compliance 0.0000 I need this result xml from above through xsl...
[ "xml", "xslt" ]
0
1
136
1
0
2011-06-08T11:00:44.497000
2011-06-08T11:24:54.923000
6,277,687
6,282,211
Setting text background color in Raphael
I am using Raphael-js to position text on a canvas. Is it possible to have a background color for the text? I would like different text elements to have different backgrounds colors. Thanks,
The background of text is known as "fill" and can be applied using the attr function as follows: paper.text(50, 50, "Example").attr("fill", "#000000"); For a full listing of the properties, see the Raphael Documentation
Setting text background color in Raphael I am using Raphael-js to position text on a canvas. Is it possible to have a background color for the text? I would like different text elements to have different backgrounds colors. Thanks,
TITLE: Setting text background color in Raphael QUESTION: I am using Raphael-js to position text on a canvas. Is it possible to have a background color for the text? I would like different text elements to have different backgrounds colors. Thanks, ANSWER: The background of text is known as "fill" and can be applied ...
[ "javascript", "raphael" ]
4
2
5,678
2
0
2011-06-08T11:00:53.750000
2011-06-08T16:38:19.193000
6,277,692
6,290,866
How can I set the dns servers to use from a Java program?
I am using Ubuntu 64 bit and Java ignores the system DNS settings. How can I set these manually from within my Java program? Here is the code (sorry the JVM language is Clojure): (clojure.contrib.http.agent/string (clojure.contrib.http.agent/http-agent (str "http://yahoo.com"))):which results in: java.net.UnknownHostEx...
In the end I found the answer to my problem at: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477211 lib32nss-mdsn needs to be installed on Ubuntu to make this work
How can I set the dns servers to use from a Java program? I am using Ubuntu 64 bit and Java ignores the system DNS settings. How can I set these manually from within my Java program? Here is the code (sorry the JVM language is Clojure): (clojure.contrib.http.agent/string (clojure.contrib.http.agent/http-agent (str "htt...
TITLE: How can I set the dns servers to use from a Java program? QUESTION: I am using Ubuntu 64 bit and Java ignores the system DNS settings. How can I set these manually from within my Java program? Here is the code (sorry the JVM language is Clojure): (clojure.contrib.http.agent/string (clojure.contrib.http.agent/ht...
[ "java", "clojure", "dns" ]
1
2
719
1
0
2011-06-08T11:01:19.787000
2011-06-09T09:41:18.497000
6,277,695
6,277,743
Would it make sense to arrange the boolean flags in certain order for better performance
boolean a = m1(); boolean b = m2(); boolean c = m3(); Currently my code looks like this and mostly the condition for "c" is bound to be true if (a || b || c) Would it make sense to re-write the code as if (c || a || b), so that the if condition can be quickly evaluated.
Yes that would make sense, but evaluating just booleans is negligible. You'd probably be better inlining the method calls, though so you only execute the code which is neccessary: if (m3() || m1() || m2())
Would it make sense to arrange the boolean flags in certain order for better performance boolean a = m1(); boolean b = m2(); boolean c = m3(); Currently my code looks like this and mostly the condition for "c" is bound to be true if (a || b || c) Would it make sense to re-write the code as if (c || a || b), so that the...
TITLE: Would it make sense to arrange the boolean flags in certain order for better performance QUESTION: boolean a = m1(); boolean b = m2(); boolean c = m3(); Currently my code looks like this and mostly the condition for "c" is bound to be true if (a || b || c) Would it make sense to re-write the code as if (c || a ...
[ "java" ]
0
7
109
11
0
2011-06-08T11:01:26.227000
2011-06-08T11:04:27.023000
6,277,701
6,282,481
iTextSharp produce PDF from existing PDF template
I am looking at the feasibility of creating something using C# and iTextSharp that can take a PDF template and replace various place holder values with actual values retrieved from a database. Essentially a PDF mail merge. I have the iText in action book but it covers rather a lot of stuff i don't need and I am struggl...
Build your template sans fields in your page-layout/text-editor of choice. Save to PDF. Open that PDF and add fields to it. This is easy to do in Acrobat Pro (you could download a trial if need be). It's also possible in iText, just much harder. In either case, you want to set your form fields to have no border, and no...
iTextSharp produce PDF from existing PDF template I am looking at the feasibility of creating something using C# and iTextSharp that can take a PDF template and replace various place holder values with actual values retrieved from a database. Essentially a PDF mail merge. I have the iText in action book but it covers r...
TITLE: iTextSharp produce PDF from existing PDF template QUESTION: I am looking at the feasibility of creating something using C# and iTextSharp that can take a PDF template and replace various place holder values with actual values retrieved from a database. Essentially a PDF mail merge. I have the iText in action bo...
[ "c#", "pdf", "itext" ]
7
9
11,970
1
0
2011-06-08T11:02:08.930000
2011-06-08T17:02:31.973000
6,277,710
6,287,083
Djangothumbnails app issue
I an using this plugin to generate thumbnails. But somhow I couldn't make it work. The models work well, as images can be uploaded from the admin interface, even thumbnails get generated. I uploaded an image named "myphoto.jpg". The view I have is this. def mainpage(request,slug): page = get_object_or_404(MainPage, slu...
Somehow I got it working. Instead of creating a separate class, I used this line photo = ImageWithThumbsField(blank=True, upload_to='images/', sizes=((125,125),(200,200))) in my blog class. And I used the line {{% post.photo.url_125x124 %} in my index.html template.
Djangothumbnails app issue I an using this plugin to generate thumbnails. But somhow I couldn't make it work. The models work well, as images can be uploaded from the admin interface, even thumbnails get generated. I uploaded an image named "myphoto.jpg". The view I have is this. def mainpage(request,slug): page = get_...
TITLE: Djangothumbnails app issue QUESTION: I an using this plugin to generate thumbnails. But somhow I couldn't make it work. The models work well, as images can be uploaded from the admin interface, even thumbnails get generated. I uploaded an image named "myphoto.jpg". The view I have is this. def mainpage(request,...
[ "django", "django-models" ]
0
0
194
2
0
2011-06-08T11:02:26.343000
2011-06-09T01:15:06.733000
6,277,716
6,277,764
Bind combobox inside an itemscontrol
I am trying to populate a combobox, which is part of an itemscontrol, with a list of items (ParentCredentials). The problem is that these ParentCredentials are at the same level of the items being binded with the itemscontrol. Not sure if this is clear but if you have a look at the view model it should make more sense ...
You need to navigate back up to the ItemsControl, and bind via the DataContext path. {Binding RelativeSource={RelativeSource AncestorType=ItemsControl}, Path=DataContext.AccessControl.ParentCredentials} Source={RelativeSource... never works in any case. Further the AncestorType is always some FrameworkElement rather th...
Bind combobox inside an itemscontrol I am trying to populate a combobox, which is part of an itemscontrol, with a list of items (ParentCredentials). The problem is that these ParentCredentials are at the same level of the items being binded with the itemscontrol. Not sure if this is clear but if you have a look at the ...
TITLE: Bind combobox inside an itemscontrol QUESTION: I am trying to populate a combobox, which is part of an itemscontrol, with a list of items (ParentCredentials). The problem is that these ParentCredentials are at the same level of the items being binded with the itemscontrol. Not sure if this is clear but if you h...
[ "c#", "wpf", "xaml", "data-binding", "combobox" ]
1
2
1,795
1
0
2011-06-08T11:02:51.457000
2011-06-08T11:05:57.527000
6,277,717
6,290,747
document.createEvent("KeyboardEvent") - get keycode for manually created event
I am using the custom input event found @ http://whattheheadsaid.com/projects/input-special-event.. The trouble is that I am not able to get the keycode for the event. Any ideas?
Found the cure.. in the end, I updated the following lines;- else if (onprop) $(this).bind("onpropertychange", handler); to;- else if (onprop) $(this).bind("keypress", function(e){ handler.call(this, e) });
document.createEvent("KeyboardEvent") - get keycode for manually created event I am using the custom input event found @ http://whattheheadsaid.com/projects/input-special-event.. The trouble is that I am not able to get the keycode for the event. Any ideas?
TITLE: document.createEvent("KeyboardEvent") - get keycode for manually created event QUESTION: I am using the custom input event found @ http://whattheheadsaid.com/projects/input-special-event.. The trouble is that I am not able to get the keycode for the event. Any ideas? ANSWER: Found the cure.. in the end, I upda...
[ "javascript", "dom-events" ]
1
0
564
1
0
2011-06-08T11:02:53.920000
2011-06-09T09:30:48.403000
6,277,740
6,277,851
Pass by Value in Java
import java.util.Arrays; public class Test { public static void main(String... args) { String[] strings = new String[] { "foo", "bar" }; changeReference(strings); System.out.println(Arrays.toString(strings)); // still [foo, bar] changeValue(strings); System.out.println(Arrays.toString(strings)); // [foo, foo] } public ...
strings is an array of String s. Arrays are objects for our purposes here, which means they are a reference type. changeReference does nothing useful. It receives a reference to strings, but it receives that reference by value. Reassigning strings within the function has no effect on the strings being passed in -- it j...
Pass by Value in Java import java.util.Arrays; public class Test { public static void main(String... args) { String[] strings = new String[] { "foo", "bar" }; changeReference(strings); System.out.println(Arrays.toString(strings)); // still [foo, bar] changeValue(strings); System.out.println(Arrays.toString(strings)); /...
TITLE: Pass by Value in Java QUESTION: import java.util.Arrays; public class Test { public static void main(String... args) { String[] strings = new String[] { "foo", "bar" }; changeReference(strings); System.out.println(Arrays.toString(strings)); // still [foo, bar] changeValue(strings); System.out.println(Arrays.toS...
[ "java", "string", "pass-by-reference", "parameter-passing" ]
0
4
2,546
4
0
2011-06-08T11:04:21.977000
2011-06-08T11:13:09.677000
6,277,741
6,277,787
Reading files above the webroot
In php, I'm trying to read a file that is placed above the web root (e.g. /home/[username]/games/ ). I am trying to read a.swf and an.xml file. I have it working well on my local LAMP server, using this code: @readfile("/home/[username]/games/hangman/example.xml"); But, testing it on an external server, it doesn't work...
This has something to do with the open_basedir value of php.ini, see http://php.net/manual/en/ini.core.php for more information.
Reading files above the webroot In php, I'm trying to read a file that is placed above the web root (e.g. /home/[username]/games/ ). I am trying to read a.swf and an.xml file. I have it working well on my local LAMP server, using this code: @readfile("/home/[username]/games/hangman/example.xml"); But, testing it on an ...
TITLE: Reading files above the webroot QUESTION: In php, I'm trying to read a file that is placed above the web root (e.g. /home/[username]/games/ ). I am trying to read a.swf and an.xml file. I have it working well on my local LAMP server, using this code: @readfile("/home/[username]/games/hangman/example.xml"); But,...
[ "php", "cakephp" ]
4
3
1,975
1
0
2011-06-08T11:04:22.527000
2011-06-08T11:08:15.647000
6,277,745
6,277,894
iPhone : Problem while capturing screen
I want to capture my screen view. My app is in Landscape. But while I try to capture the screen it capture view in portrait mode. I want to make sure that screen capture is in landscape. What should I do?
Use following one UIGraphicsBeginImageContext(CGSizeMake(480,320)); UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
iPhone : Problem while capturing screen I want to capture my screen view. My app is in Landscape. But while I try to capture the screen it capture view in portrait mode. I want to make sure that screen capture is in landscape. What should I do?
TITLE: iPhone : Problem while capturing screen QUESTION: I want to capture my screen view. My app is in Landscape. But while I try to capture the screen it capture view in portrait mode. I want to make sure that screen capture is in landscape. What should I do? ANSWER: Use following one UIGraphicsBeginImageContext(CG...
[ "iphone", "objective-c", "cocoa-touch", "ios4" ]
1
0
179
2
0
2011-06-08T11:04:32.220000
2011-06-08T11:16:15.113000
6,277,758
6,278,214
Gwt and jsp in same project
i was looking for similar title here but i didn't find much info, so if anyone can provide some example or url or any approach how to do it. For example: is it possible to call a jsp from a gwt widget? or communication (server - jsp) in gwt project and so on.. Is there any limitation is using jsp in gwt project? Thanks...
GWT compiles down to html+javascript (static files), while JSPs are internally compiled and behave like servlets. You can configure URLs to point to both (via your server config and/or web.xml). Both GWT and JSP allow you to go to a new URL. In GWT you can use Window.Location.assign(url) (this will load new URL and clo...
Gwt and jsp in same project i was looking for similar title here but i didn't find much info, so if anyone can provide some example or url or any approach how to do it. For example: is it possible to call a jsp from a gwt widget? or communication (server - jsp) in gwt project and so on.. Is there any limitation is usin...
TITLE: Gwt and jsp in same project QUESTION: i was looking for similar title here but i didn't find much info, so if anyone can provide some example or url or any approach how to do it. For example: is it possible to call a jsp from a gwt widget? or communication (server - jsp) in gwt project and so on.. Is there any ...
[ "java", "jsp", "gwt" ]
3
3
6,970
2
0
2011-06-08T11:05:13.967000
2011-06-08T11:45:20.680000
6,277,759
6,278,322
Binding to WPF DataGrid cell value from within template
I have a collection of custom data objects that I display in DataGrid. The columns are created dynamically on runtime. Some of the columns are TemplateColumns which display the value as a progressbar with respective text in the TextBlock; the brogressbar itself is defined from Style: private string CreateProgressBarCol...
You can use the ProgressBar.Tag property to proxy the value to the TextBlock in the ControlTemplate. But really, this should be a custom control (i.e. MyProgressBar) which exposes a new dependency property (i.e. Text). To use the Tag, you'd add: CellTemp.Append(String.Format(" ", fieldName)); The bind your TextBlock to...
Binding to WPF DataGrid cell value from within template I have a collection of custom data objects that I display in DataGrid. The columns are created dynamically on runtime. Some of the columns are TemplateColumns which display the value as a progressbar with respective text in the TextBlock; the brogressbar itself is...
TITLE: Binding to WPF DataGrid cell value from within template QUESTION: I have a collection of custom data objects that I display in DataGrid. The columns are created dynamically on runtime. Some of the columns are TemplateColumns which display the value as a progressbar with respective text in the TextBlock; the bro...
[ "wpf", "templates", "xaml", "data-binding", "datagrid" ]
2
1
1,922
1
0
2011-06-08T11:05:26.167000
2011-06-08T11:56:42.553000
6,277,760
6,277,808
Can I use Linq's Except() with a lambda expression comparer?
I know I can call linq's Except and specify a custom IEqualityComparer, but implementing a new Comparer class for each data type seems like an overkill for this purpose. Can I use a lambda expression to provide the equality function, like when I use Where or other LINQ functions? If I can't, is there an alternative?
I don't think you can directly with the basic LINQ interfaces, but I've seen people implement a LambdaComparer class with extension methods which will help you do it. Here's an example
Can I use Linq's Except() with a lambda expression comparer? I know I can call linq's Except and specify a custom IEqualityComparer, but implementing a new Comparer class for each data type seems like an overkill for this purpose. Can I use a lambda expression to provide the equality function, like when I use Where or ...
TITLE: Can I use Linq's Except() with a lambda expression comparer? QUESTION: I know I can call linq's Except and specify a custom IEqualityComparer, but implementing a new Comparer class for each data type seems like an overkill for this purpose. Can I use a lambda expression to provide the equality function, like wh...
[ "c#", ".net", "linq" ]
40
11
35,523
7
0
2011-06-08T11:05:26.820000
2011-06-08T11:10:09.007000
6,277,761
6,278,089
Execute Unittest in Django
I have written a small unit test for my django view.My project structure is like Project_name/ apps/ module1/ tests.py module2/ tests.py this is my dir structure i am executing the tests by using the command: $python manage.py test_coverage module1 module2 -v2 then it executing the test nicely but now i have change di...
The simplest solution is to add __init__.py file to tests/ package containing following lines: from.test_basic import * from.test_detail import * And then run all the tests with: $ python manage.py test module1
Execute Unittest in Django I have written a small unit test for my django view.My project structure is like Project_name/ apps/ module1/ tests.py module2/ tests.py this is my dir structure i am executing the tests by using the command: $python manage.py test_coverage module1 module2 -v2 then it executing the test nice...
TITLE: Execute Unittest in Django QUESTION: I have written a small unit test for my django view.My project structure is like Project_name/ apps/ module1/ tests.py module2/ tests.py this is my dir structure i am executing the tests by using the command: $python manage.py test_coverage module1 module2 -v2 then it execu...
[ "python", "django", "unit-testing", "django-unittest" ]
0
3
151
1
0
2011-06-08T11:05:27.257000
2011-06-08T11:35:05.747000
6,277,771
6,277,806
What is a composition root in the context of dependency injection?
I am exploring dependency injection and the term composition root is used all over the place. So what is it?
The composition root is the single place in your application where the composition of the object graphs for your application take place, using the dependency injection container (although how this is done is irrelevant, it could be using a container or could be done manually using pure DI ). There should only be one pl...
What is a composition root in the context of dependency injection? I am exploring dependency injection and the term composition root is used all over the place. So what is it?
TITLE: What is a composition root in the context of dependency injection? QUESTION: I am exploring dependency injection and the term composition root is used all over the place. So what is it? ANSWER: The composition root is the single place in your application where the composition of the object graphs for your appl...
[ "dependency-injection", "inversion-of-control" ]
90
87
30,588
2
0
2011-06-08T11:06:35.157000
2011-06-08T11:10:00.753000
6,277,776
6,277,834
CodeIgniter access parent function variable
I have made a script that adds files to a zip (after lots of parsing, etc..) and I have this function: function _add_file($command) { if (!isset($command["source"]) ||!isset($command["dest"])) { return; } if (!get_file_info("files/".$command["source"])) { return; } $zip->addFile("files/".$command["source"], $command[...
Make it a class variable var $zip and access it with $this->zip
CodeIgniter access parent function variable I have made a script that adds files to a zip (after lots of parsing, etc..) and I have this function: function _add_file($command) { if (!isset($command["source"]) ||!isset($command["dest"])) { return; } if (!get_file_info("files/".$command["source"])) { return; } $zip->ad...
TITLE: CodeIgniter access parent function variable QUESTION: I have made a script that adds files to a zip (after lots of parsing, etc..) and I have this function: function _add_file($command) { if (!isset($command["source"]) ||!isset($command["dest"])) { return; } if (!get_file_info("files/".$command["source"])) { r...
[ "php", "codeigniter", "variables", "scope", "parent" ]
0
2
155
1
0
2011-06-08T11:07:21.017000
2011-06-08T11:12:04.260000
6,277,800
6,277,864
Scientific Notation - bug in .NET?
Yeah I know it's hard to believe - bug in.NET? But run this code in the command line app: decimal x; x = decimal.Parse("3.E-2", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("5.72e9", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("3.E−2", NumberStyles.Float); Console.WriteLine(x); I'm g...
The first and 3rd are not exactly the same. in the 3rd you have a "longer" - sign, as a result it doesnt know what to do with it. Therefore you would need to check for that and replace it with the standard minus sign
Scientific Notation - bug in .NET? Yeah I know it's hard to believe - bug in.NET? But run this code in the command line app: decimal x; x = decimal.Parse("3.E-2", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("5.72e9", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("3.E−2", NumberStyles....
TITLE: Scientific Notation - bug in .NET? QUESTION: Yeah I know it's hard to believe - bug in.NET? But run this code in the command line app: decimal x; x = decimal.Parse("3.E-2", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("5.72e9", NumberStyles.Float); Console.WriteLine(x); x = decimal.Parse("3.E...
[ "c#", ".net", "scientific-notation" ]
2
24
1,316
1
0
2011-06-08T11:09:28.290000
2011-06-08T11:14:10.233000
6,277,812
6,278,171
Solr - Import date time field from DB -> 2 hours difference
I'm importing a datetime column (SQLServer) in Solr, and the values is always 2 hours early in solr that in the DB, with full and delta imports. I have configured jvm with the correct time (in the logs it's show the correct time). I think I have to configure something in data-config.xml but I can't find any information...
You need to convert your date/times into UTC format when you use the data import handler. See this thread on how to do it. AFAIK Solr always expects your dates in UTC format, no matter what the timestamp of the JVM is. Ditto for when you retrieve and display the date (it will be UTC).
Solr - Import date time field from DB -> 2 hours difference I'm importing a datetime column (SQLServer) in Solr, and the values is always 2 hours early in solr that in the DB, with full and delta imports. I have configured jvm with the correct time (in the logs it's show the correct time). I think I have to configure s...
TITLE: Solr - Import date time field from DB -> 2 hours difference QUESTION: I'm importing a datetime column (SQLServer) in Solr, and the values is always 2 hours early in solr that in the DB, with full and delta imports. I have configured jvm with the correct time (in the logs it's show the correct time). I think I h...
[ "import", "solr" ]
3
4
2,607
1
0
2011-06-08T11:10:29.167000
2011-06-08T11:42:21.597000
6,277,816
6,277,964
How to get right HTML code from a concrete URL (python)
Im trying to write a code, that will be able to verify domain through whois.domaintools.com. But theres a little problem with reading the html, that do not match with whois.domaintools.com/notregistereddomain.com source code. Whats wrong? Its problem with requsting or what? I really dont know how to solve it. import ur...
If you use print error instead of print error.read(), you'll see that you're getting a HTTP 403 "Forbidden" answer from the server. Apparently this server doesn't like requests without a user-agent header (or it doesn't like Python's one because it doesn't want to be queried from a script). Here's a workaround: user_ag...
How to get right HTML code from a concrete URL (python) Im trying to write a code, that will be able to verify domain through whois.domaintools.com. But theres a little problem with reading the html, that do not match with whois.domaintools.com/notregistereddomain.com source code. Whats wrong? Its problem with requstin...
TITLE: How to get right HTML code from a concrete URL (python) QUESTION: Im trying to write a code, that will be able to verify domain through whois.domaintools.com. But theres a little problem with reading the html, that do not match with whois.domaintools.com/notregistereddomain.com source code. Whats wrong? Its pro...
[ "python", "html", "url", "urllib" ]
0
2
963
1
0
2011-06-08T11:10:40.477000
2011-06-08T11:23:25.993000
6,277,817
6,277,893
Storing string in resource,
Does anyone know a method other than string table to store strings in resource.. cause i would like to store only one or two string...and avoid string table as if i use FindResource() function it will load a whole block of strings
Store each string separately as a Binary resource. In this case you can load each string separately by its ID. Code below will extract resource with "ResId" from "RES_SECTION", where RES_SECTION is custom section defined by user when resource is added, and ResId is id of the resource. HMODULE hModule = NULL; HGLOBAL hR...
Storing string in resource, Does anyone know a method other than string table to store strings in resource.. cause i would like to store only one or two string...and avoid string table as if i use FindResource() function it will load a whole block of strings
TITLE: Storing string in resource, QUESTION: Does anyone know a method other than string table to store strings in resource.. cause i would like to store only one or two string...and avoid string table as if i use FindResource() function it will load a whole block of strings ANSWER: Store each string separately as a ...
[ "windows", "string", "resources" ]
0
1
134
1
0
2011-06-08T11:10:45.513000
2011-06-08T11:16:13.930000
6,277,822
6,277,927
send multiple mail with image attachements
i am using mail class to send email with attachment as image to multiple recipients. but the problem is as email is sent to first recipient it is throwing an exception that "image is being used by another process".. how this can be solved.. i am getting users in listitem as: foreach (ListItem item in lstboxlist.Items) ...
Close the stream after you've finished with it, so for example: StreamReader strm_rdr = new StreamReader(theme); string theme_text = strm_rdr.ReadToEnd(); strm_rdr.Close();
send multiple mail with image attachements i am using mail class to send email with attachment as image to multiple recipients. but the problem is as email is sent to first recipient it is throwing an exception that "image is being used by another process".. how this can be solved.. i am getting users in listitem as: f...
TITLE: send multiple mail with image attachements QUESTION: i am using mail class to send email with attachment as image to multiple recipients. but the problem is as email is sent to first recipient it is throwing an exception that "image is being used by another process".. how this can be solved.. i am getting users...
[ "c#", "email" ]
0
1
219
1
0
2011-06-08T11:11:12.653000
2011-06-08T11:19:36.630000
6,277,829
6,277,939
how to pass values from one activity to other using bundle
i am having many activities like settings,game,home etc.i want to accept some values from user in settings page.when i click on the done button all these values have to b stored in variables.at the same time i am going back to home page.from there i am going to game class.in that i want to get the previously stored val...
You should use Intent itself to pass data from One Activity to another. Use intent.putExtra("NAME", data); you could refer to this thread
how to pass values from one activity to other using bundle i am having many activities like settings,game,home etc.i want to accept some values from user in settings page.when i click on the done button all these values have to b stored in variables.at the same time i am going back to home page.from there i am going to...
TITLE: how to pass values from one activity to other using bundle QUESTION: i am having many activities like settings,game,home etc.i want to accept some values from user in settings page.when i click on the done button all these values have to b stored in variables.at the same time i am going back to home page.from t...
[ "android", "bundle" ]
2
2
14,908
4
0
2011-06-08T11:11:55.727000
2011-06-08T11:20:28.017000
6,277,844
6,277,891
Android Cursor Query Count
I'm developing a small application that reads data from a database and displys it in a few custom listview layouts. I got all my ducks in a row but have one issue where I can't wrap my mind around which is preforming a count within the cursor query Here is a simple example of my code private static final String fields[...
You can use Cursor.getCount() to get the total number of rows returned by the cursor. To count individual 'makers' you can either iterate over the cursor, and count them yourself, or use another query to issue COUNT SQL to the server and retrieve the counts from there. As you're already fetching this data for use in a ...
Android Cursor Query Count I'm developing a small application that reads data from a database and displys it in a few custom listview layouts. I got all my ducks in a row but have one issue where I can't wrap my mind around which is preforming a count within the cursor query Here is a simple example of my code private ...
TITLE: Android Cursor Query Count QUESTION: I'm developing a small application that reads data from a database and displys it in a few custom listview layouts. I got all my ducks in a row but have one issue where I can't wrap my mind around which is preforming a count within the cursor query Here is a simple example o...
[ "android", "sql", "count", "android-cursor" ]
4
14
15,465
2
0
2011-06-08T11:12:43.913000
2011-06-08T11:16:06.763000
6,277,868
6,277,988
What should a CSS Class represent?
Possible Duplicate: Should css class names like 'floatleft' that directly describe the attached style be avoided? I was wondering what the best practices were for the naming and usage of CSS classes. For instance, in a scenario where you want to center the text of both the button text and the header text, is it better ...
A CSS class should represent what you use the element for, not what the element looks like. Consider that you have headers that are red and bold, and change the design to large blue letters instead. If you named your classes after the look of the headers, you end up with:.RedBold { color: blue; font-size: 200%; }
What should a CSS Class represent? Possible Duplicate: Should css class names like 'floatleft' that directly describe the attached style be avoided? I was wondering what the best practices were for the naming and usage of CSS classes. For instance, in a scenario where you want to center the text of both the button text...
TITLE: What should a CSS Class represent? QUESTION: Possible Duplicate: Should css class names like 'floatleft' that directly describe the attached style be avoided? I was wondering what the best practices were for the naming and usage of CSS classes. For instance, in a scenario where you want to center the text of bo...
[ "css" ]
1
7
280
5
0
2011-06-08T11:14:21.450000
2011-06-08T11:25:00.507000
6,277,871
6,278,429
How to read xml values from specified path as shown in code
I created xml file getFilesDir().getAbsolutePath()+ File.separator + "test.xml" in this path, i want to read xml values from this path how can i do it. please send me code for accessing file on that path. this xml is created in this path in DDMS ( data/data/ /files/xmlname.xml ) please help me. Thank You, TextView txto...
you can use... XmlPullParser.. to parse xml file in android. http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html Doc about xml pull parser on android developer site. and little article with code snippest is given here... http://indiheaven.blogspot.com/2011/03/xml-parsing-in-android-using.html
How to read xml values from specified path as shown in code I created xml file getFilesDir().getAbsolutePath()+ File.separator + "test.xml" in this path, i want to read xml values from this path how can i do it. please send me code for accessing file on that path. this xml is created in this path in DDMS ( data/data/ /...
TITLE: How to read xml values from specified path as shown in code QUESTION: I created xml file getFilesDir().getAbsolutePath()+ File.separator + "test.xml" in this path, i want to read xml values from this path how can i do it. please send me code for accessing file on that path. this xml is created in this path in D...
[ "android", "xml" ]
0
0
887
1
0
2011-06-08T11:14:27.160000
2011-06-08T12:06:42.740000
6,277,877
6,283,398
How do I develop a web page that returns password for users to register?
I am doing a project on creating a lab application for a next generation sequencing data using ruby on rails. The main idea my boss suggests me to do is to have users fill in their details and submit to us. After the submission, the administrator, i.e. me, would send them a password which they can use to login my appli...
I would start with Michael Hartl's RailsTutorial. Not only did I find it the best way to get started - the application he builds includes a bombproof user security model, just as you require, and so you'd be both learning and developing something relevant at the same time. I'd also recommend buying the videos, as well ...
How do I develop a web page that returns password for users to register? I am doing a project on creating a lab application for a next generation sequencing data using ruby on rails. The main idea my boss suggests me to do is to have users fill in their details and submit to us. After the submission, the administrator,...
TITLE: How do I develop a web page that returns password for users to register? QUESTION: I am doing a project on creating a lab application for a next generation sequencing data using ruby on rails. The main idea my boss suggests me to do is to have users fill in their details and submit to us. After the submission, ...
[ "ruby-on-rails" ]
0
0
55
2
0
2011-06-08T11:14:55.740000
2011-06-08T18:23:36.420000
6,277,888
6,278,244
How can I rewrite this Linq to XML query?
I am preferring LINQ to XML over XMLReader because it feels much easier to use. However, I know I'm doing it wrong somewhere. I'm not looking for faster execution or anything, just a cleaner rewrite. I can't tell if it'll fit cleanly into the from foo in bar where foo is some condition form, but there's got to be a cle...
I think, you can do something like this: XDocument xdoc = XDocument.Load(@"..\..\XMLFile1.xml"); var data = xdoc.Root.Elements("Component").SelectMany(e => new { type = e.Attribute("type").Value, paramValues = e.Elements().Select(x => new KeyValuePair (x.Name.LocalName, x.Value)), paramType = e.Elements().Select(x => x...
How can I rewrite this Linq to XML query? I am preferring LINQ to XML over XMLReader because it feels much easier to use. However, I know I'm doing it wrong somewhere. I'm not looking for faster execution or anything, just a cleaner rewrite. I can't tell if it'll fit cleanly into the from foo in bar where foo is some c...
TITLE: How can I rewrite this Linq to XML query? QUESTION: I am preferring LINQ to XML over XMLReader because it feels much easier to use. However, I know I'm doing it wrong somewhere. I'm not looking for faster execution or anything, just a cleaner rewrite. I can't tell if it'll fit cleanly into the from foo in bar w...
[ "c#", "xml", "linq", "components", "linq-to-xml" ]
1
4
252
1
0
2011-06-08T11:15:47.757000
2011-06-08T11:48:29.967000
6,277,905
6,278,145
SQL Server: Maximum number of records to return
We have RowCount to set number of records to return or affect. But we need to set this each time before executing sql statement. I am looking a way to set this once my application started and so it affect all queries execute via my application. Update I want to achieve a trial version strategy with limited records! I d...
You don't mention the application language you are using, so I can't give you the code, but make a wrapper function for a database connect. In this function, after you connect to the database, issue the SET ROWCOUNT n, make n a parameter and add any logic you need to make it variable. I do a similar thing with CONTEXT_...
SQL Server: Maximum number of records to return We have RowCount to set number of records to return or affect. But we need to set this each time before executing sql statement. I am looking a way to set this once my application started and so it affect all queries execute via my application. Update I want to achieve a ...
TITLE: SQL Server: Maximum number of records to return QUESTION: We have RowCount to set number of records to return or affect. But we need to set this each time before executing sql statement. I am looking a way to set this once my application started and so it affect all queries execute via my application. Update I ...
[ "sql-server", "t-sql" ]
6
2
6,568
3
0
2011-06-08T11:17:01.537000
2011-06-08T11:40:16.247000
6,277,907
6,277,935
How to determine the screen width/height using C#
I want to set the width & height of a Window dynamically based on the user screens maximum width/height. How can I determine this programmatically?
For the primary screen: System.Windows.SystemParameters.PrimaryScreenWidth System.Windows.SystemParameters.PrimaryScreenHeight ( Note that there are also some other primary screen related properties which depend on various factors, Full* & Maximised* ) Virtual screen: SystemParameters.VirtualScreenWidth SystemParameter...
How to determine the screen width/height using C# I want to set the width & height of a Window dynamically based on the user screens maximum width/height. How can I determine this programmatically?
TITLE: How to determine the screen width/height using C# QUESTION: I want to set the width & height of a Window dynamically based on the user screens maximum width/height. How can I determine this programmatically? ANSWER: For the primary screen: System.Windows.SystemParameters.PrimaryScreenWidth System.Windows.Syste...
[ "c#", "wpf", "screen", "css" ]
30
42
86,485
6
0
2011-06-08T11:17:05.423000
2011-06-08T11:20:09.967000
6,277,921
6,280,045
NSPredicate with Multiple parameters
Hello Need help with predicate. The problem is that I want to have one function which will fetch from database depends on the multiple values it receives, but the values don't always exist, does it mean I have to create several different predicates? Code below NSPredicate *predicate = [NSPredicate predicateWithFormat:@...
Assemble an appropriate collection of individual predicates into NSCompoundPredicate as in NSMutableArray *parr = [NSMutableArray array]; if([brand_one length]) { [parr addObject:[NSPredicate predicateWithFormat:@"brand_id LIKE %@",myBrandId]]; } if([brand_two length]) { // etc } NSPredicate *compoundpred = [NSCompoun...
NSPredicate with Multiple parameters Hello Need help with predicate. The problem is that I want to have one function which will fetch from database depends on the multiple values it receives, but the values don't always exist, does it mean I have to create several different predicates? Code below NSPredicate *predicate...
TITLE: NSPredicate with Multiple parameters QUESTION: Hello Need help with predicate. The problem is that I want to have one function which will fetch from database depends on the multiple values it receives, but the values don't always exist, does it mean I have to create several different predicates? Code below NSPr...
[ "xcode", "core-data", "nspredicate" ]
25
61
23,923
3
0
2011-06-08T11:18:59.220000
2011-06-08T14:09:32.027000
6,277,926
6,277,946
JavaScript access from parent domain to subdomain?
I've read that setting document.domain = "example.com" lets me access the parent domain from a subdomain. Will the same work the other way around? Let's say my main site is running under http://example.com. All API functions that I want to access via AJAX (GET & POST) are hosted on http:// api.example.com. Will I be ab...
You need to set document.domain on BOTH pages Alternatively set CORS headers on your server: http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/ A Quick Overview of CORS Firefox 3.5 and Safari 4 implement the CORS specification, using XMLHttpRequest as an “API container” that sends and receives the ap...
JavaScript access from parent domain to subdomain? I've read that setting document.domain = "example.com" lets me access the parent domain from a subdomain. Will the same work the other way around? Let's say my main site is running under http://example.com. All API functions that I want to access via AJAX (GET & POST) ...
TITLE: JavaScript access from parent domain to subdomain? QUESTION: I've read that setting document.domain = "example.com" lets me access the parent domain from a subdomain. Will the same work the other way around? Let's say my main site is running under http://example.com. All API functions that I want to access via ...
[ "javascript", "cross-domain", "cross-domain-policy" ]
18
7
18,388
1
0
2011-06-08T11:19:19.250000
2011-06-08T11:21:19.803000
6,277,944
6,277,978
Escape double quotes in Java
Possible Duplicate: In Java, is there a way to write a string literal without having to escape quotes? private static final String CREATE_TABLE_EXHIBITORS = "CREATE TABLE "users" ("_id" text PRIMARY KEY,"name" text,"body" text,"image" text,"stand_id" text,"begin" long,"end" long,"changedate" long,"website" text,"facebo...
Escaping the double quotes with backslashes is the only way to do this in Java. Some IDEs around such as IntelliJ IDEA do this escaping automatically when pasting such a String into a String literal (i.e. between the double quotes surrounding a java String literal) One other option would be to put the String into some ...
Escape double quotes in Java Possible Duplicate: In Java, is there a way to write a string literal without having to escape quotes? private static final String CREATE_TABLE_EXHIBITORS = "CREATE TABLE "users" ("_id" text PRIMARY KEY,"name" text,"body" text,"image" text,"stand_id" text,"begin" long,"end" long,"changedate...
TITLE: Escape double quotes in Java QUESTION: Possible Duplicate: In Java, is there a way to write a string literal without having to escape quotes? private static final String CREATE_TABLE_EXHIBITORS = "CREATE TABLE "users" ("_id" text PRIMARY KEY,"name" text,"body" text,"image" text,"stand_id" text,"begin" long,"end...
[ "java", "escaping" ]
56
45
263,503
4
0
2011-06-08T11:21:12.757000
2011-06-08T11:24:31.457000
6,277,949
6,278,028
I've created a WCF service and now I want to call it from a reference but why InvalidOperationException?
I've written a WCF service. I have successfully browsed to the service and it says: You have created a service. So then I add a reference to it using a the 'Add Service Reference' in visual studio. Then I write the following code to consume it.... ServiceReference1.VLSContentServiceClient client = new ServiceReference1...
You are using REST service - client for such service cannot be created with Add service reference. That is only for SOAP services (no webHttpBinding and webHttp behavior). Also once you use SOAP service you don't pass name of any server side feature to the constructor of the proxy. The proxy constructor expects name of...
I've created a WCF service and now I want to call it from a reference but why InvalidOperationException? I've written a WCF service. I have successfully browsed to the service and it says: You have created a service. So then I add a reference to it using a the 'Add Service Reference' in visual studio. Then I write the ...
TITLE: I've created a WCF service and now I want to call it from a reference but why InvalidOperationException? QUESTION: I've written a WCF service. I have successfully browsed to the service and it says: You have created a service. So then I add a reference to it using a the 'Add Service Reference' in visual studio....
[ "c#", "wcf", "web-services" ]
1
5
708
3
0
2011-06-08T11:21:43.913000
2011-06-08T11:29:02.010000
6,277,952
6,278,470
Animate image with ImageView
I am get an exception when I try to animate an image through frame and ImageView. Here is the code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView rocketImage = (ImageView) findViewById(R.id.imageView1); rocketImage.setBackgroundResource(R....
try with this animation_sample.xml sorry if there are some errors but I don't have here eclipse and the SDK
Animate image with ImageView I am get an exception when I try to animate an image through frame and ImageView. Here is the code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView rocketImage = (ImageView) findViewById(R.id.imageView1); rocketI...
TITLE: Animate image with ImageView QUESTION: I am get an exception when I try to animate an image through frame and ImageView. Here is the code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView rocketImage = (ImageView) findViewById(R.id.im...
[ "android", "animation", "imageview" ]
1
1
2,130
1
0
2011-06-08T11:22:00.030000
2011-06-08T12:10:14.200000
6,277,953
6,278,347
How to manage Loopers and Threads (thread doesn't die anymore!)
I created a class extending Thread to retrieve user location through LocationManager in a non-ui thread. I implemented this as a thread because it has to be started on request and do its work just for a limited time. By the way, I had to add a Looper object in the thread, to be able to create the handler for the Locati...
You can explicitly quit from Looper 's loop using Handler: private Handler mUserLocationHandler = null; private Handler handler = null; public class UserLocationThread extends Thread implements LocationListener { public void run() { try { Looper.prepare(); mUserLocationHandler = new Handler(); locationManager.request...
How to manage Loopers and Threads (thread doesn't die anymore!) I created a class extending Thread to retrieve user location through LocationManager in a non-ui thread. I implemented this as a thread because it has to be started on request and do its work just for a limited time. By the way, I had to add a Looper objec...
TITLE: How to manage Loopers and Threads (thread doesn't die anymore!) QUESTION: I created a class extending Thread to retrieve user location through LocationManager in a non-ui thread. I implemented this as a thread because it has to be started on request and do its work just for a limited time. By the way, I had to ...
[ "android", "multithreading", "handler", "looper" ]
9
20
17,149
5
0
2011-06-08T11:22:13.390000
2011-06-08T11:59:18.607000
6,277,958
6,277,973
whats a good ios charting library/framework
Has anyone got any recommendations for a charting library/framework for ios. I need to be able to create bar, pie, line trend, scatter charts from an internal database/warehouse onto an iPad. I've read some mixed reports about core-plot.
We've used this in the past http://code.google.com/p/core-plot/ and found it to be the most reliable!
whats a good ios charting library/framework Has anyone got any recommendations for a charting library/framework for ios. I need to be able to create bar, pie, line trend, scatter charts from an internal database/warehouse onto an iPad. I've read some mixed reports about core-plot.
TITLE: whats a good ios charting library/framework QUESTION: Has anyone got any recommendations for a charting library/framework for ios. I need to be able to create bar, pie, line trend, scatter charts from an internal database/warehouse onto an iPad. I've read some mixed reports about core-plot. ANSWER: We've used ...
[ "ios", "frameworks", "charts", "core-plot" ]
7
5
17,074
4
0
2011-06-08T11:22:38.763000
2011-06-08T11:24:12.120000
6,277,959
6,278,067
grep on colored lines
I wrote a simple PHP shell script which parses files and outputs certain element. It generates lots of output. In different (bash) colors, green for OK, yellow for warnings, red for errors, etc. During development I want to filter some lines out. For example all lines that contains red text. Can I use a grep (or other)...
I have no idea what your input looks like, but as a proof of concept you can filter any lines in ls output that use green colour: ls --color=always | grep '^[\[01;32m' The lookup table for other colours can be found here: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors Hint: In case you didn't know, the ^[ part ab...
grep on colored lines I wrote a simple PHP shell script which parses files and outputs certain element. It generates lots of output. In different (bash) colors, green for OK, yellow for warnings, red for errors, etc. During development I want to filter some lines out. For example all lines that contains red text. Can I...
TITLE: grep on colored lines QUESTION: I wrote a simple PHP shell script which parses files and outputs certain element. It generates lots of output. In different (bash) colors, green for OK, yellow for warnings, red for errors, etc. During development I want to filter some lines out. For example all lines that contai...
[ "linux", "bash", "grep" ]
7
8
3,234
2
0
2011-06-08T11:22:39.400000
2011-06-08T11:32:53.313000
6,277,966
6,278,066
Reading XML comments in C#
I have got some XML files that contain comments above the nodes. When I am reading the file in, as part of the process I would like to get the comment out as well. I know you can write a comment to the file using XmlComment, but not sure how to read them back out. My XML looks similar to this:
Try this: XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.IgnoreComments = false; using (XmlReader reader = XmlReader.Create("input.xml", readerSettings)) { XmlDocument myData = new XmlDocument(); myData.Load(reader); // etc... } To read comments: XmlReader xmlRdr = XmlReader.Create("Test.XML...
Reading XML comments in C# I have got some XML files that contain comments above the nodes. When I am reading the file in, as part of the process I would like to get the comment out as well. I know you can write a comment to the file using XmlComment, but not sure how to read them back out. My XML looks similar to this...
TITLE: Reading XML comments in C# QUESTION: I have got some XML files that contain comments above the nodes. When I am reading the file in, as part of the process I would like to get the comment out as well. I know you can write a comment to the file using XmlComment, but not sure how to read them back out. My XML loo...
[ "c#", "xml" ]
12
17
23,165
6
0
2011-06-08T11:23:35.373000
2011-06-08T11:32:53.300000
6,277,990
6,278,071
How to encrypt long strings in PHP?
I'm using PHP's openssl_public_encrypt() to encrypt data using RSA. But it won't encrypt data larger than a certain size. How can I get it to encrypt data of an arbitrary length?
The php.net page has an excellent hint for this problem (as usual) http://www.php.net/manual/en/function.openssl-public-encrypt.php#95307
How to encrypt long strings in PHP? I'm using PHP's openssl_public_encrypt() to encrypt data using RSA. But it won't encrypt data larger than a certain size. How can I get it to encrypt data of an arbitrary length?
TITLE: How to encrypt long strings in PHP? QUESTION: I'm using PHP's openssl_public_encrypt() to encrypt data using RSA. But it won't encrypt data larger than a certain size. How can I get it to encrypt data of an arbitrary length? ANSWER: The php.net page has an excellent hint for this problem (as usual) http://www....
[ "php", "rsa", "public-key-encryption" ]
12
4
12,842
3
0
2011-06-08T11:25:07.093000
2011-06-08T11:33:03.990000
6,277,993
6,278,235
How to change hyperlink color in xml layout
In my project I am not able to change the color of the hyperlink text. Basically this text is shown in TextView and for it I have used xml layout such as android:autoLink="all" Now the problem is that I want to change the color of this hyperlink text to white Thanks all in advance.
use this property android:textColorLink="@android:color/white" for that textView
How to change hyperlink color in xml layout In my project I am not able to change the color of the hyperlink text. Basically this text is shown in TextView and for it I have used xml layout such as android:autoLink="all" Now the problem is that I want to change the color of this hyperlink text to white Thanks all in ad...
TITLE: How to change hyperlink color in xml layout QUESTION: In my project I am not able to change the color of the hyperlink text. Basically this text is shown in TextView and for it I have used xml layout such as android:autoLink="all" Now the problem is that I want to change the color of this hyperlink text to whit...
[ "android", "android-layout" ]
1
5
2,905
2
0
2011-06-08T11:25:25.823000
2011-06-08T11:47:43.360000
6,278,017
6,278,046
Select Case problem
I have this code: For each c as char in "Hello World" Select Case c Case "h" DoSomething() Case "e" DoSomething() End Select Next Why I cant write like this: Case "h" Or "e" DoSomething() It says 'Long' values cannot be converted to 'Char' How to accomplish this task?
Use: Select Case c Case "h" Case "e" DoSomething() End Select or: Select Case c Case "h","e" DoSomething() End Select
Select Case problem I have this code: For each c as char in "Hello World" Select Case c Case "h" DoSomething() Case "e" DoSomething() End Select Next Why I cant write like this: Case "h" Or "e" DoSomething() It says 'Long' values cannot be converted to 'Char' How to accomplish this task?
TITLE: Select Case problem QUESTION: I have this code: For each c as char in "Hello World" Select Case c Case "h" DoSomething() Case "e" DoSomething() End Select Next Why I cant write like this: Case "h" Or "e" DoSomething() It says 'Long' values cannot be converted to 'Char' How to accomplish this task? ANSWER: Use:...
[ ".net", "vb.net" ]
3
8
398
4
0
2011-06-08T11:27:59.217000
2011-06-08T11:30:55.250000
6,278,019
6,278,183
Slf4j LOGGER usage
Can anyone throw some light on the clear usage of different levels of LOGGER viz LOGGER.info() LOGGER.trace(), LOGGER.error() and LOGGER.debug(). Pls note its not about configuration, but its about when to use info() and when not to use etc.
I tend to use them like this: TRACE: Mark where something has executed, like the start of a method. I'm usually not interested logging any information other than "this line executed". Usually turned off in both development and production (to prevent logging large amounts of output) but turned on if I'm diagnosing a def...
Slf4j LOGGER usage Can anyone throw some light on the clear usage of different levels of LOGGER viz LOGGER.info() LOGGER.trace(), LOGGER.error() and LOGGER.debug(). Pls note its not about configuration, but its about when to use info() and when not to use etc.
TITLE: Slf4j LOGGER usage QUESTION: Can anyone throw some light on the clear usage of different levels of LOGGER viz LOGGER.info() LOGGER.trace(), LOGGER.error() and LOGGER.debug(). Pls note its not about configuration, but its about when to use info() and when not to use etc. ANSWER: I tend to use them like this: TR...
[ "java", "logging", "slf4j" ]
3
5
1,039
2
0
2011-06-08T11:28:01.380000
2011-06-08T11:43:04.797000
6,278,021
6,278,131
How can i create Graph in android aplication?
How to Create 3d Graph(Like pie,line,scatter) in android Application?
AChartEngine is a good option for this, Free, OpenSource and have almost all type of graphs. you can download it from here, as well as demo application also.
How can i create Graph in android aplication? How to Create 3d Graph(Like pie,line,scatter) in android Application?
TITLE: How can i create Graph in android aplication? QUESTION: How to Create 3d Graph(Like pie,line,scatter) in android Application? ANSWER: AChartEngine is a good option for this, Free, OpenSource and have almost all type of graphs. you can download it from here, as well as demo application also.
[ "android" ]
0
3
2,136
2
0
2011-06-08T11:28:11.147000
2011-06-08T11:38:46.217000
6,278,026
6,278,068
Creating a variable_function as member of a class
Let's say we have a class stockFns and I do $stockFns->{$functionOne}=create_function('$a,$b', 'return $a+$b;'); This creates a property in $stockFns named whatever create_function returned. Now I want to refer (invoke) to the created_function. What would be a clean way to do it in a single instruction?. An example $st...
Either your way, or echo call_user_func(array($stockFbs, 'add'), 1, 2); The problem is, that PHP cannot distinguish real methods from properties with callables. If you call something with () it will not touch the properties at all and in maybe will call __call, if it exists. You can try something like class StockFns { ...
Creating a variable_function as member of a class Let's say we have a class stockFns and I do $stockFns->{$functionOne}=create_function('$a,$b', 'return $a+$b;'); This creates a property in $stockFns named whatever create_function returned. Now I want to refer (invoke) to the created_function. What would be a clean way...
TITLE: Creating a variable_function as member of a class QUESTION: Let's say we have a class stockFns and I do $stockFns->{$functionOne}=create_function('$a,$b', 'return $a+$b;'); This creates a property in $stockFns named whatever create_function returned. Now I want to refer (invoke) to the created_function. What wo...
[ "php", "variables", "dynamic" ]
1
2
42
2
0
2011-06-08T11:28:56.610000
2011-06-08T11:32:56.170000
6,278,033
6,278,141
listview and screen orientation
I dont' event know if it's possible but here is what I would like to achieve. I have some actvities that show some data in listviews with list adapters (just compòsed of text views). The layout is based on: And Here is the basic composition of one "row" of the listView: textview1 textView2 textView4 textview5 inflatedv...
For this we have one event is there when mobile orientation is changed i,e; ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getOrientation() By using above code we get the screen orientation.If orienation is landscape at that time you take 2 listviews side by side,and set the values to tha...
listview and screen orientation I dont' event know if it's possible but here is what I would like to achieve. I have some actvities that show some data in listviews with list adapters (just compòsed of text views). The layout is based on: And Here is the basic composition of one "row" of the listView: textview1 textVie...
TITLE: listview and screen orientation QUESTION: I dont' event know if it's possible but here is what I would like to achieve. I have some actvities that show some data in listviews with list adapters (just compòsed of text views). The layout is based on: And Here is the basic composition of one "row" of the listView:...
[ "android", "listview", "landscape", "listadapter" ]
1
1
880
1
0
2011-06-08T11:29:15.220000
2011-06-08T11:39:40.973000
6,278,034
6,278,288
Adding conflicting methods in an Objective C class using category
I have added a method foo to a class MYCustomClass in a category Category1 separate from the original definition of the class. Then I added another method also called foo in another category Category2. I then call foo on an instance of MYCustomClass. In my case the foo in Category2 is being called. My question is: Is t...
When a category is loaded, its methods are inserted into the existing method table, and there's no way to distinguish where they came from once that's done. The last category to load wins. Back in the NeXTSTEP days, we would sometimes do this deliberately as a very kludgey way to fix a broken method in code for which w...
Adding conflicting methods in an Objective C class using category I have added a method foo to a class MYCustomClass in a category Category1 separate from the original definition of the class. Then I added another method also called foo in another category Category2. I then call foo on an instance of MYCustomClass. In ...
TITLE: Adding conflicting methods in an Objective C class using category QUESTION: I have added a method foo to a class MYCustomClass in a category Category1 separate from the original definition of the class. Then I added another method also called foo in another category Category2. I then call foo on an instance of ...
[ "objective-c", "objective-c-category" ]
4
3
1,247
2
0
2011-06-08T11:29:16.107000
2011-06-08T11:53:19.257000
6,278,045
6,278,410
Application crash on UIButton click : iphone
I have a View base iphone application I add a NSObject class AddNewContact and take its object in IB AddNewContact.h #import @interface AddNewContact: NSObject { } -(IBAction)abc:(id)sender; @end AddNewContact.m #import "AddNewContact.h" @implementation AddNewContact -(IBAction)abc:(id)sender{ NSLog(@"this is test");...
You will be releasing your AddNewContact view controller, the view is still in the superview but the viewController is released, the button tries to call 'abc' on AddNewContact controller which no longer exists...
Application crash on UIButton click : iphone I have a View base iphone application I add a NSObject class AddNewContact and take its object in IB AddNewContact.h #import @interface AddNewContact: NSObject { } -(IBAction)abc:(id)sender; @end AddNewContact.m #import "AddNewContact.h" @implementation AddNewContact -(IBA...
TITLE: Application crash on UIButton click : iphone QUESTION: I have a View base iphone application I add a NSObject class AddNewContact and take its object in IB AddNewContact.h #import @interface AddNewContact: NSObject { } -(IBAction)abc:(id)sender; @end AddNewContact.m #import "AddNewContact.h" @implementation Ad...
[ "objective-c", "cocoa-touch", "xcode", "iphone-sdk-3.0" ]
0
9
2,331
1
0
2011-06-08T11:30:49.043000
2011-06-08T12:05:19.787000
6,278,054
6,282,858
MS-DOS batch script: assignment operation
I am referring to below threat Batch files: How to read a file?. For retrieving the line by line from a text file. I am using the below script: @echo off SETLOCAL DisableDelayedExpansion FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ paths.txt"`) do ( set "var=%%a" SETLOCAL EnableDelayedExpansion set "var=!var:*:=!"...
The key is the delayed expansion, expand your variables inside of parenthesis always with! not with %. A sample that changes X with Y @echo off SETLOCAL DisableDelayedExpansion FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ paths.txt"`) do ( set "var=%%a" SETLOCAL EnableDelayedExpansion set "var=!var:*:=!" set "myVa...
MS-DOS batch script: assignment operation I am referring to below threat Batch files: How to read a file?. For retrieving the line by line from a text file. I am using the below script: @echo off SETLOCAL DisableDelayedExpansion FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ paths.txt"`) do ( set "var=%%a" SETLOCAL ...
TITLE: MS-DOS batch script: assignment operation QUESTION: I am referring to below threat Batch files: How to read a file?. For retrieving the line by line from a text file. I am using the below script: @echo off SETLOCAL DisableDelayedExpansion FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ paths.txt"`) do ( set "...
[ "batch-file", "dos" ]
3
2
2,648
4
0
2011-06-08T11:31:39.460000
2011-06-08T17:34:28.670000
6,278,057
6,278,174
Replace only first match in multiple files with perl
I need to replace a bit of text in multiple css files, but ony the first occurence. I've tried replacing with: perl -pi -e 's/(width:).*;/$1 100%;/' filename.css But this replaces the value after every occurrence of 'width:' in the file, even though i'm not using the /g modifier. I'm running this on a recent Ubuntu mac...
You can stop the replacement after the first one: perl -pi -e '$a=1 if(!$a && s/(width:).*;/$1 100%;/);' filename.css
Replace only first match in multiple files with perl I need to replace a bit of text in multiple css files, but ony the first occurence. I've tried replacing with: perl -pi -e 's/(width:).*;/$1 100%;/' filename.css But this replaces the value after every occurrence of 'width:' in the file, even though i'm not using the...
TITLE: Replace only first match in multiple files with perl QUESTION: I need to replace a bit of text in multiple css files, but ony the first occurence. I've tried replacing with: perl -pi -e 's/(width:).*;/$1 100%;/' filename.css But this replaces the value after every occurrence of 'width:' in the file, even though...
[ "regex", "perl", "replace" ]
10
5
8,157
5
0
2011-06-08T11:31:47.980000
2011-06-08T11:42:35.377000
6,278,061
6,278,157
Invoice from multiple orders?
I need a way to create an invoice from multiple orders every month? In the tbl_order table, I have a list of orders from the customer. tbl_order table OrderID (PK) ShopID (FK) CustomerID (FK) Statu Total OrderDate Let say I want to create an invoice for period: 1 to 31 May from tbl_order.ShopID = 2 (From there, I can ...
You would need 2 tables. The invoice table. InvoiceID (PK) InvoiceDate InvoicePrice InvoiceBtw ect. etc. An link table between orders and invoices. So you can keep track which order is processed in which invoice. InvoiceID (FK to tbl_invoices.InvoiceID) OrderID (FK to tbl_orders.OrderID)
Invoice from multiple orders? I need a way to create an invoice from multiple orders every month? In the tbl_order table, I have a list of orders from the customer. tbl_order table OrderID (PK) ShopID (FK) CustomerID (FK) Statu Total OrderDate Let say I want to create an invoice for period: 1 to 31 May from tbl_order....
TITLE: Invoice from multiple orders? QUESTION: I need a way to create an invoice from multiple orders every month? In the tbl_order table, I have a list of orders from the customer. tbl_order table OrderID (PK) ShopID (FK) CustomerID (FK) Statu Total OrderDate Let say I want to create an invoice for period: 1 to 31 M...
[ "php", "mysql", "database", "database-design", "data-structures" ]
1
3
1,065
2
0
2011-06-08T11:32:30.117000
2011-06-08T11:41:06.823000
6,278,064
6,278,189
How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id
How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id ( id is autoincrement primary key in drk table )? I looked at http://php.net/manual/en/sqlite3.open.php but there is no closing connection. Can someone show me, I don't have experience with SQLite.
See SQLite3::lastInsertRowID(). Also, PDO might be a better choice for you.
How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id ( id is autoincrement primary key in drk table )? I looked at http://php.net/manual/en/sqlite3.open.php but there is no closing connection. Can so...
TITLE: How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id QUESTION: How to insert new row using PHP in SQLITE in table /var/drk.db and to get generated id ( id is autoincrement primary key in drk table )? I looked at http://php.net/manual/en/sqlite3.open.php but there is no closing ...
[ "php", "sqlite" ]
0
0
151
1
0
2011-06-08T11:32:41.293000
2011-06-08T11:43:19.600000
6,278,085
6,290,129
Integrate Gamecenter in cocos2d game
Is there any one who knows how to integrate game center in Cocos2d. Please tell me steps so i can integrate that in my Game.
UPDATE: I created my own Helper Class that works with all kind of Apps (also Cocos2D 1 & 2+) https://github.com/alexblunck/ABGameKitHelper Hi I suggest you use GKHelper Class from Steffen Itterheim! I uploaded the GKHelper.h / GKHelper.m for you: http://www.cl.ly/7ReW Then follow these instructions: //0.0 Add GameKit F...
Integrate Gamecenter in cocos2d game Is there any one who knows how to integrate game center in Cocos2d. Please tell me steps so i can integrate that in my Game.
TITLE: Integrate Gamecenter in cocos2d game QUESTION: Is there any one who knows how to integrate game center in Cocos2d. Please tell me steps so i can integrate that in my Game. ANSWER: UPDATE: I created my own Helper Class that works with all kind of Apps (also Cocos2D 1 & 2+) https://github.com/alexblunck/ABGameKi...
[ "cocos2d-iphone", "game-center" ]
10
30
11,802
3
0
2011-06-08T11:34:46.293000
2011-06-09T08:37:09.920000
6,278,088
6,278,123
singleton pattern in C# Question
I was researching on the singleton pattern for C# I found this example from the msdn website. public sealed class Singleton { private static readonly Singleton instance = new Singleton(); private Singleton(){} public static Singleton Instance { get { return instance; } } } Because the Singleton instance is referenced...
In the example code you provided, the singleton instance will be created at the time of the first access to the class. This means for your example at the time when Instance gets called for the first time. More insight you can find in Jon Skeet's article Implementing the Singleton Pattern in C#, see Method 4. Basically,...
singleton pattern in C# Question I was researching on the singleton pattern for C# I found this example from the msdn website. public sealed class Singleton { private static readonly Singleton instance = new Singleton(); private Singleton(){} public static Singleton Instance { get { return instance; } } } Because the...
TITLE: singleton pattern in C# Question QUESTION: I was researching on the singleton pattern for C# I found this example from the msdn website. public sealed class Singleton { private static readonly Singleton instance = new Singleton(); private Singleton(){} public static Singleton Instance { get { return instance;...
[ "c#", "singleton" ]
1
7
2,953
5
0
2011-06-08T11:34:56.970000
2011-06-08T11:37:53.690000
6,278,095
6,278,377
Git Remote branches
I currently have Git setup with a central bare repository which is accessed by two developers via remote repositories. I've hit on a problem when I've created a branch and then tried to push that branch from a remote repository to the central bare respository, similiar to that in this post. I've read that tracking bran...
First of all: you won't need an own repo for each version of your software. If you release, create a tag and that's all you need. Referencing this tag, you can always go back to the released version. If you have a central repo where each of your two developers shall be allowed to push to, then you'll have to make that ...
Git Remote branches I currently have Git setup with a central bare repository which is accessed by two developers via remote repositories. I've hit on a problem when I've created a branch and then tried to push that branch from a remote repository to the central bare respository, similiar to that in this post. I've rea...
TITLE: Git Remote branches QUESTION: I currently have Git setup with a central bare repository which is accessed by two developers via remote repositories. I've hit on a problem when I've created a branch and then tried to push that branch from a remote repository to the central bare respository, similiar to that in t...
[ "git", "branch", "remote-branch" ]
1
1
247
1
0
2011-06-08T11:35:25.083000
2011-06-08T12:01:51.503000
6,278,101
6,278,355
How to show the vertical data horizentally through sql
my table has two column columnname and data i issue a simple sql like select * from mytable then data is showing like colname data ------------------- ----------- JID 41185 WID 0 AccountReference LH169 OEReference Ari002 InvoiceNumber 0 but i want to display data in different way like JID WID AccountReference OEReferen...
SELECT JID,WID,AccountReference,OEReference,InvoiceNumber FROM ( SELECT colname, data FROM YourTableName ) p PIVOT ( Max(data) FOR colname IN ([JID],[WID],[AccountReference],[OEReference],[InvoiceNumber]) ) AS pvt you can try below links. contains tutorials for the usage of Pivot. Link1 Link2
How to show the vertical data horizentally through sql my table has two column columnname and data i issue a simple sql like select * from mytable then data is showing like colname data ------------------- ----------- JID 41185 WID 0 AccountReference LH169 OEReference Ari002 InvoiceNumber 0 but i want to display data i...
TITLE: How to show the vertical data horizentally through sql QUESTION: my table has two column columnname and data i issue a simple sql like select * from mytable then data is showing like colname data ------------------- ----------- JID 41185 WID 0 AccountReference LH169 OEReference Ari002 InvoiceNumber 0 but i want...
[ "sql", "sql-server", "sql-server-2005", "t-sql", "sql-server-2008" ]
2
3
2,708
4
0
2011-06-08T11:36:14.563000
2011-06-08T12:00:11.303000
6,278,102
6,278,175
What are the valid Java @WebMethod return types?
I am writing a WebService using Java. Now I have a @WebMethod that is supposed to return some data, and I am not sure what format to use. I have seen that in other languages, there are certain restrictions on @WebMethod return types - is this the same for Java? When I tried to return a DOM Document containing XML, I go...
When I was implementing JAX-WS web services, all my return types were annotated with JAXB annotations (@XmlElement,...), and they also were Serializable. EDIT: which means just any type will not work, and you will have to create wrappers around structures you want to return.
What are the valid Java @WebMethod return types? I am writing a WebService using Java. Now I have a @WebMethod that is supposed to return some data, and I am not sure what format to use. I have seen that in other languages, there are certain restrictions on @WebMethod return types - is this the same for Java? When I tr...
TITLE: What are the valid Java @WebMethod return types? QUESTION: I am writing a WebService using Java. Now I have a @WebMethod that is supposed to return some data, and I am not sure what format to use. I have seen that in other languages, there are certain restrictions on @WebMethod return types - is this the same f...
[ "java", "web-services", "webmethod" ]
1
2
2,298
1
0
2011-06-08T11:36:15.483000
2011-06-08T11:42:36.673000
6,278,115
6,278,190
Sql queries not 'reporting' back until all queries have finish executing
I'm running a set of sql queries and they are not reporting the row affect until all the queries have ran. Is there anyway i can get incremental feedback. Example: DECLARE @HowManyLastTime int SET @HowManyLastTime = 1 WHILE @HowManyLastTime <> 2400000 BEGIN SET @HowManyLastTime = @HowManyLastTime +1 print(@HowManyLa...
To flush recordcounts and other data to the client, you'll want to use RaisError with NOWAIT. Related questions and links: PRINT statement in T-SQL http://weblogs.sqlteam.com/mladenp/archive/2007/10/01/SQL-Server-Notify-client-of-progress-in-a-long-running.aspx In SSMS this will work as expected. With other clients, yo...
Sql queries not 'reporting' back until all queries have finish executing I'm running a set of sql queries and they are not reporting the row affect until all the queries have ran. Is there anyway i can get incremental feedback. Example: DECLARE @HowManyLastTime int SET @HowManyLastTime = 1 WHILE @HowManyLastTime <> 2...
TITLE: Sql queries not 'reporting' back until all queries have finish executing QUESTION: I'm running a set of sql queries and they are not reporting the row affect until all the queries have ran. Is there anyway i can get incremental feedback. Example: DECLARE @HowManyLastTime int SET @HowManyLastTime = 1 WHILE @Ho...
[ "sql", "sql-server" ]
2
2
879
2
0
2011-06-08T11:37:41.957000
2011-06-08T11:43:20.333000
6,278,135
6,289,405
I want to use the question mark in the auto-generated path aliases
I want to use the question mark the automatically generated path aliases, but when I write the question mark, it is changed to %3f. How can I fix this?
The URL you are trying to use appears to be used as a proper delimiter of path vs. query string. You should not attempt to add the question mark yourself, but instead implement the section after the question mark as query string. For example: l(t('My Link'), 'campaign/resurfacing-seminar', array( 'query' => array( 'cam...
I want to use the question mark in the auto-generated path aliases I want to use the question mark the automatically generated path aliases, but when I write the question mark, it is changed to %3f. How can I fix this?
TITLE: I want to use the question mark in the auto-generated path aliases QUESTION: I want to use the question mark the automatically generated path aliases, but when I write the question mark, it is changed to %3f. How can I fix this? ANSWER: The URL you are trying to use appears to be used as a proper delimiter of ...
[ "drupal", "drupal-path-aliases" ]
0
3
1,510
3
0
2011-06-08T11:39:14.107000
2011-06-09T07:22:26.543000
6,278,143
6,278,294
How do I assign the result of a regex match to a new variable, in a single line?
I want to match and assign to a variable in just one line: my $abspath='/var/ftp/path/to/file.txt'; $abspath =~ #/var/ftp/(.*)$#; my $relpath=$1; I'm sure it must be easy.
my ($relpath) = $abspath =~ m#/var/ftp/(.*)$#; In list context the match returns the values of the groups.
How do I assign the result of a regex match to a new variable, in a single line? I want to match and assign to a variable in just one line: my $abspath='/var/ftp/path/to/file.txt'; $abspath =~ #/var/ftp/(.*)$#; my $relpath=$1; I'm sure it must be easy.
TITLE: How do I assign the result of a regex match to a new variable, in a single line? QUESTION: I want to match and assign to a variable in just one line: my $abspath='/var/ftp/path/to/file.txt'; $abspath =~ #/var/ftp/(.*)$#; my $relpath=$1; I'm sure it must be easy. ANSWER: my ($relpath) = $abspath =~ m#/var/ftp/...
[ "regex", "perl" ]
11
18
14,043
5
0
2011-06-08T11:39:47.803000
2011-06-08T11:53:35.427000
6,278,144
6,278,290
How to find unix/linux sytem info using java or shell script?
How to find unix/linux system info like OS version, RAM, no. of processors, hard disk, memory dedicated to a particular process, memory utilization of java using java or shell scripts.
To find the version of the kernel, use uname -r in a shell script. All kinds of information regarding the hardware can be retrieved from the files in /proc. /proc/cpuinfo contains information about the CPU's, including their number. /proc/meminfo shows the total physical memory, free memory, etc. If you only want to fe...
How to find unix/linux sytem info using java or shell script? How to find unix/linux system info like OS version, RAM, no. of processors, hard disk, memory dedicated to a particular process, memory utilization of java using java or shell scripts.
TITLE: How to find unix/linux sytem info using java or shell script? QUESTION: How to find unix/linux system info like OS version, RAM, no. of processors, hard disk, memory dedicated to a particular process, memory utilization of java using java or shell scripts. ANSWER: To find the version of the kernel, use uname -...
[ "java", "linux", "unix", "sh", "system-information" ]
1
1
1,125
2
0
2011-06-08T11:40:05.097000
2011-06-08T11:53:29.417000
6,278,146
6,278,197
Array initialization problem
I have the following code: var intrebari = new Array(); var i = 0; intrebari[i]['enunt'] = 'test'; alert(intrebari[i]['enunt']); The problem is that when I run it it says that intrebari is undefined. Why?
var intrebari = new Array(); var i = 0; intrebari[i] = new Object() intrebari[i]['enunt'] = 'test'; alert(intrebari[i]['enunt']);
Array initialization problem I have the following code: var intrebari = new Array(); var i = 0; intrebari[i]['enunt'] = 'test'; alert(intrebari[i]['enunt']); The problem is that when I run it it says that intrebari is undefined. Why?
TITLE: Array initialization problem QUESTION: I have the following code: var intrebari = new Array(); var i = 0; intrebari[i]['enunt'] = 'test'; alert(intrebari[i]['enunt']); The problem is that when I run it it says that intrebari is undefined. Why? ANSWER: var intrebari = new Array(); var i = 0; intrebari[i] = new ...
[ "javascript" ]
0
1
81
3
0
2011-06-08T11:40:16.560000
2011-06-08T11:44:13.660000
6,278,149
6,278,225
Design decision conflict for methods in a class
Ok I will try to explain this as much as possible. I have a class, say MyLib, the methods of which will be used by another class, say Consumer class. There is a public method called Navigate() in MyLib, which will be used by Consumer. This method sort of provides a level of abstraction for Consumer, as it can provide d...
Have multiple public versions of the method. That will make way more sense to consumers looking at this through intellisense.
Design decision conflict for methods in a class Ok I will try to explain this as much as possible. I have a class, say MyLib, the methods of which will be used by another class, say Consumer class. There is a public method called Navigate() in MyLib, which will be used by Consumer. This method sort of provides a level ...
TITLE: Design decision conflict for methods in a class QUESTION: Ok I will try to explain this as much as possible. I have a class, say MyLib, the methods of which will be used by another class, say Consumer class. There is a public method called Navigate() in MyLib, which will be used by Consumer. This method sort of...
[ "design-patterns", "polymorphism", "overloading" ]
0
1
78
3
0
2011-06-08T11:40:36.077000
2011-06-08T11:46:26.070000
6,278,159
6,278,207
Find out if PNG is 8 or 24?
Is there a way to find out if a PNG is the 8 or 24 type? Ive tried with windows, fireworks and photoshop but I can't figure this out. Thanks
Open it in Photoshop and check what's written on the top bar. If it says "index", then it has been saved as 8-bit PNG, if it says "RGB/8" then your PNG is a 32-bit one. Alternatively you can open Image/Mode menu and for an 8-bit one it would be "Indexed color", while for a 32-bit one - "RGB color". Another really quick...
Find out if PNG is 8 or 24? Is there a way to find out if a PNG is the 8 or 24 type? Ive tried with windows, fireworks and photoshop but I can't figure this out. Thanks
TITLE: Find out if PNG is 8 or 24? QUESTION: Is there a way to find out if a PNG is the 8 or 24 type? Ive tried with windows, fireworks and photoshop but I can't figure this out. Thanks ANSWER: Open it in Photoshop and check what's written on the top bar. If it says "index", then it has been saved as 8-bit PNG, if it...
[ "image", "encoding", "png", "bit" ]
11
11
26,580
5
0
2011-06-08T11:41:12.687000
2011-06-08T11:44:48.103000
6,278,192
6,278,271
string.Format ignores NumberFormatInfo?
I output data from a process to a csv. I store intermediate results in a data class, which also has methods to output the data to a string so it can be written to a file. Class DataClass { // the actual data public double Value1 { get; set; } public double Value2 { get; set; } public double Value3 { get; set; } // re...
You have to use the N format specifier for Format to use the NumberFormatInfo. Try this return string.Format(nfi, "{0:N}\t{1:N}\t{2:N}", Value1, Value2, Value3, );
string.Format ignores NumberFormatInfo? I output data from a process to a csv. I store intermediate results in a data class, which also has methods to output the data to a string so it can be written to a file. Class DataClass { // the actual data public double Value1 { get; set; } public double Value2 { get; set; } p...
TITLE: string.Format ignores NumberFormatInfo? QUESTION: I output data from a process to a csv. I store intermediate results in a data class, which also has methods to output the data to a string so it can be written to a file. Class DataClass { // the actual data public double Value1 { get; set; } public double Valu...
[ "c#", ".net" ]
6
12
4,471
1
0
2011-06-08T11:43:27.683000
2011-06-08T11:51:03.050000
6,278,195
6,278,330
Call Java Cryptography Architecture (JCA) from PL/SQL
Is it possible to access (call) Java Cryptography Architecture (JCA) classes from PL/SQL? For example, when stored procedure are running. P.S. The big task is to validate digital signature (RSA) in PL/SQL.
First of all, have you looked at the DBMS_CRYPTO package in Oracle? If that supports the algorithm(s) you need, I would suggest using it instead of calling Java. But yes, if necessary, you should be able to call JCA from PL/SQL. It looks to me like this is part of the core JDK and therefore should be included in the Or...
Call Java Cryptography Architecture (JCA) from PL/SQL Is it possible to access (call) Java Cryptography Architecture (JCA) classes from PL/SQL? For example, when stored procedure are running. P.S. The big task is to validate digital signature (RSA) in PL/SQL.
TITLE: Call Java Cryptography Architecture (JCA) from PL/SQL QUESTION: Is it possible to access (call) Java Cryptography Architecture (JCA) classes from PL/SQL? For example, when stored procedure are running. P.S. The big task is to validate digital signature (RSA) in PL/SQL. ANSWER: First of all, have you looked at ...
[ "java", "oracle", "plsql" ]
1
1
523
1
0
2011-06-08T11:44:09.087000
2011-06-08T11:57:43.973000
6,278,206
6,278,285
Jquery - Grouping Repetitive Function into a Class Question
I am trying to figure out a way to create a class to group together a set of effects that performs the same effects but just different color. I am a procedural guy and OOP is something I am still learning and need some guide. I am trying to create a 'tag' lookalike shape using 'a' tag that changes the font and backgrou...
Instead of binding this to a specific class, you can use a custom attribute(data-startColor, data-endColor) with the value of the start and end color, then bind a single block of this code to all elements that match $("[data-startColor]"), and access the custom colors by $(this).attr("data-startColor") and $(this).attr...
Jquery - Grouping Repetitive Function into a Class Question I am trying to figure out a way to create a class to group together a set of effects that performs the same effects but just different color. I am a procedural guy and OOP is something I am still learning and need some guide. I am trying to create a 'tag' look...
TITLE: Jquery - Grouping Repetitive Function into a Class Question QUESTION: I am trying to figure out a way to create a class to group together a set of effects that performs the same effects but just different color. I am a procedural guy and OOP is something I am still learning and need some guide. I am trying to c...
[ "jquery", "class" ]
0
2
116
1
0
2011-06-08T11:44:36.980000
2011-06-08T11:52:53.083000
6,278,216
6,278,356
how to change provider Gps to Network for geo location?
I am working on geolocation application in that I want to use Gps provider as it giving accurate location than network provider.But sometimes indoor the gps signal is not reaching then I want to use network provider.Whenever Gps signal is not reaching that time I want to use network provider.How can I switch between th...
If you have a button that switches a variable on or off, you can switch between providers like this (Sorry that it's pseudo code). if (GPSisOff){ LocationProvider locationProvider = LocationManager.NETWORK_PROVIDER; } else { LocationProvider locationProvider = LocationManager.GPS_PROVIDER; } Also it depends on whether ...
how to change provider Gps to Network for geo location? I am working on geolocation application in that I want to use Gps provider as it giving accurate location than network provider.But sometimes indoor the gps signal is not reaching then I want to use network provider.Whenever Gps signal is not reaching that time I ...
TITLE: how to change provider Gps to Network for geo location? QUESTION: I am working on geolocation application in that I want to use Gps provider as it giving accurate location than network provider.But sometimes indoor the gps signal is not reaching then I want to use network provider.Whenever Gps signal is not rea...
[ "android", "geolocation" ]
0
0
2,246
3
0
2011-06-08T11:45:31.720000
2011-06-08T12:00:14.940000
6,278,219
6,278,391
How to create runtime visible variables using GCC
With the Green Hill compiler it is possible to create variables in the linker that is visible at runtime. In the linker: __ghs_ramstart = MEMADDR(dram_memory); In the code: if (__ghs_ramstart == 0) {do something} Is it possible to do the same type of thing when using gcc?
Yes, you can do that using GNU ld linker scripting. http://sourceware.org/binutils/docs-2.21/ld/Scripts.html#Scripts You can defined symbols in scripts that are accessible from gcc. I've also used scripts to create data tables (an array of addresses, for example). In the linker script, you can say something like __ghs_...
How to create runtime visible variables using GCC With the Green Hill compiler it is possible to create variables in the linker that is visible at runtime. In the linker: __ghs_ramstart = MEMADDR(dram_memory); In the code: if (__ghs_ramstart == 0) {do something} Is it possible to do the same type of thing when using gc...
TITLE: How to create runtime visible variables using GCC QUESTION: With the Green Hill compiler it is possible to create variables in the linker that is visible at runtime. In the linker: __ghs_ramstart = MEMADDR(dram_memory); In the code: if (__ghs_ramstart == 0) {do something} Is it possible to do the same type of t...
[ "gcc", "embedded" ]
1
3
307
2
0
2011-06-08T11:45:44.847000
2011-06-08T12:03:34.720000
6,278,239
6,278,319
WIX: Running a custom action based on the success of previously executed custom action
I have the need to restart the Windows Explorer process during the installation. Currently we force the user to reboot to ensure that the Explorer process is really restarted, but I would like to be a bit more flexible. I have a restartexplorer executable which I can call during the installation. What I would like to d...
You can create VB script custom action which will do the following: Run RestartExplorer.exe If it is failed set some global property (For example EXPLORER_RESTART_FAILED=1) Then use the ShaduleReboot if EXPLORER_RESTART_FAILED is 1.
WIX: Running a custom action based on the success of previously executed custom action I have the need to restart the Windows Explorer process during the installation. Currently we force the user to reboot to ensure that the Explorer process is really restarted, but I would like to be a bit more flexible. I have a rest...
TITLE: WIX: Running a custom action based on the success of previously executed custom action QUESTION: I have the need to restart the Windows Explorer process during the installation. Currently we force the user to reboot to ensure that the Explorer process is really restarted, but I would like to be a bit more flexi...
[ "installation", "wix", "conditional-statements", "wix3", "custom-action" ]
2
1
918
1
0
2011-06-08T11:48:00.193000
2011-06-08T11:56:37.077000
6,278,261
6,278,351
run a code for all rows of table jQuery
I am using this code to hide the element in sixth column of a table on a condition (I mean if text of span fourth column of table is "0"). But this code just works for first row of table. How can i do this function for all rows of target table? if ($('#table tr td:eq(4) > span').text() == "0") { $('#table tr td:eq(6) >...
If you could post the full HTML structure of tr then you'd get more optimized solutions. Looking at your existing code you could do something like this: $('#table tr').each(function() { var text = $('td:eq(4) > span', this).text(); $('td:eq(6) >.PrintReport', this).toggle(text!= '0'); }); Notice that inside the loop I...
run a code for all rows of table jQuery I am using this code to hide the element in sixth column of a table on a condition (I mean if text of span fourth column of table is "0"). But this code just works for first row of table. How can i do this function for all rows of target table? if ($('#table tr td:eq(4) > span')....
TITLE: run a code for all rows of table jQuery QUESTION: I am using this code to hide the element in sixth column of a table on a condition (I mean if text of span fourth column of table is "0"). But this code just works for first row of table. How can i do this function for all rows of target table? if ($('#table tr ...
[ "jquery", "jquery-selectors" ]
1
4
1,367
5
0
2011-06-08T11:50:21.347000
2011-06-08T11:59:48.497000
6,278,264
6,278,421
matlab - removing elements with low frequency in an array
If you have a MATLAB array such as the below: A = [1,1,1,1,2,2,2,2,3,3,3,4,4,5] I want to be able to filter this array so that elements which have a low frequency are removed. In other words, is there an easy way to remove elements in the array which have a certain low frequency for example <= than 2? In this case: The...
I'd probably do it somehow like this (hope the syntax is good:)) function array= ClearElementsWithLowOccurence(array,minimalFrequency) elements = unique(array); indecesToRemove = []; for i = 0:length(elements) indeces = find(array==elements(i)); if (length(indeces) < minimalFrequency) indecesToRemove = [indecesToRemove...
matlab - removing elements with low frequency in an array If you have a MATLAB array such as the below: A = [1,1,1,1,2,2,2,2,3,3,3,4,4,5] I want to be able to filter this array so that elements which have a low frequency are removed. In other words, is there an easy way to remove elements in the array which have a cert...
TITLE: matlab - removing elements with low frequency in an array QUESTION: If you have a MATLAB array such as the below: A = [1,1,1,1,2,2,2,2,3,3,3,4,4,5] I want to be able to filter this array so that elements which have a low frequency are removed. In other words, is there an easy way to remove elements in the array...
[ "arrays", "matlab", "frequency" ]
0
3
842
3
0
2011-06-08T11:50:32.067000
2011-06-08T12:06:13.533000
6,278,270
6,278,461
Matlab: How to generate a 4x1 matrix of random variables, assuming a 4x4 correlation matrix?
I start with 4 time series, labelled A, B, C, D. I generate the following: A 4x1 matrix of means. A 4x1 matrix of standard deviations. A 4x4 correlation matrix, by taking 30 samples from each time series. What is the Matlab code to generate a 4x1 matrix of random variables, keeping the correlations between the time ser...
You need just the means vector (call it m ) and the covariance matrix (call it C ). Note that you can get the covariance matrix from the correlation using the equation C = R - m*m' (or just compute it directly by computing the correlation of the sequences after subtracting their mean). Then, to get a vector with the co...
Matlab: How to generate a 4x1 matrix of random variables, assuming a 4x4 correlation matrix? I start with 4 time series, labelled A, B, C, D. I generate the following: A 4x1 matrix of means. A 4x1 matrix of standard deviations. A 4x4 correlation matrix, by taking 30 samples from each time series. What is the Matlab cod...
TITLE: Matlab: How to generate a 4x1 matrix of random variables, assuming a 4x4 correlation matrix? QUESTION: I start with 4 time series, labelled A, B, C, D. I generate the following: A 4x1 matrix of means. A 4x1 matrix of standard deviations. A 4x4 correlation matrix, by taking 30 samples from each time series. What...
[ "matlab", "statistics", "probability", "correlation", "montecarlo" ]
3
5
2,007
2
0
2011-06-08T11:51:01.913000
2011-06-08T12:09:38.883000
6,278,291
6,278,342
NSMutableDictionary content release?
I have the following code in my class method for test: NSMutableDictionary * temp = [[NSMutableDictionary alloc] init]; [temp setObject:@"4" forKey:@"Interval"]; interval = [temp objectForKey:@"Interval"]; [temp release]; interval is my instance variable: NSString * interval; and getter method for it(it is not property...
@"4" is a literal/constant NSString object, and literal/constant NSStrings are never deallocated — this is why you can still reference that string even though it should theoretically have been released (assuming the dictionary was the only owner). This doesn’t mean you shouldn’t follow proper memory management rules, o...
NSMutableDictionary content release? I have the following code in my class method for test: NSMutableDictionary * temp = [[NSMutableDictionary alloc] init]; [temp setObject:@"4" forKey:@"Interval"]; interval = [temp objectForKey:@"Interval"]; [temp release]; interval is my instance variable: NSString * interval; and ge...
TITLE: NSMutableDictionary content release? QUESTION: I have the following code in my class method for test: NSMutableDictionary * temp = [[NSMutableDictionary alloc] init]; [temp setObject:@"4" forKey:@"Interval"]; interval = [temp objectForKey:@"Interval"]; [temp release]; interval is my instance variable: NSString ...
[ "objective-c", "memory-management" ]
6
8
125
1
0
2011-06-08T11:53:31.823000
2011-06-08T11:58:44.173000
6,278,296
6,278,312
Extract a single (unsigned) integer from a string
I want to extract the digits from a string that contains numbers and letters like: "In My Cart: 11 items" I want to extract the number 11.
$str = 'In My Cart: 11 12 items'; preg_match_all('!\d+!', $str, $matches); print_r($matches);
Extract a single (unsigned) integer from a string I want to extract the digits from a string that contains numbers and letters like: "In My Cart: 11 items" I want to extract the number 11.
TITLE: Extract a single (unsigned) integer from a string QUESTION: I want to extract the digits from a string that contains numbers and letters like: "In My Cart: 11 items" I want to extract the number 11. ANSWER: $str = 'In My Cart: 11 12 items'; preg_match_all('!\d+!', $str, $matches); print_r($matches);
[ "php", "string", "integer", "text-extraction" ]
400
408
612,887
23
0
2011-06-08T11:53:56.160000
2011-06-08T11:56:00.460000
6,278,316
6,278,398
How to store array of hashes in redis
I want to store array of hashes in redis, what is best way to code it?
The only way AFAIK is to de-reference them. Say you have an array of 2 hashes like: {foo: 'bar', baz: 'qux'}. You'd store them separately, and then create a SET that references them all: HMSET myarr:0 foo bar baz qux SADD myarr myarr:0 HMSET myarr:1 foo bar baz qux SADD myarr myarr:1 Then you can retrieve them all by q...
How to store array of hashes in redis I want to store array of hashes in redis, what is best way to code it?
TITLE: How to store array of hashes in redis QUESTION: I want to store array of hashes in redis, what is best way to code it? ANSWER: The only way AFAIK is to de-reference them. Say you have an array of 2 hashes like: {foo: 'bar', baz: 'qux'}. You'd store them separately, and then create a SET that references them al...
[ "node.js", "redis", "key-value-store" ]
19
39
17,623
2
0
2011-06-08T11:56:12.693000
2011-06-08T12:04:02.550000
6,278,358
6,278,439
Why am I getting a BeanCreationException when trying to initialise a bean using the constructor-arg element
I'm trying create an immutable object and initialise it from xml config file in spring. But I'm getting a BeanCreationException and I haven't been able to figure out why. The exception states that it can't find an appropriate constructor with the following message: "Could not resolve matching constructor (hint: specify...
The docs for the attribute "name" says: Note: This requires debug symbols to be stored in the class file in order to introspect argument names! So maybe you don't have the debug symbols enabled?
Why am I getting a BeanCreationException when trying to initialise a bean using the constructor-arg element I'm trying create an immutable object and initialise it from xml config file in spring. But I'm getting a BeanCreationException and I haven't been able to figure out why. The exception states that it can't find a...
TITLE: Why am I getting a BeanCreationException when trying to initialise a bean using the constructor-arg element QUESTION: I'm trying create an immutable object and initialise it from xml config file in spring. But I'm getting a BeanCreationException and I haven't been able to figure out why. The exception states th...
[ "java", "spring" ]
3
7
14,351
2
0
2011-06-08T12:00:22.680000
2011-06-08T12:07:47.887000
6,278,369
6,278,417
get full path name using list comprehension in python
can I do something like this(actually the it doesn't work) flist = [dirpath + f for f for fnames for dirpath, dirnames, fnames in os.walk('/home/user')] thanks!
fnames doesn't exist yet. Swap the loops. flist = [dirpath + f for dirpath, dirnames, fnames in os.walk('/home/user') for f in fnames]
get full path name using list comprehension in python can I do something like this(actually the it doesn't work) flist = [dirpath + f for f for fnames for dirpath, dirnames, fnames in os.walk('/home/user')] thanks!
TITLE: get full path name using list comprehension in python QUESTION: can I do something like this(actually the it doesn't work) flist = [dirpath + f for f for fnames for dirpath, dirnames, fnames in os.walk('/home/user')] thanks! ANSWER: fnames doesn't exist yet. Swap the loops. flist = [dirpath + f for dirpath, di...
[ "python", "python-3.x" ]
1
3
2,607
5
0
2011-06-08T12:01:19.243000
2011-06-08T12:05:47.997000
6,278,372
6,278,415
Invoking action method using Java script in asp.net MVC
I have a form, I want to check the username is availability. I that I have html textbox, in Onclcik I'm calling java script function. The script has to call the Action methods in controller. Based upon the username availability it has to return either 1 or 0. I have tried Json. But its is showing "Microsoft JScript run...
If you get that message it means you're trying to use jQuery but you haven't included the library. You can use Google's CDN. I guess you've used Ajax to call. Something like this: $.ajax({ type: 'POST', url: '<%=Url.Action("Your Action", "Your Controller")%>', data: { userName: $('#UserName').val(), password: $('#Passw...
Invoking action method using Java script in asp.net MVC I have a form, I want to check the username is availability. I that I have html textbox, in Onclcik I'm calling java script function. The script has to call the Action methods in controller. Based upon the username availability it has to return either 1 or 0. I ha...
TITLE: Invoking action method using Java script in asp.net MVC QUESTION: I have a form, I want to check the username is availability. I that I have html textbox, in Onclcik I'm calling java script function. The script has to call the Action methods in controller. Based upon the username availability it has to return e...
[ "asp.net-mvc", "json" ]
0
2
413
2
0
2011-06-08T12:01:27.217000
2011-06-08T12:05:39.633000
6,278,390
6,278,431
Calling Connection.Close/Dispose in finaliser
I've always called Connection.Close in the finally block, however I learned today you aren't supposed to do that: Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only release unmanaged resources that your class owns...
No, you don't need to call Close explicitly if you are using a Using block. Here's how I would write it: Using conn As New SqlConnection("SOME CONNECTION STRING") Using cmd = conn.CreateCommand() conn.Open() cmd.CommandText = "some sql command here" '... create and fill data table End Using End Using Also calling Clos...
Calling Connection.Close/Dispose in finaliser I've always called Connection.Close in the finally block, however I learned today you aren't supposed to do that: Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only re...
TITLE: Calling Connection.Close/Dispose in finaliser QUESTION: I've always called Connection.Close in the finally block, however I learned today you aren't supposed to do that: Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, ...
[ ".net", "ado.net", "garbage-collection", "connection", "database-connection" ]
3
5
1,058
2
0
2011-06-08T12:03:33.317000
2011-06-08T12:07:06.807000
6,278,394
6,278,435
Type to store time in C# and corresponding type in T-SQL
I would like to know how to store time in C# and T-SQL. I know that both of them provide a DateTime type but I just need to store a time. For instance: var startTime = 9PM; var endTime = 10PM; And then store/retrieve this values from a database. Thanks in advance. Francesco
C# Whether to use a DateTime or TimeSpan type in C# to store 9 PM is up to taste. Personally, I'd use DateTime, leaving the date component empty, since that's semantically closer to what you want. (A TimeSpan is designed to hold time intervals, such as "21 hours".) The documentation supports both options. This is from ...
Type to store time in C# and corresponding type in T-SQL I would like to know how to store time in C# and T-SQL. I know that both of them provide a DateTime type but I just need to store a time. For instance: var startTime = 9PM; var endTime = 10PM; And then store/retrieve this values from a database. Thanks in advance...
TITLE: Type to store time in C# and corresponding type in T-SQL QUESTION: I would like to know how to store time in C# and T-SQL. I know that both of them provide a DateTime type but I just need to store a time. For instance: var startTime = 9PM; var endTime = 10PM; And then store/retrieve this values from a database....
[ "c#", "t-sql", "time" ]
10
10
10,446
4
0
2011-06-08T12:03:40.413000
2011-06-08T12:07:28.087000
6,278,404
6,278,449
.replace() regex question
I can have a string that looks like this as an example: sometext somemore text endof text... I have the following Javascript that matches the above string, and replaces it with:): subject = subject.replace(/ /, ':)'); The catch is it's not greedy... it matches both occurrences rather then just one. How would I change t...
you need to make it non greedy by adding a question mark? // Greedy quantifiers String match = find("A.*c", "AbcAbc"); // AbcAbc match = find("A.+", "AbcAbc"); // AbcAbc // Nongreedy quantifiers match = find("A.*?c", "AbcAbc"); // Abc match = find("A.+?", "AbcAbc"); // Abc So in your case, something like subject = sub...
.replace() regex question I can have a string that looks like this as an example: sometext somemore text endof text... I have the following Javascript that matches the above string, and replaces it with:): subject = subject.replace(/ /, ':)'); The catch is it's not greedy... it matches both occurrences rather then just...
TITLE: .replace() regex question QUESTION: I can have a string that looks like this as an example: sometext somemore text endof text... I have the following Javascript that matches the above string, and replaces it with:): subject = subject.replace(/ /, ':)'); The catch is it's not greedy... it matches both occurrence...
[ "javascript", "regex", "replace" ]
1
3
1,403
3
0
2011-06-08T12:04:39.647000
2011-06-08T12:08:33.500000
6,278,405
6,278,501
Connecting and printing to a printer in Java
Is there an easy way in Java to do the following? Connect to a printer (will be a local printer and the only printer connected to the machine). Print pages that are 2 pages in 2 different printer trays. Get the current print queue count, i.e. I have 100 items to print and 34 have been currently printed, the printer que...
Some quick hints: print from java: see A Basic Printing Program status of printing job: you might be able to get something useful by using a PrintJobListener: Implementations of this listener interface should be attached to a DocPrintJob to monitor the status of the printer job. These callback methods may be invoked on...
Connecting and printing to a printer in Java Is there an easy way in Java to do the following? Connect to a printer (will be a local printer and the only printer connected to the machine). Print pages that are 2 pages in 2 different printer trays. Get the current print queue count, i.e. I have 100 items to print and 34...
TITLE: Connecting and printing to a printer in Java QUESTION: Is there an easy way in Java to do the following? Connect to a printer (will be a local printer and the only printer connected to the machine). Print pages that are 2 pages in 2 different printer trays. Get the current print queue count, i.e. I have 100 ite...
[ "java", "printing" ]
11
10
60,381
4
0
2011-06-08T12:04:43.627000
2011-06-08T12:12:47.367000
6,278,413
6,278,456
Is it wise to use PHP `mysql_data_seek` and code rather than SQL `LIMIT` to limit results for pagination?
Following a conversation at work about methods of pagination and only getting the data you need for a particular page. Is it better to use PHP mysql_data_seek() on a returned dataset and use code to limit or use SQL LIMIT to limit results for pagination? For example we have a built-in function for paginating results bu...
An additional COUNT query or SQL_CALC_FOUND_ROWS combination is more effective then loading your entire table. Imagine if you have billions of rows! It will eat bandwith. Extremely slow on larger sets. It isn't effective PHP-wise either.
Is it wise to use PHP `mysql_data_seek` and code rather than SQL `LIMIT` to limit results for pagination? Following a conversation at work about methods of pagination and only getting the data you need for a particular page. Is it better to use PHP mysql_data_seek() on a returned dataset and use code to limit or use SQ...
TITLE: Is it wise to use PHP `mysql_data_seek` and code rather than SQL `LIMIT` to limit results for pagination? QUESTION: Following a conversation at work about methods of pagination and only getting the data you need for a particular page. Is it better to use PHP mysql_data_seek() on a returned dataset and use code ...
[ "php", "mysql", "pagination" ]
3
4
959
4
0
2011-06-08T12:05:35.190000
2011-06-08T12:08:57.980000
6,278,423
6,278,434
jquery select element by name attribute
I have an input with the name attribute: how can I select this element? I tried $("input[name=data[foo][bar]]") but in vein.
Add quotes to the attribute value, otherwise you get conflicting square brackets and a parse error: $("input[name='data[foo][bar]']")
jquery select element by name attribute I have an input with the name attribute: how can I select this element? I tried $("input[name=data[foo][bar]]") but in vein.
TITLE: jquery select element by name attribute QUESTION: I have an input with the name attribute: how can I select this element? I tried $("input[name=data[foo][bar]]") but in vein. ANSWER: Add quotes to the attribute value, otherwise you get conflicting square brackets and a parse error: $("input[name='data[foo][bar...
[ "javascript", "jquery", "jquery-selectors" ]
0
11
3,853
4
0
2011-06-08T12:06:17.763000
2011-06-08T12:07:22.453000
6,278,445
6,279,938
TTreeView drawing error when deactivating a form
I have found what appears to be a bug related to TTreeView. Take a form containing a TTreeView with HideSelection set to True. Make the tree view multi-select and select multiple items in the tree view. Show another form so that your app has two forms. Give the tree view the focus and then click in the other form. The ...
The solution seems to be to respond to NM_SETFOCUS and NM_KILLFOCUS notifications by invalidating selected nodes. You can modify TCustomTreeView.CNNotify directly or you can write a new TCustomTreeView descendant. Here is a quick hack only to show the missing code: type TTreeView = class(ComCtrls.TTreeView) private pro...
TTreeView drawing error when deactivating a form I have found what appears to be a bug related to TTreeView. Take a form containing a TTreeView with HideSelection set to True. Make the tree view multi-select and select multiple items in the tree view. Show another form so that your app has two forms. Give the tree view...
TITLE: TTreeView drawing error when deactivating a form QUESTION: I have found what appears to be a bug related to TTreeView. Take a form containing a TTreeView with HideSelection set to True. Make the tree view multi-select and select multiple items in the tree view. Show another form so that your app has two forms. ...
[ "delphi", "delphi-2010" ]
7
9
406
1
0
2011-06-08T12:08:10.290000
2011-06-08T14:01:56.643000
6,278,448
6,278,493
File operations [.txt normal file] in javascript?
Possible Duplicate: How to read and write into file using JavaScript javascript functions for file manipulations like reading & writing? Im looking for word by word file reading & appending each word in an array of strings.
JavaScript is a client-side language, and as such it runs on the client of the user viewing your site and running your script. You can't access server files directly from JavaScript, and can't access client files at all. However, HTML5 introduces some storage options if that can fit your needs.
File operations [.txt normal file] in javascript? Possible Duplicate: How to read and write into file using JavaScript javascript functions for file manipulations like reading & writing? Im looking for word by word file reading & appending each word in an array of strings.
TITLE: File operations [.txt normal file] in javascript? QUESTION: Possible Duplicate: How to read and write into file using JavaScript javascript functions for file manipulations like reading & writing? Im looking for word by word file reading & appending each word in an array of strings. ANSWER: JavaScript is a cli...
[ "javascript" ]
0
0
1,058
2
0
2011-06-08T12:08:33.003000
2011-06-08T12:12:15.657000
6,278,462
6,287,180
Filtering hierarchies in MDX WITH clause
By using the answer of MDX on multiple hierarchical dimensions I have the following MDX query: with member L1Y1 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calendar Date].[Year].&[2010], [Measures].[x]) select ([Dim Attribute].[Parent Code].&[10000]) on 0, ({L1Y1}) on 1 from DS Now the problem is how to f...
How about: with member L1Y1 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calendar Date].[Year].&[2010], [Measures].[x]) member S2 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calendar Date].[Season].&[2], [Measures].[x]) member M7 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calen...
Filtering hierarchies in MDX WITH clause By using the answer of MDX on multiple hierarchical dimensions I have the following MDX query: with member L1Y1 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calendar Date].[Year].&[2010], [Measures].[x]) select ([Dim Attribute].[Parent Code].&[10000]) on 0, ({L1Y1})...
TITLE: Filtering hierarchies in MDX WITH clause QUESTION: By using the answer of MDX on multiple hierarchical dimensions I have the following MDX query: with member L1Y1 as ([Dim Location].[Hierarchy].[Center].&[1], [Dim Date].[Calendar Date].[Year].&[2010], [Measures].[x]) select ([Dim Attribute].[Parent Code].&[1000...
[ "ssas", "mdx", "olap" ]
0
1
3,359
2
0
2011-06-08T12:09:40.240000
2011-06-09T01:40:25.987000
6,278,522
6,280,179
Chain webkit animation
I would like to create a 'chained' animation that moves a div element on the screen to two different points on the screen, in two consecutive steps. So if my div starts at (0,0), I would like this div to animate and move towards (100,100) in 2 seconds. After it reaches the latter destination, it then animates again and...
I use jQuery and Modernizr, then a function like this: speed = 500; var vP = ""; var transitionEnd = "transitionEnd"; if ($.browser.webkit) { vP = "-webkit-"; transitionEnd = "webkitTransitionEnd"; } else if ($.browser.msie) { vP = "-ms-"; transitionEnd = "msTransitionEnd"; } else if ($.browser.mozilla) { vP = "-moz-"...
Chain webkit animation I would like to create a 'chained' animation that moves a div element on the screen to two different points on the screen, in two consecutive steps. So if my div starts at (0,0), I would like this div to animate and move towards (100,100) in 2 seconds. After it reaches the latter destination, it ...
TITLE: Chain webkit animation QUESTION: I would like to create a 'chained' animation that moves a div element on the screen to two different points on the screen, in two consecutive steps. So if my div starts at (0,0), I would like this div to animate and move towards (100,100) in 2 seconds. After it reaches the latte...
[ "jquery", "css", "webkit" ]
3
3
3,195
4
0
2011-06-08T12:14:01.347000
2011-06-08T14:16:54.057000
6,279,883
6,290,279
Clearing Html textbox value permanently using Jquery
I have a <%: Html.TextBoxFor(model=>model.UserName)%>. Here I'm checking wheather user name is available or not. If it's not available then I need to clear the TextBox. I used the query $("#UserName").val("");. But after the event completion again the text box getting the value. Can anyone help me? UPDATE: Additional J...
I got the answer for my problem. HTML code: <%: Html.TextBoxFor(model=>model.UserName,new { @onchange="CheckAvailability()" }) %> Javascript Code: function CheckAvailability() { var value; if (document.getElementById("UserName").value == "") { $("#usernamelookupresult").html(""); alert("Please Enter User Name"); } else...
Clearing Html textbox value permanently using Jquery I have a <%: Html.TextBoxFor(model=>model.UserName)%>. Here I'm checking wheather user name is available or not. If it's not available then I need to clear the TextBox. I used the query $("#UserName").val("");. But after the event completion again the text box gettin...
TITLE: Clearing Html textbox value permanently using Jquery QUESTION: I have a <%: Html.TextBoxFor(model=>model.UserName)%>. Here I'm checking wheather user name is available or not. If it's not available then I need to clear the TextBox. I used the query $("#UserName").val("");. But after the event completion again t...
[ "jquery", "asp.net-mvc" ]
1
0
2,067
2
0
2011-06-08T13:58:16.850000
2011-06-09T08:51:12.517000
6,279,884
6,280,088
What triggers MVC JSON Get blocking - intermittently working
I have a JSON method that accepts a GET request and returns a JSON object (not array). I'm aware of JSON Hijacking and the implications. I've read the Phil Haack post. The problem is that the method works 98% of the time for GET and POST. The other times I'm recording this error: This request has been blocked because s...
I've just looked at the MVC source code and it do not add up with what you are saying in your question. To me it looks like JsonRequestBehavior.DenyGet is used for all JSON results per default. Hence you should get the error message each time you try to return JSON from a controller using a GET request (without specify...
What triggers MVC JSON Get blocking - intermittently working I have a JSON method that accepts a GET request and returns a JSON object (not array). I'm aware of JSON Hijacking and the implications. I've read the Phil Haack post. The problem is that the method works 98% of the time for GET and POST. The other times I'm ...
TITLE: What triggers MVC JSON Get blocking - intermittently working QUESTION: I have a JSON method that accepts a GET request and returns a JSON object (not array). I'm aware of JSON Hijacking and the implications. I've read the Phil Haack post. The problem is that the method works 98% of the time for GET and POST. Th...
[ "asp.net-mvc", "ajax", "asp.net-mvc-3", "jquery" ]
2
3
1,480
1
0
2011-06-08T13:58:18.237000
2011-06-08T14:11:45.487000