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,194,925
6,195,108
Help withJS Form Validation
I'm working on a js form validation and so far I have this: // grab form field values var valid = ''; var name = $('form #name').val(); // perform error checking if (name = '' || name.length <= 2) { valid = ' Your name' + required +' '; } How can I validate that the user has chosen one of the options from a dropdown t...
$('select.foo').val(); check this http://api.jquery.com/val/
Help withJS Form Validation I'm working on a js form validation and so far I have this: // grab form field values var valid = ''; var name = $('form #name').val(); // perform error checking if (name = '' || name.length <= 2) { valid = ' Your name' + required +' '; } How can I validate that the user has chosen one of t...
TITLE: Help withJS Form Validation QUESTION: I'm working on a js form validation and so far I have this: // grab form field values var valid = ''; var name = $('form #name').val(); // perform error checking if (name = '' || name.length <= 2) { valid = ' Your name' + required +' '; } How can I validate that the user h...
[ "php", "javascript", "jquery", "forms" ]
1
3
58
2
0
2011-06-01T00:10:04.250000
2011-06-01T00:44:31.013000
6,194,929
6,204,232
How to make work newline inside c-string returned by a sqlite3 text column?
I'd like to know how to make work newline control character inside c-string returned by a sqlite3_column_text. For example, this is the text returned from a query to a sqlite database: "Lorem ipsum\ndolor sit amet,\nconsectetur\nadipiscing elit." and this is the code I use to get it: char *body = (char *)sqlite3_column...
Looking in the literal values section of the documentation of SQLite I found that the reason of why it return the two-character \n instead of newline is because C-style escapes using the backslash character are not supported because they are not standard SQL. So I tried a different aproach by using NSString instead of ...
How to make work newline inside c-string returned by a sqlite3 text column? I'd like to know how to make work newline control character inside c-string returned by a sqlite3_column_text. For example, this is the text returned from a query to a sqlite database: "Lorem ipsum\ndolor sit amet,\nconsectetur\nadipiscing elit...
TITLE: How to make work newline inside c-string returned by a sqlite3 text column? QUESTION: I'd like to know how to make work newline control character inside c-string returned by a sqlite3_column_text. For example, this is the text returned from a query to a sqlite database: "Lorem ipsum\ndolor sit amet,\nconsectetu...
[ "core-data", "sqlite", "nsstring", "escaping" ]
1
2
2,484
2
0
2011-06-01T00:11:04.773000
2011-06-01T16:05:51.367000
6,194,931
6,194,962
Status delete.php function
I have the button working, when I click the X button on my status it takes me to delete.php shows me the link in the browser and the streamitem_id number like so. Here is the button echo ' X '; And the link it gives out my site /raw/sn-extend/theme/default/delete.php?=1516 I then see on this page 'cannot find comment' ...
Ok, first you don't pass any variable via the url query string here echo ' X '; Hint: on next page you search for $_GET['id'], so I presume you should put id instead of PUT_SOME_NAME_HERE in above example:) Try that and share results. In your code example, there is also missing database selection and passing of mysql u...
Status delete.php function I have the button working, when I click the X button on my status it takes me to delete.php shows me the link in the browser and the streamitem_id number like so. Here is the button echo ' X '; And the link it gives out my site /raw/sn-extend/theme/default/delete.php?=1516 I then see on this ...
TITLE: Status delete.php function QUESTION: I have the button working, when I click the X button on my status it takes me to delete.php shows me the link in the browser and the streamitem_id number like so. Here is the button echo ' X '; And the link it gives out my site /raw/sn-extend/theme/default/delete.php?=1516 I...
[ "php", "mysql", "social-networking", "sql-delete" ]
0
0
471
2
0
2011-06-01T00:12:08.877000
2011-06-01T00:17:16.420000
6,194,932
6,194,984
How to fire an asynchronous task, but wait for all callbacks before returning ActionResult?
I have an ASP.NET MVC 3 action method which accepts a HttpFileCollectionBase in the HTTP POST. In this method, i need to resize and upload the image 3 times. The action method currently looks like this: public ActionResult ChangeProfilePicture() { var fileUpload = Request.Files[0]; ResizeAndUpload(fileUpload.InputStre...
One simple way of doing it, is using Join: public ActionResult ChangeProfilePicture() { var fileUpload = Request.Files[0]; var threads = new Thread[3]; threads[0] = new Thread(()=>ResizeAndUpload(fileUpload.InputStream, Size.Original)); threads[1] = new Thread(()=>ResizeAndUpload(fileUpload.InputStream, Size.Profile));...
How to fire an asynchronous task, but wait for all callbacks before returning ActionResult? I have an ASP.NET MVC 3 action method which accepts a HttpFileCollectionBase in the HTTP POST. In this method, i need to resize and upload the image 3 times. The action method currently looks like this: public ActionResult Chang...
TITLE: How to fire an asynchronous task, but wait for all callbacks before returning ActionResult? QUESTION: I have an ASP.NET MVC 3 action method which accepts a HttpFileCollectionBase in the HTTP POST. In this method, i need to resize and upload the image 3 times. The action method currently looks like this: public ...
[ "c#", "asp.net-mvc", "asp.net-mvc-3", "asynchronous", "asynccallback" ]
3
7
7,336
6
0
2011-06-01T00:12:15.170000
2011-06-01T00:21:45.143000
6,194,935
6,197,233
Prevent Ajax.BeginForm from HTML encoding output
@using (Ajax.BeginForm("Create", "Comment", new AjaxOptions { UpdateTargetId = "newComment", OnSuccess = "function() { alert('finished " + ViewData.Model.Id + "'); }", })) {... } outputs the following markup: As you can see, it has HTML encoded my javascript. How do I prevent this? EDIT: I have multiple AJAX forms on m...
Personally I would use a standard Html.BeginForm helper with HTML5 data-* attributes that I will AJAXify myself: @using (Html.BeginForm( "Create", "Comment", FormMethod.Post, new { data_id = Model.Id } )) {... } which outputs:... and then in a separate javascript file I would subscribe for the.submit event: $(function(...
Prevent Ajax.BeginForm from HTML encoding output @using (Ajax.BeginForm("Create", "Comment", new AjaxOptions { UpdateTargetId = "newComment", OnSuccess = "function() { alert('finished " + ViewData.Model.Id + "'); }", })) {... } outputs the following markup: As you can see, it has HTML encoded my javascript. How do I pr...
TITLE: Prevent Ajax.BeginForm from HTML encoding output QUESTION: @using (Ajax.BeginForm("Create", "Comment", new AjaxOptions { UpdateTargetId = "newComment", OnSuccess = "function() { alert('finished " + ViewData.Model.Id + "'); }", })) {... } outputs the following markup: As you can see, it has HTML encoded my javas...
[ "html", "asp.net-mvc", "razor" ]
0
1
1,406
3
0
2011-06-01T00:12:49.563000
2011-06-01T06:41:12.530000
6,194,950
6,194,960
What does the "|" (single pipe) do in JavaScript?
console.log(0.5 | 0); // 0 console.log(-1 | 0); // -1 console.log(1 | 0); // 1 Why does 0.5 | 0 return zero, but any integer (including negative) returns the input integer? What does the single pipe ("|") do?
This is a bitwise or. Since bitwise operations only make sense on integers, 0.5 is truncated. x | 0 is x, if x is an integer.
What does the "|" (single pipe) do in JavaScript? console.log(0.5 | 0); // 0 console.log(-1 | 0); // -1 console.log(1 | 0); // 1 Why does 0.5 | 0 return zero, but any integer (including negative) returns the input integer? What does the single pipe ("|") do?
TITLE: What does the "|" (single pipe) do in JavaScript? QUESTION: console.log(0.5 | 0); // 0 console.log(-1 | 0); // -1 console.log(1 | 0); // 1 Why does 0.5 | 0 return zero, but any integer (including negative) returns the input integer? What does the single pipe ("|") do? ANSWER: This is a bitwise or. Since bitwis...
[ "javascript" ]
202
197
111,611
5
0
2011-06-01T00:14:26.707000
2011-06-01T00:16:35.070000
6,194,967
6,195,117
Why does my regex not work on input from file.read()?
I have a section of code that I need to remove from multiple files that starts like this: and ends like this: //}}18420732?> where both strings of numbers can be any sequence of letters and numbers (not the same). I wrote a Python program that will return the entire input string except for this problem string: def remo...
Your regex only uses \n for lines. Your text editor may insert a carriage return and newline combination: \r\n. Try changing \n in your regex to (\r\n|\r|\n).
Why does my regex not work on input from file.read()? I have a section of code that I need to remove from multiple files that starts like this: and ends like this: //}}18420732?> where both strings of numbers can be any sequence of letters and numbers (not the same). I wrote a Python program that will return the entire...
TITLE: Why does my regex not work on input from file.read()? QUESTION: I have a section of code that I need to remove from multiple files that starts like this: and ends like this: //}}18420732?> where both strings of numbers can be any sequence of letters and numbers (not the same). I wrote a Python program that will...
[ "python", "regex", "string", "file-io", "quotes" ]
2
1
495
2
0
2011-06-01T00:18:34.233000
2011-06-01T00:47:05.387000
6,194,970
6,195,135
Problem with adding sorted number Strings to a SortedSet in Java
I created a my own SortedSet here is the code for adding something to the array. (I know there are better and simpler ways to do this than an Array but it has to be done this way) public boolean add(AnyType x){ if(this.contains(x)) return false; else if(this.isEmpty()){ items[theSize]=x; theSize++; return true; } else{...
Those look like sorted strings to me. "1" comes before "10" just like "a" comes before "ab" in the dictionary. @MRAB has the correct suggestion to convert your strings representing numbers to actual numbers if you want them sorted in numerical order. You can do that with a Comparator if you want to keep your set a Sort...
Problem with adding sorted number Strings to a SortedSet in Java I created a my own SortedSet here is the code for adding something to the array. (I know there are better and simpler ways to do this than an Array but it has to be done this way) public boolean add(AnyType x){ if(this.contains(x)) return false; else if(t...
TITLE: Problem with adding sorted number Strings to a SortedSet in Java QUESTION: I created a my own SortedSet here is the code for adding something to the array. (I know there are better and simpler ways to do this than an Array but it has to be done this way) public boolean add(AnyType x){ if(this.contains(x)) retur...
[ "java", "string", "integer", "addition", "sortedset" ]
1
2
1,571
2
0
2011-06-01T00:18:55.983000
2011-06-01T00:50:20.513000
6,194,981
6,195,079
jquery colorpicker and CSS3 gradients
I have a question regarding CSS3 Gradients and a plugin for jQuery called color picker, What i am trying to achieve is the user can change the background of a image to their chosen gradients; i have tried a number of solutions but can not seem to get the gradient part to work. Here is the development version: http://pr...
-moz-linear-gradient is a background-image value, e.g. $('#logo').css({'background-image': '-moz-linear-gradient(100% 100% 90deg,' + '#' + gradientHexOne + ', #' + gradientHexTwo + ')'});
jquery colorpicker and CSS3 gradients I have a question regarding CSS3 Gradients and a plugin for jQuery called color picker, What i am trying to achieve is the user can change the background of a image to their chosen gradients; i have tried a number of solutions but can not seem to get the gradient part to work. Here...
TITLE: jquery colorpicker and CSS3 gradients QUESTION: I have a question regarding CSS3 Gradients and a plugin for jQuery called color picker, What i am trying to achieve is the user can change the background of a image to their chosen gradients; i have tried a number of solutions but can not seem to get the gradient ...
[ "jquery", "css", "color-picker" ]
2
4
2,124
1
0
2011-06-01T00:20:18.110000
2011-06-01T00:40:13.640000
6,194,982
6,200,688
Selenium seems to work, but then gets a timeout error?
$ java -jar selenium-server-standalone-2.0b3.jar 00:17:03.883 INFO - Java: Sun Microsystems Inc. 19.0-b09 00:17:03.885 INFO - OS: Linux 2.6.32-305-ec2 i386 00:17:03.889 INFO - v2.0 [b3], with Core v2.0 [b3] 00:17:04.501 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 00:17:04.530 INFO ...
Looks like you're using Selenium Grid. The grid consists of a hub and nodes which connect to it. When you run a test you send a request to the server which dispatches it accordingly to a host with the appropriate configuration according to what you defined in desired_capabilities. In this case you don't seem to have st...
Selenium seems to work, but then gets a timeout error? $ java -jar selenium-server-standalone-2.0b3.jar 00:17:03.883 INFO - Java: Sun Microsystems Inc. 19.0-b09 00:17:03.885 INFO - OS: Linux 2.6.32-305-ec2 i386 00:17:03.889 INFO - v2.0 [b3], with Core v2.0 [b3] 00:17:04.501 INFO - RemoteWebDriver instances should conn...
TITLE: Selenium seems to work, but then gets a timeout error? QUESTION: $ java -jar selenium-server-standalone-2.0b3.jar 00:17:03.883 INFO - Java: Sun Microsystems Inc. 19.0-b09 00:17:03.885 INFO - OS: Linux 2.6.32-305-ec2 i386 00:17:03.889 INFO - v2.0 [b3], with Core v2.0 [b3] 00:17:04.501 INFO - RemoteWebDriver ins...
[ "java", "python", "selenium", "selenium-rc" ]
1
2
3,884
1
0
2011-06-01T00:20:39.027000
2011-06-01T11:54:00.787000
6,194,988
6,195,014
Django - how to set blank = False, required = False
I've a model like this: class Message(models.Model): msg = models.CharField(max_length = 150) and I have a form for insert the field. Actually django allows empty spaces, for examples if I inset in the field one space it works. But now I want to fix this: the field is not required, but if a user insert a spaces, the va...
Whitespace is not considered to be blank. blank specifically refers to no input (i.e. an empty string '' ). You will need to use a model field validator that raises an exception if the value only consists of spaces. See the documentation for details. Example: def validate_not_spaces(value): if isinstance(value, str) an...
Django - how to set blank = False, required = False I've a model like this: class Message(models.Model): msg = models.CharField(max_length = 150) and I have a form for insert the field. Actually django allows empty spaces, for examples if I inset in the field one space it works. But now I want to fix this: the field is...
TITLE: Django - how to set blank = False, required = False QUESTION: I've a model like this: class Message(models.Model): msg = models.CharField(max_length = 150) and I have a form for insert the field. Actually django allows empty spaces, for examples if I inset in the field one space it works. But now I want to fix ...
[ "python", "django" ]
8
13
4,370
2
0
2011-06-01T00:22:07.027000
2011-06-01T00:27:03.797000
6,194,990
6,195,091
emulator app only showing title, not matching eclipse preview
I have a simple GUI table-layout I'm trying to design in eclipse, but when I run the app in the emulator, only the title of my application appears. Nothing else that is shown from the eclipse graphical layout window shows up in the emulator. I've also tried it on my real device with the same outcome, so I suspect I'm d...
Make sure that you've specified setContentView(R.layout.main) in the onCreate of your Activity. There should also be a closing tag for LinearLayout at the end of the document. Other than those two issues, this layout works for me.
emulator app only showing title, not matching eclipse preview I have a simple GUI table-layout I'm trying to design in eclipse, but when I run the app in the emulator, only the title of my application appears. Nothing else that is shown from the eclipse graphical layout window shows up in the emulator. I've also tried ...
TITLE: emulator app only showing title, not matching eclipse preview QUESTION: I have a simple GUI table-layout I'm trying to design in eclipse, but when I run the app in the emulator, only the title of my application appears. Nothing else that is shown from the eclipse graphical layout window shows up in the emulator...
[ "android", "user-interface" ]
1
1
519
3
0
2011-06-01T00:22:23.303000
2011-06-01T00:41:39.943000
6,194,993
6,195,618
@Enterprise Library Unity property inject
I'm a fresher with the enterprise library. I want to ask some questions and any help will be appreciate. 1、 How to deploy inject an instance property. public class MyObject { public MyObject(string Title) { ///... } public MyObject(InjectObject injectObject) { ///... } public InjectObject InjectObject{get;set;} public ...
Firstly, prefer constructor injection over property injection. To inject the type to the constructor, you use the attribute. For example: UPDATE: To add an array as the injection value you need to configure something like this: Check out the Unity configure schema for all the detail on how to do this.
@Enterprise Library Unity property inject I'm a fresher with the enterprise library. I want to ask some questions and any help will be appreciate. 1、 How to deploy inject an instance property. public class MyObject { public MyObject(string Title) { ///... } public MyObject(InjectObject injectObject) { ///... } public I...
TITLE: @Enterprise Library Unity property inject QUESTION: I'm a fresher with the enterprise library. I want to ask some questions and any help will be appreciate. 1、 How to deploy inject an instance property. public class MyObject { public MyObject(string Title) { ///... } public MyObject(InjectObject injectObject) {...
[ "properties", "unity-container", "enterprise", "code-injection" ]
1
1
345
1
0
2011-06-01T00:22:46.857000
2011-06-01T02:29:52.053000
6,194,998
6,195,171
What's the right way to parse an ISO8601 date in cocoa?
I would like to parse ISO8601 dates in Cocoa, both for iOS 4+ and OSX 10.6+ There are a few questions about this on StackOverflow already, but in my opinion none of them contain good answers. Here's what I think constitutes a good answer: The answer should point to code with support for ISO8601. This code should compil...
The best way is this library. ☺ I should add a link on that page to the Bitbucket repo, which contains newer source code (including 32-bit and Clang fixes!) and has an issue tracker. If you find any other bugs in it, please file them. I'd also like to know what you mean by “more complicated than necessary”. Normal usag...
What's the right way to parse an ISO8601 date in cocoa? I would like to parse ISO8601 dates in Cocoa, both for iOS 4+ and OSX 10.6+ There are a few questions about this on StackOverflow already, but in my opinion none of them contain good answers. Here's what I think constitutes a good answer: The answer should point t...
TITLE: What's the right way to parse an ISO8601 date in cocoa? QUESTION: I would like to parse ISO8601 dates in Cocoa, both for iOS 4+ and OSX 10.6+ There are a few questions about this on StackOverflow already, but in my opinion none of them contain good answers. Here's what I think constitutes a good answer: The ans...
[ "objective-c", "cocoa", "ios", "macos", "iso8601" ]
7
6
3,359
1
0
2011-06-01T00:24:07.857000
2011-06-01T00:57:35.280000
6,195,007
6,195,035
Generate array from comma-separated value string
I have a string that is sent to my JavaScript via PHP that looks like this: var string = "[ 'string 1','string 2 ','string 3' ]" I want to split this string and get rid of the symbols [, ] and ' to produce the array var array = { string 1, string 2, string 3, } My current method uses a bunch of replaces, splits and loo...
You can use eval()... var myArray = eval("['string 1', 'string 2', 'string 3']"); alert(myArray[0]);
Generate array from comma-separated value string I have a string that is sent to my JavaScript via PHP that looks like this: var string = "[ 'string 1','string 2 ','string 3' ]" I want to split this string and get rid of the symbols [, ] and ' to produce the array var array = { string 1, string 2, string 3, } My curren...
TITLE: Generate array from comma-separated value string QUESTION: I have a string that is sent to my JavaScript via PHP that looks like this: var string = "[ 'string 1','string 2 ','string 3' ]" I want to split this string and get rid of the symbols [, ] and ' to produce the array var array = { string 1, string 2, str...
[ "javascript" ]
2
2
1,575
4
0
2011-06-01T00:25:44.287000
2011-06-01T00:32:15.013000
6,195,009
6,195,134
WCF - Wondering about Request Queueing
I have a quick simply question about requests in WCF. Does WCF automatically queue requests to a service(the service being a singleton) when multiple users request the same process, ie lets say I have a function that takes a while to complete, and two users make a call to this function, does WCF automatically queue the...
The service behavior attribute on the contract defines how sessions, instances and concurrency are handled. See http://msdn.microsoft.com/en-us/library/ms731193.aspx for more details. Basically you can configure it (1) handle one request at a time or (2) multiple requests at the same time.
WCF - Wondering about Request Queueing I have a quick simply question about requests in WCF. Does WCF automatically queue requests to a service(the service being a singleton) when multiple users request the same process, ie lets say I have a function that takes a while to complete, and two users make a call to this fun...
TITLE: WCF - Wondering about Request Queueing QUESTION: I have a quick simply question about requests in WCF. Does WCF automatically queue requests to a service(the service being a singleton) when multiple users request the same process, ie lets say I have a function that takes a while to complete, and two users make ...
[ "c#", "wcf" ]
4
2
2,213
1
0
2011-06-01T00:25:46.823000
2011-06-01T00:50:12.743000
6,195,011
6,195,309
Can't copy files from main bundle to documents directory on iPad
I found this piece of code from anther post here. It worked as intended with iPad simulator mode but not when I switched to the actual iPad device mode. Instead, it came up with a "no such files exist" error message. Before executing this codes, I did create a the Populator folder by right-click on the xxxxxx.app and c...
You cannot add files or folder to the NSBundle after it has been built. For the device, Xcode is going to sign the NSBundle. Whatever files and folders you want in the NSBundle on the device will have to be added to your Xcode project. The other way to add files/folders to your NSBundle is during the build phase before...
Can't copy files from main bundle to documents directory on iPad I found this piece of code from anther post here. It worked as intended with iPad simulator mode but not when I switched to the actual iPad device mode. Instead, it came up with a "no such files exist" error message. Before executing this codes, I did cre...
TITLE: Can't copy files from main bundle to documents directory on iPad QUESTION: I found this piece of code from anther post here. It worked as intended with iPad simulator mode but not when I switched to the actual iPad device mode. Instead, it came up with a "no such files exist" error message. Before executing thi...
[ "iphone", "objective-c", "cocoa-touch", "ipad", "nsfilemanager" ]
0
3
1,439
3
0
2011-06-01T00:25:55.250000
2011-06-01T01:23:11.717000
6,195,013
6,195,083
How can I order my items by date and time with this convoluted table structure?
I am using an awful propriety CMS system. Its events module can store events by an explicit date/time, e.g. 2011-08-04 13:30:00 or by a weekly recurring event, of which the recurring day is stored as a 0 based integer and the time is added to the date/time field (where the data is 0), e.g. 0000-00-00 13:30:00. I need t...
I would do it in two steps: Convert the recurring entries into the two DATETIME values for the next two weeks. This would be one sub-query. Collect the non-recurring entries from the same period. This would be a second sub-query. The UNION of the two sub-queries gives you all the events with their actual date and time ...
How can I order my items by date and time with this convoluted table structure? I am using an awful propriety CMS system. Its events module can store events by an explicit date/time, e.g. 2011-08-04 13:30:00 or by a weekly recurring event, of which the recurring day is stored as a 0 based integer and the time is added ...
TITLE: How can I order my items by date and time with this convoluted table structure? QUESTION: I am using an awful propriety CMS system. Its events module can store events by an explicit date/time, e.g. 2011-08-04 13:30:00 or by a weekly recurring event, of which the recurring day is stored as a 0 based integer and ...
[ "mysql", "datetime" ]
4
3
283
1
0
2011-06-01T00:26:56.360000
2011-06-01T00:40:29.383000
6,195,018
6,195,043
How to implement unit tests in a database-backed ASP.NET application (also UI testing)
ASP.NET apps that I've developed (on ASP.NET 2.0) have typically been backed by a database; the great majority of the.NET code on the server loads data in the form of a DataSet or SqlDataReader and uses it to databind something like a DataGrid. The meaningful logic is either database dependent or user interface depende...
Take a look at the MVP pattern (Model View Presenter). This should allow you to isolate the behaviour of your system and unit test it properly. Also, consider switching to MVC (I would go with Fubu over ASP.NET MVC). This will allow you to test controllers and have a more rails-like experience. To automate, I use WatiN...
How to implement unit tests in a database-backed ASP.NET application (also UI testing) ASP.NET apps that I've developed (on ASP.NET 2.0) have typically been backed by a database; the great majority of the.NET code on the server loads data in the form of a DataSet or SqlDataReader and uses it to databind something like ...
TITLE: How to implement unit tests in a database-backed ASP.NET application (also UI testing) QUESTION: ASP.NET apps that I've developed (on ASP.NET 2.0) have typically been backed by a database; the great majority of the.NET code on the server loads data in the form of a DataSet or SqlDataReader and uses it to databi...
[ "asp.net", "unit-testing" ]
0
1
294
1
0
2011-06-01T00:27:54.003000
2011-06-01T00:33:17.260000
6,195,027
6,198,131
jQuery click handler doesn't work if inside jsTree
My question first. How to make buttons 'inside jsTree' work? It worked with onclick defined. But now I used a jQuery handler for a click on buttons. Works fine. See sample http://jsfiddle.net/radek/5xym7/4/ I copied the handler definition (below) to my existing code (bit big to copy it here & not sure which part I need...
In your example, you bind to the click event from $(document).ready(), but initialize your jsTree object outside the $(document).ready() function. The jsTree creating block will execute as soon as that part of the source is loaded, while the $(document).ready() will execute later, upon the whole DOM is loaded. So essen...
jQuery click handler doesn't work if inside jsTree My question first. How to make buttons 'inside jsTree' work? It worked with onclick defined. But now I used a jQuery handler for a click on buttons. Works fine. See sample http://jsfiddle.net/radek/5xym7/4/ I copied the handler definition (below) to my existing code (b...
TITLE: jQuery click handler doesn't work if inside jsTree QUESTION: My question first. How to make buttons 'inside jsTree' work? It worked with onclick defined. But now I used a jQuery handler for a click on buttons. Works fine. See sample http://jsfiddle.net/radek/5xym7/4/ I copied the handler definition (below) to m...
[ "jquery", "jquery-plugins", "jquery-selectors" ]
1
1
2,054
1
0
2011-06-01T00:31:02.767000
2011-06-01T08:11:53
6,195,041
6,195,418
VB6 or VBA - I have the image data (source) can I find out the image type and name from that?
I only have the data of the image. How do I interogate this data to get type and its name? Taking a shot in the dark that this is possible. Thank you for your help
You need to examine the file structure and make a determination based on that. I would start with: http://www.garykessler.net/library/file_sigs.html
VB6 or VBA - I have the image data (source) can I find out the image type and name from that? I only have the data of the image. How do I interogate this data to get type and its name? Taking a shot in the dark that this is possible. Thank you for your help
TITLE: VB6 or VBA - I have the image data (source) can I find out the image type and name from that? QUESTION: I only have the data of the image. How do I interogate this data to get type and its name? Taking a shot in the dark that this is possible. Thank you for your help ANSWER: You need to examine the file struct...
[ "image", "vba", "vb6" ]
2
0
480
1
0
2011-06-01T00:33:00.647000
2011-06-01T01:45:37.943000
6,195,042
6,195,210
Separate database for each user group?
My program is intended for multiple projects (clients) use. I am working w/ PHP and Mysql. For example, the implementation of the program for a client would include all the tables needed, and a list of users of that client. Each implementation of the program (for separate and completely different clients) would make us...
You can create one master table where it will store the database name for each client and clients login crediential. Once they login, according to their client ID, you need to select the database. For new client registration, you need to create a copy of the database with their client name prefix.
Separate database for each user group? My program is intended for multiple projects (clients) use. I am working w/ PHP and Mysql. For example, the implementation of the program for a client would include all the tables needed, and a list of users of that client. Each implementation of the program (for separate and comp...
TITLE: Separate database for each user group? QUESTION: My program is intended for multiple projects (clients) use. I am working w/ PHP and Mysql. For example, the implementation of the program for a client would include all the tables needed, and a list of users of that client. Each implementation of the program (for...
[ "mysql", "database", "clients" ]
1
1
1,794
2
0
2011-06-01T00:33:17.073000
2011-06-01T01:05:26.170000
6,195,045
6,207,941
Malloc() creates space for single struct, not array of structs
I've been banging my head against this problem all day, I would be very grateful to anyone who could help out. Here's the deal - I'm trying to create a dynamic C array using malloc(). This array will hold CGPoint structs, which I start building and assigning right after the array is built. Here's the code: CGPoint* tem...
OK, after your edit I think I see what's going on. That code, exactly as you've written, should work OK. Xcode won't show you the values of any of those CGPoints, because it doesn't know it's an array, just a pointer to a single CGPoint. But it's there. Set a breakpoint right after you call setVertices:. At the gdb pro...
Malloc() creates space for single struct, not array of structs I've been banging my head against this problem all day, I would be very grateful to anyone who could help out. Here's the deal - I'm trying to create a dynamic C array using malloc(). This array will hold CGPoint structs, which I start building and assignin...
TITLE: Malloc() creates space for single struct, not array of structs QUESTION: I've been banging my head against this problem all day, I would be very grateful to anyone who could help out. Here's the deal - I'm trying to create a dynamic C array using malloc(). This array will hold CGPoint structs, which I start bui...
[ "iphone", "objective-c", "struct", "malloc", "arrays" ]
2
1
609
4
0
2011-06-01T00:33:40.817000
2011-06-01T21:29:06.373000
6,195,052
6,195,066
CSS - Elastic layout, 1 fluid + 1 fixed column, center aligned
This CSS challenge is really puzzling me. Here's what I'm trying to do... have an elastic layout (i.e. the container is max-width: 1200px min-width: 960px) have the container be center aligned. where the left column is fluid and expands to the highest possible width in the elastic constraints. and the right column is f...
The main part is keeping the left column stay fluid while the right is not. The left column should have a wrapper, that wrapper should have a margin-right of 200px; The left column should be 100% width; The right column should float right, have absolute positioning and have 200px of width.
CSS - Elastic layout, 1 fluid + 1 fixed column, center aligned This CSS challenge is really puzzling me. Here's what I'm trying to do... have an elastic layout (i.e. the container is max-width: 1200px min-width: 960px) have the container be center aligned. where the left column is fluid and expands to the highest possi...
TITLE: CSS - Elastic layout, 1 fluid + 1 fixed column, center aligned QUESTION: This CSS challenge is really puzzling me. Here's what I'm trying to do... have an elastic layout (i.e. the container is max-width: 1200px min-width: 960px) have the container be center aligned. where the left column is fluid and expands to...
[ "css", "fixed", "fluid", "elasticlayout" ]
0
3
1,853
1
0
2011-06-01T00:35:13.410000
2011-06-01T00:38:27.757000
6,195,061
6,195,188
php secure comment logic?
Ok, this might be obvious but its not clicking quite yet. I am creating a forum/blog esque app. I grab the posts from the database rather securely but commenting is beginning to be a little more difficult. (I could just be paranoid, right?). How do I add a comment without exposing the id of the parent message? (like in...
I would recommend that you setup your database like so: Comments --------- id encodedID authorID parentID message Then, for the form field have two hidden values, one will be the encodedID, and the second will be a hash that you make. I would recommend the hash to be: Then, when the user submits the form, validate that...
php secure comment logic? Ok, this might be obvious but its not clicking quite yet. I am creating a forum/blog esque app. I grab the posts from the database rather securely but commenting is beginning to be a little more difficult. (I could just be paranoid, right?). How do I add a comment without exposing the id of th...
TITLE: php secure comment logic? QUESTION: Ok, this might be obvious but its not clicking quite yet. I am creating a forum/blog esque app. I grab the posts from the database rather securely but commenting is beginning to be a little more difficult. (I could just be paranoid, right?). How do I add a comment without exp...
[ "php", "database", "logic" ]
1
3
250
4
0
2011-06-01T00:37:12.827000
2011-06-01T01:00:10.283000
6,195,084
6,195,325
Thread safe logging class implementation
Would the following be the correct way to implement a fairly straightforward thread-safe logging class? I know that I never explicitly close the TextWriter, would that be a problem? When I initially used the TextWriter.Synchronized method, it did not seem to work until I initialized it in a static constructor and made ...
I'm going to take a completely different approach here than the other answers and assume you actually want to learn how to write better thread-aware code, and are not looking for 3rd party suggestions from us (even though you may actually end up using one.) As others have said, you are creating a thread safe TextWriter...
Thread safe logging class implementation Would the following be the correct way to implement a fairly straightforward thread-safe logging class? I know that I never explicitly close the TextWriter, would that be a problem? When I initially used the TextWriter.Synchronized method, it did not seem to work until I initial...
TITLE: Thread safe logging class implementation QUESTION: Would the following be the correct way to implement a fairly straightforward thread-safe logging class? I know that I never explicitly close the TextWriter, would that be a problem? When I initially used the TextWriter.Synchronized method, it did not seem to wo...
[ "c#", "multithreading", "logging", "thread-safety" ]
59
107
59,159
5
0
2011-06-01T00:40:34.433000
2011-06-01T01:26:41.550000
6,195,086
6,202,017
Can't ssh to ec2 instance
Hello I am getting permission denied on the ec2 free tier when trying to ssh into my newly created ec2 instance, I have search the forums and tried the solutions provided to no avail. I would be extremely grateful for any help. Here is what I have Done First Edited ~/.bashrc with the following export EC2_PRIVATE_KEY=$H...
I manged to login correctly by deleting the instance and my keypair via the web config and regenerating them, once I did that I was able to login. Thanks for the help everyone
Can't ssh to ec2 instance Hello I am getting permission denied on the ec2 free tier when trying to ssh into my newly created ec2 instance, I have search the forums and tried the solutions provided to no avail. I would be extremely grateful for any help. Here is what I have Done First Edited ~/.bashrc with the following...
TITLE: Can't ssh to ec2 instance QUESTION: Hello I am getting permission denied on the ec2 free tier when trying to ssh into my newly created ec2 instance, I have search the forums and tried the solutions provided to no avail. I would be extremely grateful for any help. Here is what I have Done First Edited ~/.bashrc ...
[ "ssh", "amazon-ec2" ]
4
1
3,495
1
0
2011-06-01T00:41:00.080000
2011-06-01T13:33:55.700000
6,195,097
6,195,143
why am I getting a 'no route matches' error in Rails 3?
I have in my haml: = link_to("Calls Today", todo_path) And in my routes.rb: match "todo/today" => "todo#show_date" match "todo/today/campaign/:id" => "todo#show_date",:as => "todo" My understanding is that 'todo_path' should find todo controller and show_date.
This route: match "todo/today/campaign/:id" => "todo#show_date",:as => "todo" Expects an id parameter. Therefore, your link_to should be like: = link_to("Calls Today", todo_path(:id => your_id))
why am I getting a 'no route matches' error in Rails 3? I have in my haml: = link_to("Calls Today", todo_path) And in my routes.rb: match "todo/today" => "todo#show_date" match "todo/today/campaign/:id" => "todo#show_date",:as => "todo" My understanding is that 'todo_path' should find todo controller and show_date.
TITLE: why am I getting a 'no route matches' error in Rails 3? QUESTION: I have in my haml: = link_to("Calls Today", todo_path) And in my routes.rb: match "todo/today" => "todo#show_date" match "todo/today/campaign/:id" => "todo#show_date",:as => "todo" My understanding is that 'todo_path' should find todo controller ...
[ "ruby-on-rails-3", "routes", "rails-3-upgrade" ]
0
3
148
1
0
2011-06-01T00:42:22.800000
2011-06-01T00:52:33.047000
6,195,123
6,201,149
Rails 3: How to ask questions to narrow down a set of data results
I'm new to rails and programming so I'm not really sure how to do this yet and I'd love if I could get a little. I'd like to create entries for people that contain a set of data such as 'eye color' choice a) blue, b) brown, c) green, or d) other. And so on for 'hair color', and other attributes. I'd like to ask the que...
Well you could simply create a form with all of the questions showing that they would fill out in-order. This would probably be a good first step depending on just how new you are to learning rails and programming. The rails guides are a great resource, for tutorial-based learning then http://railsforzombies.org/ is a ...
Rails 3: How to ask questions to narrow down a set of data results I'm new to rails and programming so I'm not really sure how to do this yet and I'd love if I could get a little. I'd like to create entries for people that contain a set of data such as 'eye color' choice a) blue, b) brown, c) green, or d) other. And so...
TITLE: Rails 3: How to ask questions to narrow down a set of data results QUESTION: I'm new to rails and programming so I'm not really sure how to do this yet and I'd love if I could get a little. I'd like to create entries for people that contain a set of data such as 'eye color' choice a) blue, b) brown, c) green, o...
[ "ruby-on-rails", "ruby-on-rails-3", "forms" ]
0
0
176
2
0
2011-06-01T00:48:14.920000
2011-06-01T12:29:30.270000
6,195,124
6,195,137
How can I use the template parameter of a class as the template parameter of a class member?
I'm trying to implement the following in C++: template class Inner { public: Inner(T inData){data = inData;}; ~Inner(void){}; T data; }; template class Outer { public: Outer(Inner in){inner = in;}; ~Outer(void){}; Inner inner; }; int main(void) { Inner in (10); Outer out (in); std::cout << out.inner.data; } Compil...
The problem is that you don't have a default constructor for inner. When the compiler initializes the object it calls the default constructor of inner before the assignment. EDIT: It's probably a good idea to properly implement a copy constructor and instead initialize inner like so: Outer(Inner in): inner(in) { }; You...
How can I use the template parameter of a class as the template parameter of a class member? I'm trying to implement the following in C++: template class Inner { public: Inner(T inData){data = inData;}; ~Inner(void){}; T data; }; template class Outer { public: Outer(Inner in){inner = in;}; ~Outer(void){}; Inner inne...
TITLE: How can I use the template parameter of a class as the template parameter of a class member? QUESTION: I'm trying to implement the following in C++: template class Inner { public: Inner(T inData){data = inData;}; ~Inner(void){}; T data; }; template class Outer { public: Outer(Inner in){inner = in;}; ~Outer(vo...
[ "c++", "templates" ]
2
3
211
2
0
2011-06-01T00:48:16.510000
2011-06-01T00:50:48.100000
6,195,127
6,195,161
Deleting UITableCells programmatically without animation
When I programmatically delete a bunch of cells (I am normally at the bottom of the tableview) there is a move around of all the cells (as the ones being deleted are from the top). How can I stop this moving / jerking / rearranging when I delete them?
use reloadData over adding and removing rows, and it'll all just snap.
Deleting UITableCells programmatically without animation When I programmatically delete a bunch of cells (I am normally at the bottom of the tableview) there is a move around of all the cells (as the ones being deleted are from the top). How can I stop this moving / jerking / rearranging when I delete them?
TITLE: Deleting UITableCells programmatically without animation QUESTION: When I programmatically delete a bunch of cells (I am normally at the bottom of the tableview) there is a move around of all the cells (as the ones being deleted are from the top). How can I stop this moving / jerking / rearranging when I delete...
[ "iphone", "objective-c", "uitableview" ]
0
1
688
3
0
2011-06-01T00:48:38.580000
2011-06-01T00:56:02.507000
6,195,131
6,221,634
Asset Management in Adobe Air for a 2d Game
I'm building an Adobe AIR application (2d platformer adventure game), utilizing the Flash Builder 4 IDE, which will be packaged on a CD for installation. I've embed the majority of the game assets into a static class to keep it simple and organized. This way I can reuse assets and swap them without much digging. exampl...
it sounds to me like it's time to break up your assets into separate files and load them at runtime from the disk. That should free up some space while you're editing code so that FB4 doesn't freak out. I just finished a Facebook game that had a ton of assets, and I ended up putting all of the sounds in their own SWF, ...
Asset Management in Adobe Air for a 2d Game I'm building an Adobe AIR application (2d platformer adventure game), utilizing the Flash Builder 4 IDE, which will be packaged on a CD for installation. I've embed the majority of the game assets into a static class to keep it simple and organized. This way I can reuse asset...
TITLE: Asset Management in Adobe Air for a 2d Game QUESTION: I'm building an Adobe AIR application (2d platformer adventure game), utilizing the Flash Builder 4 IDE, which will be packaged on a CD for installation. I've embed the majority of the game assets into a static class to keep it simple and organized. This way...
[ "flash", "actionscript-3", "air", "flash-builder" ]
2
3
1,005
1
0
2011-06-01T00:50:00.457000
2011-06-02T23:48:16.323000
6,195,132
6,195,170
Java library for interactive SSH session (to be able to do multi-part commands)?
I'm currently using a library for SSH within Java but it seems to be lacking the ability to do multipart commands (such as if I do passwd user I have no way of then entering the password twice to change it to because it makes you start a new session each time you enter a command). I really need this functionality for t...
I am using the Ganymede SSH-2 library with great success. However the password prompt shouldn't appear to the application at all, it should be part of the connection setup negotiation.
Java library for interactive SSH session (to be able to do multi-part commands)? I'm currently using a library for SSH within Java but it seems to be lacking the ability to do multipart commands (such as if I do passwd user I have no way of then entering the password twice to change it to because it makes you start a n...
TITLE: Java library for interactive SSH session (to be able to do multi-part commands)? QUESTION: I'm currently using a library for SSH within Java but it seems to be lacking the ability to do multipart commands (such as if I do passwd user I have no way of then entering the password twice to change it to because it m...
[ "java", "linux", "ssh", "distributed-computing" ]
5
2
2,519
3
0
2011-06-01T00:50:08.677000
2011-06-01T00:57:17.417000
6,195,144
6,195,187
Does SSL also encrypt cookies?
A review of SO doesn't categorically answer this question. It could be implied, but I would like to get it on the record specifically. If SSL is active, it will encrypt HTTP header data, like "set-cookie"? I know about "setSecure" to only transmit cookie's if HTTPS is active, but if SSL is active I would like to confir...
Data sent over SSL (HTTPS) is fully encrypted, headers included (hence cookies), only the Host you are sending the request to is not encrypted. It also means that the GET request is encrypted (the rest of the URL). Although an attacker could force a client to respond over HTTP, so it is highly recommended to use the "S...
Does SSL also encrypt cookies? A review of SO doesn't categorically answer this question. It could be implied, but I would like to get it on the record specifically. If SSL is active, it will encrypt HTTP header data, like "set-cookie"? I know about "setSecure" to only transmit cookie's if HTTPS is active, but if SSL i...
TITLE: Does SSL also encrypt cookies? QUESTION: A review of SO doesn't categorically answer this question. It could be implied, but I would like to get it on the record specifically. If SSL is active, it will encrypt HTTP header data, like "set-cookie"? I know about "setSecure" to only transmit cookie's if HTTPS is ac...
[ "servlets", "ssl", "http-headers" ]
56
79
20,475
2
0
2011-06-01T00:52:34.247000
2011-06-01T01:00:07.147000
6,195,145
6,209,101
Creating Dynamic Class for Bitmap containing bitmapData from SWC
I have the following code ///Get BitmapData from library in SWC var ClassReference:Class = getDefinitionByName(products[i].producticon+"Data") as Class; // Create new BitmapData Instance From it var bitMapS:BitmapData = new ClassReference(); // Create new Class that contains Bitmap Data var IconBitmap:Class = new Andro...
I'm not sure I understand you question exactly, but it sounds like you want a way to get a copy of this bitmap data in a manner similar to creating a new instance of a class. If that's the case, you could do something like this: //grab the name of the asset as a string var bitmapDataAssetName:String = products[i].produ...
Creating Dynamic Class for Bitmap containing bitmapData from SWC I have the following code ///Get BitmapData from library in SWC var ClassReference:Class = getDefinitionByName(products[i].producticon+"Data") as Class; // Create new BitmapData Instance From it var bitMapS:BitmapData = new ClassReference(); // Create new...
TITLE: Creating Dynamic Class for Bitmap containing bitmapData from SWC QUESTION: I have the following code ///Get BitmapData from library in SWC var ClassReference:Class = getDefinitionByName(products[i].producticon+"Data") as Class; // Create new BitmapData Instance From it var bitMapS:BitmapData = new ClassReferenc...
[ "apache-flex", "actionscript-3", "actionscript", "air", "flash-builder" ]
0
0
1,002
1
0
2011-06-01T00:52:51.603000
2011-06-02T00:05:43.783000
6,195,146
6,195,186
Keeping Variables in Scope when Running Commands as Another User
I'm trying to run a command as a different user and save the return code for further processing. Is this possible in bash? ret=99 pid=1234 su - deploy -c "cd $PROJECT_ROOT; kill -9 `echo $pid`; ret=$?" >> mylog.log 2>&1 echo $ret # <= $ret still equals 99 when I want it to equal 0 or 1
Not like that. ret=99 pid=1234 su - deploy -c "cd $PROJECT_ROOT; kill -9 `echo $pid`" >> mylog.log 2>&1 ret=$? echo $ret
Keeping Variables in Scope when Running Commands as Another User I'm trying to run a command as a different user and save the return code for further processing. Is this possible in bash? ret=99 pid=1234 su - deploy -c "cd $PROJECT_ROOT; kill -9 `echo $pid`; ret=$?" >> mylog.log 2>&1 echo $ret # <= $ret still equals 99...
TITLE: Keeping Variables in Scope when Running Commands as Another User QUESTION: I'm trying to run a command as a different user and save the return code for further processing. Is this possible in bash? ret=99 pid=1234 su - deploy -c "cd $PROJECT_ROOT; kill -9 `echo $pid`; ret=$?" >> mylog.log 2>&1 echo $ret # <= $r...
[ "bash" ]
2
1
111
1
0
2011-06-01T00:53:02.453000
2011-06-01T00:59:56.263000
6,195,162
6,195,212
Rails help sorting
I want the default sorting to be rating DESC, but I also have, some ajax sorting. Here is my controller: def konkurrance_oversigt @konkurrencerb = Konkurrancer.order(sort_column + "" + sort_direction) @titel = 'Gratis konkurrenceoversigt | Vinderhimlen.dk' end How should I set the default order, without removeing the a...
def sort_column Konkurrancer.column_names.include?(params[:sort])? params[:sort]: "rating" end
Rails help sorting I want the default sorting to be rating DESC, but I also have, some ajax sorting. Here is my controller: def konkurrance_oversigt @konkurrencerb = Konkurrancer.order(sort_column + "" + sort_direction) @titel = 'Gratis konkurrenceoversigt | Vinderhimlen.dk' end How should I set the default order, with...
TITLE: Rails help sorting QUESTION: I want the default sorting to be rating DESC, but I also have, some ajax sorting. Here is my controller: def konkurrance_oversigt @konkurrencerb = Konkurrancer.order(sort_column + "" + sort_direction) @titel = 'Gratis konkurrenceoversigt | Vinderhimlen.dk' end How should I set the d...
[ "ruby-on-rails", "ruby", "ruby-on-rails-3" ]
0
0
66
1
0
2011-06-01T00:56:05.910000
2011-06-01T01:05:50.053000
6,195,164
6,195,179
I am getting an Unexpected Indent error in a nested if block
I am using a nested if block to decide the appropriate view. But I am getting an Unexpected Indent error after the if block. I am not able to find out where I am making a mistake in indentation. def logged_home(request): names = request.user.social_auth.values_list('provider', flat=True) ctx = dict((name.lower().replac...
You might be mixing tabs and spaces, and don't have your tab size set to 8.
I am getting an Unexpected Indent error in a nested if block I am using a nested if block to decide the appropriate view. But I am getting an Unexpected Indent error after the if block. I am not able to find out where I am making a mistake in indentation. def logged_home(request): names = request.user.social_auth.value...
TITLE: I am getting an Unexpected Indent error in a nested if block QUESTION: I am using a nested if block to decide the appropriate view. But I am getting an Unexpected Indent error after the if block. I am not able to find out where I am making a mistake in indentation. def logged_home(request): names = request.user...
[ "python", "django", "django-views" ]
0
3
3,616
1
0
2011-06-01T00:56:30.790000
2011-06-01T00:58:44.183000
6,195,167
6,259,718
Problems trying to attach a new EF4 entity to ObjectContext while its entity collection entities are already attached
This is somewhat complicated to explain, so please bear with me. I have an ASP.NET MVC 2 project that is slowly killing me in which I'm trying to take form data and translate it into entities to create or update, depending on the context of the situation. The most relevant parts (pseudo-code): Entity Game Scalar proper...
I got it to work by using Julie Lerman's original solution. I didn't have to detach/re-attach my platforms with my original, pre-DTO solution, so I thought I didn't need to here. In any event, it looks like I need to do more research on how to handle the ObjectContext.
Problems trying to attach a new EF4 entity to ObjectContext while its entity collection entities are already attached This is somewhat complicated to explain, so please bear with me. I have an ASP.NET MVC 2 project that is slowly killing me in which I'm trying to take form data and translate it into entities to create ...
TITLE: Problems trying to attach a new EF4 entity to ObjectContext while its entity collection entities are already attached QUESTION: This is somewhat complicated to explain, so please bear with me. I have an ASP.NET MVC 2 project that is slowly killing me in which I'm trying to take form data and translate it into e...
[ "c#", "asp.net-mvc-2", "entity-framework-4", "automapper" ]
0
0
1,272
3
0
2011-06-01T00:56:55.903000
2011-06-07T01:12:39.323000
6,195,168
6,205,443
Running computation using multiple sub-selects in SQL
Is there a way to write this SQL query in SQL? select (select count(*) from a) / (select count(*) from b) as ratio; I've done the obvious: DB.fetch("select (select count(*) from a) / (select count(*) from b) as ratio") but I'm wondering whether there is a more idiomatic SQL way of doing this.
Currently, Sequel::Dataset is not able to use all of the methods that other Sequel::Expression subclasses can use, though it probably should be able to handle at least some of them. You can use the sql_expr extension that ships with Sequel to handle this: Sequel.extension:sql_expr DB.select((DB[:a].select{count(:*){}}....
Running computation using multiple sub-selects in SQL Is there a way to write this SQL query in SQL? select (select count(*) from a) / (select count(*) from b) as ratio; I've done the obvious: DB.fetch("select (select count(*) from a) / (select count(*) from b) as ratio") but I'm wondering whether there is a more idiom...
TITLE: Running computation using multiple sub-selects in SQL QUESTION: Is there a way to write this SQL query in SQL? select (select count(*) from a) / (select count(*) from b) as ratio; I've done the obvious: DB.fetch("select (select count(*) from a) / (select count(*) from b) as ratio") but I'm wondering whether the...
[ "ruby", "sequel" ]
0
2
201
3
0
2011-06-01T00:56:59.350000
2011-06-01T17:43:40.340000
6,195,169
6,195,207
jquery .bind() and/or .ready() not working
So I have this code: var bindAll; bindAll = function () { $('#somediv').bind('mouseover', function(){do something}); }; var init; init = function () { bindAll();... }; $(document).ready(init()); and it does not work. But if I put the bind on a timer by replacing: bindAll(); with tt = setTimeout('bindAll()', 1000); It...
You aren't passing init to $(document).ready, you're passing whatever init returns. Try this: $(document).ready(init); Explanation: When you were trying to pass the function, you were actually running it. At the time of you running it, the DOM wasn't ready, so the bindings to the element didn't take place, because it d...
jquery .bind() and/or .ready() not working So I have this code: var bindAll; bindAll = function () { $('#somediv').bind('mouseover', function(){do something}); }; var init; init = function () { bindAll();... }; $(document).ready(init()); and it does not work. But if I put the bind on a timer by replacing: bindAll(); ...
TITLE: jquery .bind() and/or .ready() not working QUESTION: So I have this code: var bindAll; bindAll = function () { $('#somediv').bind('mouseover', function(){do something}); }; var init; init = function () { bindAll();... }; $(document).ready(init()); and it does not work. But if I put the bind on a timer by repl...
[ "javascript", "jquery" ]
2
4
2,159
3
0
2011-06-01T00:57:00.413000
2011-06-01T01:04:38.957000
6,195,172
6,196,871
Formatting language with floating div like element
I have data stored in structured XML that I want to make it more readable using XSLT (or another alternative). The target document should have lots of instances of text aligned both to the left and to the right in the same line, and I need to have a behaviour like div floats: Left text. Left text. Left text. Left text....
I think you should decide for a more general approach to your problem by going with some well known XML standard schema like DITA or DOCBOOK. These schemas have the advantage of letting you write your own XML and render it as you need according to the output format they support. Moreover, they are free and you can obta...
Formatting language with floating div like element I have data stored in structured XML that I want to make it more readable using XSLT (or another alternative). The target document should have lots of instances of text aligned both to the left and to the right in the same line, and I need to have a behaviour like div ...
TITLE: Formatting language with floating div like element QUESTION: I have data stored in structured XML that I want to make it more readable using XSLT (or another alternative). The target document should have lots of instances of text aligned both to the left and to the right in the same line, and I need to have a b...
[ "xslt", "html", "latex", "xsl-fo", "wordml" ]
2
2
1,536
2
0
2011-06-01T00:57:37.680000
2011-06-01T05:54:47.463000
6,195,177
6,195,321
What is the performance for Node.js' http.request ? How many concurrent request it can handle?
My node.js server is making a call to another server using the latest (0.4.8) http.request call. I use jMeter to run load testing. with 50-100 concurrent threads per sec, and loop 1000 times. I observe some slow down when script keeps running. I monitor the network throughput is pretty low, CPU & memory are low too. An...
The max concurrent connections should depends on your hardware. This article said node.js can support tens of thousands of concurrent connection. However, most linux systems only allow you open 1024 files/sockets on same time by default. For that case, you can run as root and then set ulimit as a big number(e.g., 10000...
What is the performance for Node.js' http.request ? How many concurrent request it can handle? My node.js server is making a call to another server using the latest (0.4.8) http.request call. I use jMeter to run load testing. with 50-100 concurrent threads per sec, and loop 1000 times. I observe some slow down when scr...
TITLE: What is the performance for Node.js' http.request ? How many concurrent request it can handle? QUESTION: My node.js server is making a call to another server using the latest (0.4.8) http.request call. I use jMeter to run load testing. with 50-100 concurrent threads per sec, and loop 1000 times. I observe some ...
[ "http", "concurrency", "node.js", "request" ]
9
12
8,472
1
0
2011-06-01T00:58:32.067000
2011-06-01T01:25:51.387000
6,195,180
6,195,198
@property not retaining
I have a property called data of type NSArray in InventoryFilteredTVC and here's a sample code: NSArray *results = [array filteredArrayUsingPredicate:predicate]; NSLog(@"%i", [array retainCount]); InventoryFilteredTVC *filteredTVC = [[InventoryFilteredTVC alloc] initWithStyle:UITableViewStylePlain]; [filteredTVC setTit...
'results' and 'array' are two different arrays. You may be retaining 'results', but why would that affect the retain count of 'array'? As for your crash, check that you aren't releasing 'results' (it is already autoreleased), and check that you are using the synthesized setData: (or you wrote your own setData: that act...
@property not retaining I have a property called data of type NSArray in InventoryFilteredTVC and here's a sample code: NSArray *results = [array filteredArrayUsingPredicate:predicate]; NSLog(@"%i", [array retainCount]); InventoryFilteredTVC *filteredTVC = [[InventoryFilteredTVC alloc] initWithStyle:UITableViewStylePla...
TITLE: @property not retaining QUESTION: I have a property called data of type NSArray in InventoryFilteredTVC and here's a sample code: NSArray *results = [array filteredArrayUsingPredicate:predicate]; NSLog(@"%i", [array retainCount]); InventoryFilteredTVC *filteredTVC = [[InventoryFilteredTVC alloc] initWithStyle:U...
[ "objective-c", "cocoa-touch", "nsarray" ]
0
3
257
3
0
2011-06-01T00:58:57.593000
2011-06-01T01:03:04.513000
6,195,184
6,195,217
ActionScript Preloader More Detailed Percentages
I am building a preloader for a flash application I am building. I am looking for a way to gain more detailed percentages from the ProgressEvent.PROGRESS that all preloaders use to track downloading progress. When I run a trace() statement on the loader percentages for a small file, my output window displays something ...
This doesn't make sense - unless your internet connection loaded exactly 1% of the file at a time. What's happening is that after each new packet is received, it could be any size based on your download speed (let's say between 200 and 230kb). ProgressEvent.PROGRESS is dispatched each time one of these is received, add...
ActionScript Preloader More Detailed Percentages I am building a preloader for a flash application I am building. I am looking for a way to gain more detailed percentages from the ProgressEvent.PROGRESS that all preloaders use to track downloading progress. When I run a trace() statement on the loader percentages for a...
TITLE: ActionScript Preloader More Detailed Percentages QUESTION: I am building a preloader for a flash application I am building. I am looking for a way to gain more detailed percentages from the ProgressEvent.PROGRESS that all preloaders use to track downloading progress. When I run a trace() statement on the loader...
[ "php", "flash", "actionscript-3", "actionscript", "preloader" ]
1
2
149
3
0
2011-06-01T00:59:53.793000
2011-06-01T01:06:22.563000
6,195,193
6,195,229
How to fix "return not in function" error that shown on firebug?
I try to prevent page reload when user click a link, so I wrote: bla Or bla Seriously I don't like to use # because when user click on the link, the url on the address bar is added the symbol #, it make the url look ugly. So I prefer to use javascript: return false but firebug show error: "return not in function", may ...
See this discussion: Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"? Do not use href="#". If it has to be, either use "javascript:;" or "javascript:void(0);"
How to fix "return not in function" error that shown on firebug? I try to prevent page reload when user click a link, so I wrote: bla Or bla Seriously I don't like to use # because when user click on the link, the url on the address bar is added the symbol #, it make the url look ugly. So I prefer to use javascript: re...
TITLE: How to fix "return not in function" error that shown on firebug? QUESTION: I try to prevent page reload when user click a link, so I wrote: bla Or bla Seriously I don't like to use # because when user click on the link, the url on the address bar is added the symbol #, it make the url look ugly. So I prefer to ...
[ "javascript" ]
3
6
4,271
3
0
2011-06-01T01:01:20.520000
2011-06-01T01:08:25.243000
6,195,202
6,198,026
Select random record from mnesia
I have an mnesia table t that contains records with a single field x. How can I select a random value x from t? To avoid the entire of process of mathematical pedantry: I don't care about the details of the random number generation, I just want my result to generally not be the same every time. Thanks, -tjw
By using the mnesia:all_keys/1 (or dirty equivalent) function and the random module. random_value(Table) -> Keys = mnesia:dirty_all_keys(Table), Key = lists:nth(random:uniform(length(Keys)), Keys), [#record{x = X}] = mnesia:dirty_read({Table, Key}), X. Don't forget to initialize your seed using random:seed/3.
Select random record from mnesia I have an mnesia table t that contains records with a single field x. How can I select a random value x from t? To avoid the entire of process of mathematical pedantry: I don't care about the details of the random number generation, I just want my result to generally not be the same eve...
TITLE: Select random record from mnesia QUESTION: I have an mnesia table t that contains records with a single field x. How can I select a random value x from t? To avoid the entire of process of mathematical pedantry: I don't care about the details of the random number generation, I just want my result to generally n...
[ "database", "erlang", "mnesia" ]
3
4
884
2
0
2011-06-01T01:03:18.147000
2011-06-01T08:01:38.543000
6,195,204
6,195,226
Should I index DateTime in SQLite?
Will it make it faster to find date > a certain date?
In general yes, but keep in mind that SQLite only uses one index per-table (except in the case of OR clauses). Always use EXPLAIN to find out how the engine will process a given query.
Should I index DateTime in SQLite? Will it make it faster to find date > a certain date?
TITLE: Should I index DateTime in SQLite? QUESTION: Will it make it faster to find date > a certain date? ANSWER: In general yes, but keep in mind that SQLite only uses one index per-table (except in the case of OR clauses). Always use EXPLAIN to find out how the engine will process a given query.
[ "sql", "sqlite" ]
5
6
2,817
1
0
2011-06-01T01:04:13.690000
2011-06-01T01:08:01.780000
6,195,206
6,195,288
Crop image in Java with a class?
I have been attempting to do this for about a week. Every single time I have tried something it failed. So I turned to copying others code... they said the code worked for them... yet it failed for me. The piece of code that I ended up liking came from the following. How To Crop Image in Java (StackOverflow) So then fr...
The first error says it can't find method drawImage(BufferedImage,int,int,double,double,double,double,double,double, ). All those double values are coming from a Rectangle, right? Graphics has a drawImage(BufferedImage,int,int,int,int,int,int,int,int,ImageObserver) method. That's probably the one you are trying to use....
Crop image in Java with a class? I have been attempting to do this for about a week. Every single time I have tried something it failed. So I turned to copying others code... they said the code worked for them... yet it failed for me. The piece of code that I ended up liking came from the following. How To Crop Image i...
TITLE: Crop image in Java with a class? QUESTION: I have been attempting to do this for about a week. Every single time I have tried something it failed. So I turned to copying others code... they said the code worked for them... yet it failed for me. The piece of code that I ended up liking came from the following. H...
[ "java", "bufferedimage", "symbols", "drawimage" ]
1
3
2,446
1
0
2011-06-01T01:04:29.603000
2011-06-01T01:18:59.440000
6,195,215
6,195,318
jQuery, finding an element's ID during form post
I'm trying to locate an id from a div to detemine the correct css class to use when entering a form. An example of the html that will generate: ERROR Password did not match. Now I got this to work with a plug-in I made, though the difference there is that it used an iframe, which is not the case here, so I know the cod...
I don't quite understand the logic of the code, but I do understand what you want to achieve. In my opinion a better approach would be to have a wrapper for the whole message (including the type of message) and via a special class name set color or wathever CSS rule you want. Just like Plone status message works ( see ...
jQuery, finding an element's ID during form post I'm trying to locate an id from a div to detemine the correct css class to use when entering a form. An example of the html that will generate: ERROR Password did not match. Now I got this to work with a plug-in I made, though the difference there is that it used an ifra...
TITLE: jQuery, finding an element's ID during form post QUESTION: I'm trying to locate an id from a div to detemine the correct css class to use when entering a form. An example of the html that will generate: ERROR Password did not match. Now I got this to work with a plug-in I made, though the difference there is th...
[ "php", "jquery", "css", "validation" ]
2
1
143
1
0
2011-06-01T01:06:13.280000
2011-06-01T01:25:20.047000
6,195,218
6,196,061
how to convert pc serial number to string
First of all I'd like to know if I can use these two instructions gwmi win32_bios | select serialnumber gwmi win32_Computersystemproduct | select identifyingnumber indifferently. The second question is why if I write $sn = gwmi win32_bios | select serialnumber | out-string $sn.gettype() returns me system.object and $s...
By using Out-String, you are converting the output of gwmi win32_bios | select serialnumber to a string and storing it in $sn. So, $sn will now have the following content: PS> $sn serialnumber ------------ xxxxxxx So, $sn.length is showing you the length of this entire string. If you want to change it only to the seri...
how to convert pc serial number to string First of all I'd like to know if I can use these two instructions gwmi win32_bios | select serialnumber gwmi win32_Computersystemproduct | select identifyingnumber indifferently. The second question is why if I write $sn = gwmi win32_bios | select serialnumber | out-string $sn...
TITLE: how to convert pc serial number to string QUESTION: First of all I'd like to know if I can use these two instructions gwmi win32_bios | select serialnumber gwmi win32_Computersystemproduct | select identifyingnumber indifferently. The second question is why if I write $sn = gwmi win32_bios | select serialnumbe...
[ "powershell", "object-to-string" ]
3
2
6,766
4
0
2011-06-01T01:06:23.917000
2011-06-01T03:49:23.393000
6,195,219
6,195,241
ArrayUtil causes unexpected error in Java
Whenever I write a code that includes an ArrayUtil, it causes an unexpected error: int[] values = ArrayUtil.randomIntArray(30, 300); I use Eclipse to write my code, and there is always a red underline under "ArrayUtil". What am I doing wrong?
What package does your ArrayUtil belong to? No one can answer with certainty without that information. Did you get it here? If yes, your signature looks right. You probably haven't imported it yet, or the class isn't in your CLASSPATH. Eclipse is telling you to correct one or the other.
ArrayUtil causes unexpected error in Java Whenever I write a code that includes an ArrayUtil, it causes an unexpected error: int[] values = ArrayUtil.randomIntArray(30, 300); I use Eclipse to write my code, and there is always a red underline under "ArrayUtil". What am I doing wrong?
TITLE: ArrayUtil causes unexpected error in Java QUESTION: Whenever I write a code that includes an ArrayUtil, it causes an unexpected error: int[] values = ArrayUtil.randomIntArray(30, 300); I use Eclipse to write my code, and there is always a red underline under "ArrayUtil". What am I doing wrong? ANSWER: What pac...
[ "java", "eclipse", "syntax" ]
2
0
6,034
5
0
2011-06-01T01:06:26.040000
2011-06-01T01:10:51.657000
6,195,224
6,195,319
table updates empty spaces when user do not enter anything to the textbox
The situation is my program's purpose is to update employee details. The user may choose which of the information (name,position,department and tag(which tells if he/she is still employed to the company)) he/she wants to update. He or she may or may not fill up all the details as he/she wants to. In other words,he/she ...
$col['emp_name'] = (trim($_POST['ename']))?trim($_POST['ename']):false; $col['emp_pos'] = (trim($_POST['pos']))?trim($_POST['pos']):false; $col['emp_dep'] = (trim($_POST['dep']))?trim($_POST['dep']):false; $col['emp_tag'] = (trim($_POST['tag']))?trim($_POST['tag']):false; // add a val in $col[] with key=column name for...
table updates empty spaces when user do not enter anything to the textbox The situation is my program's purpose is to update employee details. The user may choose which of the information (name,position,department and tag(which tells if he/she is still employed to the company)) he/she wants to update. He or she may or ...
TITLE: table updates empty spaces when user do not enter anything to the textbox QUESTION: The situation is my program's purpose is to update employee details. The user may choose which of the information (name,position,department and tag(which tells if he/she is still employed to the company)) he/she wants to update....
[ "php", "mysql", "sql-update" ]
0
0
456
3
0
2011-06-01T01:07:09.007000
2011-06-01T01:25:23.500000
6,195,231
6,195,265
How do I get a specific <TD> value?
I'm facing a troubles around jQuery and HTML elements. Let's to the "Artists": Action Nome Data Nasc Grau Parent This above is the Table Header and Inside of it I add dinamically new Rows. Each row contains a Checkbox and three more TDs, also I have three text inputs which I send each of one to the referent TD, the che...
Cheap solution: don't get them back from the HTML at all. Instead, before inserting each row into the HTML, store that row's values in an array. Then, just read the array rather than having to go all the way back through the DOM. As requested, here is some very basic code for how you'd go about doing this. (Obviously, ...
How do I get a specific <TD> value? I'm facing a troubles around jQuery and HTML elements. Let's to the "Artists": Action Nome Data Nasc Grau Parent This above is the Table Header and Inside of it I add dinamically new Rows. Each row contains a Checkbox and three more TDs, also I have three text inputs which I send eac...
TITLE: How do I get a specific <TD> value? QUESTION: I'm facing a troubles around jQuery and HTML elements. Let's to the "Artists": Action Nome Data Nasc Grau Parent This above is the Table Header and Inside of it I add dinamically new Rows. Each row contains a Checkbox and three more TDs, also I have three text input...
[ "jquery", "html" ]
0
1
1,643
2
0
2011-06-01T01:08:42.237000
2011-06-01T01:15:43.747000
6,195,234
6,296,272
Pick up native JNI files in Maven test (lwjgl)
I'm creating a program with LWJGL and Maven, and I'm writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so that the tests can pick it up. I can't get past the error: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path I've gotten the binaries to ...
According to http://maven.40175.n5.nabble.com/Trouble-with-Java-Native-Libraries-td114063.html, the surefire plugin starts the VM and then modifies the system properties before passing control to the junit test classes. This is too late for the VM, which needs to have the java.library.path set up at the time the VM is ...
Pick up native JNI files in Maven test (lwjgl) I'm creating a program with LWJGL and Maven, and I'm writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so that the tests can pick it up. I can't get past the error: java.lang.UnsatisfiedLinkError: no lwjgl in...
TITLE: Pick up native JNI files in Maven test (lwjgl) QUESTION: I'm creating a program with LWJGL and Maven, and I'm writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so that the tests can pick it up. I can't get past the error: java.lang.UnsatisfiedLink...
[ "java", "maven-2", "java-native-interface", "lwjgl" ]
5
14
5,857
2
0
2011-06-01T01:08:58.150000
2011-06-09T16:40:09.383000
6,195,247
6,195,299
Using a .GIF animation as the splash screen in WP7 application
I have an animated.GIF image that I created with http://ajaxload.info/ and some editing. I would like to set the resulting icon as the splash screen in my app, which can take a few seconds to load. I don't think that I can set the icon as the SplashScreenImage. jpg (GIF!= JPG) and I'm not sure how to view the image as ...
Silverlight doesn't support GIF files. There are a couple of things you could do. Firstly, you could create the same animation in Blend (as a Storyboard). Or, you could display a WebBrowser control which does render GIF files. As you mentioned, you can't change the SplashScreen image. It has to be a jpeg and there's no...
Using a .GIF animation as the splash screen in WP7 application I have an animated.GIF image that I created with http://ajaxload.info/ and some editing. I would like to set the resulting icon as the splash screen in my app, which can take a few seconds to load. I don't think that I can set the icon as the SplashScreenIm...
TITLE: Using a .GIF animation as the splash screen in WP7 application QUESTION: I have an animated.GIF image that I created with http://ajaxload.info/ and some editing. I would like to set the resulting icon as the splash screen in my app, which can take a few seconds to load. I don't think that I can set the icon as ...
[ "c#", "visual-studio", "visual-studio-2010", "windows-phone-7", "animated-gif" ]
2
7
2,352
1
0
2011-06-01T01:12:34.573000
2011-06-01T01:20:21.987000
6,195,256
6,195,357
c# HttpWebRequest headers
Why the location is not listed on the response Headers? My code: string url = "http://hehe.freevar.com/files.php"; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Method = "HEAD"; Console.WriteLine(req.GetResponse().Headers);
From Wikipedia: The HTTP Location header is returned in responses from an HTTP server under two circumstances: To force a web browser to load a different web page. It is passed as part of the response by a web server when the requested URI has: Moved temporarily, or Moved permanently The HttpWebRequest class has a prop...
c# HttpWebRequest headers Why the location is not listed on the response Headers? My code: string url = "http://hehe.freevar.com/files.php"; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Method = "HEAD"; Console.WriteLine(req.GetResponse().Headers);
TITLE: c# HttpWebRequest headers QUESTION: Why the location is not listed on the response Headers? My code: string url = "http://hehe.freevar.com/files.php"; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Method = "HEAD"; Console.WriteLine(req.GetResponse().Headers); ANSWER: From Wikipedia: The ...
[ "c#", ".net", "header" ]
0
4
3,650
2
0
2011-06-01T01:13:58.100000
2011-06-01T01:33:25.367000
6,195,264
6,195,323
Android: Adding .xml resources to an array
UPDATE: So I tried the AssetManager way and ended up with this:...... XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xrp = factory.newPullParser(); AssetManager assmgr = context.getAssets(); xrp.setInput(assmgr.open("levels/level_1.xml"), null); //Ob...
Have a look at AssetManager: http://developer.android.com/reference/android/content/res/AssetManager.html#list(java.lang.String) And then you can new a file and getName() Link: http://developer.android.com/reference/java/io/File.html#getName() Hope this helps.
Android: Adding .xml resources to an array UPDATE: So I tried the AssetManager way and ended up with this:...... XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xrp = factory.newPullParser(); AssetManager assmgr = context.getAssets(); xrp.setInput(assm...
TITLE: Android: Adding .xml resources to an array QUESTION: UPDATE: So I tried the AssetManager way and ended up with this:...... XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xrp = factory.newPullParser(); AssetManager assmgr = context.getAssets(); ...
[ "java", "android", "xml" ]
2
0
322
3
0
2011-06-01T01:15:32.720000
2011-06-01T01:25:52.907000
6,195,269
6,195,320
Things are happening outside my for loop before its done (javascript)
I'm sure I've seen this before and know the answer to it but after 12 hours... my mind is complete mush. I have a for loop in which I am trying to concatenate onto a string so that AFTER I can complete the string (thus completing a nice little table) that I had hoped to then insert into my html and show the user. Howev...
$.post is asynchronous, meaning that it's firing off all the requests in the loop as fast as it can, and then exiting the loop. It doesn't wait for a response. When the response comes back, your row function is then called... but by then, all the posts have been sent on their way. See the answers to this question here....
Things are happening outside my for loop before its done (javascript) I'm sure I've seen this before and know the answer to it but after 12 hours... my mind is complete mush. I have a for loop in which I am trying to concatenate onto a string so that AFTER I can complete the string (thus completing a nice little table)...
TITLE: Things are happening outside my for loop before its done (javascript) QUESTION: I'm sure I've seen this before and know the answer to it but after 12 hours... my mind is complete mush. I have a for loop in which I am trying to concatenate onto a string so that AFTER I can complete the string (thus completing a ...
[ "javascript", "loops", "for-loop" ]
0
1
149
2
0
2011-06-01T01:16:54.637000
2011-06-01T01:25:35.587000
6,195,270
6,195,306
what is the fastest way to check whether string has uppercase letter in c#?
My first implementation idea is to do simply: bool hasUpperCase (string str) { if(string.IsNullOrEmpty(str)) return false; for (int i = 0; i < str.Length; i++) { if (char.IsUpper (str[i])) return true; } return false; } but maybe there is another faster way to do that?
You could reduce that to bool HasUpperCase (string str) { return!string.IsNullOrEmpty(str) && str.Any(c => char.IsUpper(c)); } using LINQ.
what is the fastest way to check whether string has uppercase letter in c#? My first implementation idea is to do simply: bool hasUpperCase (string str) { if(string.IsNullOrEmpty(str)) return false; for (int i = 0; i < str.Length; i++) { if (char.IsUpper (str[i])) return true; } return false; } but maybe there is anoth...
TITLE: what is the fastest way to check whether string has uppercase letter in c#? QUESTION: My first implementation idea is to do simply: bool hasUpperCase (string str) { if(string.IsNullOrEmpty(str)) return false; for (int i = 0; i < str.Length; i++) { if (char.IsUpper (str[i])) return true; } return false; } but ma...
[ "c#", "string" ]
23
40
24,651
6
0
2011-06-01T01:16:55.570000
2011-06-01T01:22:23.217000
6,195,280
6,195,562
Resolving generic interface from generic static method - is using container most simple?
I have a code similar to this: public static IEnumerable ParseInput (string input) { var xml = XElement.Parse(input); // some more code here var parser = Container.Current.Resolve >(); return parser.Parse(xml); } It contains some common processing of the data followed by a call to parser interface which is very differe...
Edit: I kinda missed what you meant. I quite like using a container for things like that. Switch statements are a bit ugly. So going with a container, some ways you could make it more testable are: If some code here is complicated, I tend to make sure it is not static, as its not as easy to unit test static methods whe...
Resolving generic interface from generic static method - is using container most simple? I have a code similar to this: public static IEnumerable ParseInput (string input) { var xml = XElement.Parse(input); // some more code here var parser = Container.Current.Resolve >(); return parser.Parse(xml); } It contains some c...
TITLE: Resolving generic interface from generic static method - is using container most simple? QUESTION: I have a code similar to this: public static IEnumerable ParseInput (string input) { var xml = XElement.Parse(input); // some more code here var parser = Container.Current.Resolve >(); return parser.Parse(xml); } ...
[ "c#", "generics", "dependency-injection" ]
2
2
309
2
0
2011-06-01T01:18:17.023000
2011-06-01T02:18:21.233000
6,195,294
6,196,346
Objective C — What is the fastest and most efficient way to enumerate an array?
Edit I read through some articles on blocks and fast enumeration and GCD and the like. @Bbum, who's written many articles on the subject of GCD and blocks, says that the block enumeration methods are always as fast or faster than the fast enumeration equivalents. You can read his reasoning here. While this has been a f...
The fastest code is the code that reaches the market first. Seriously -- unless you have a measurable performance problem, this particular choice should occupy no more of your time than it takes to answer which of these patterns fits the most naturally with my project's style? Note: adressing a performance problem by m...
Objective C — What is the fastest and most efficient way to enumerate an array? Edit I read through some articles on blocks and fast enumeration and GCD and the like. @Bbum, who's written many articles on the subject of GCD and blocks, says that the block enumeration methods are always as fast or faster than the fast e...
TITLE: Objective C — What is the fastest and most efficient way to enumerate an array? QUESTION: Edit I read through some articles on blocks and fast enumeration and GCD and the like. @Bbum, who's written many articles on the subject of GCD and blocks, says that the block enumeration methods are always as fast or fast...
[ "objective-c", "arrays", "enumeration", "grand-central-dispatch", "objective-c-blocks" ]
27
44
8,458
3
0
2011-06-01T01:19:52.870000
2011-06-01T04:39:55.630000
6,195,297
6,195,535
just what is the origin in cocos2d boundingBox
So I have a CGRect and it has a size and a CGpoint call origin. Is origin the center of the square or the top left?
The CGRect defines how far the bounding box extends along each axis from the origin point, so it will never be the center. However, cocos2D has a default coordinate system where the origin is the bottom-left of the view, so the origin in this case would be the bottom-left of the box.
just what is the origin in cocos2d boundingBox So I have a CGRect and it has a size and a CGpoint call origin. Is origin the center of the square or the top left?
TITLE: just what is the origin in cocos2d boundingBox QUESTION: So I have a CGRect and it has a size and a CGpoint call origin. Is origin the center of the square or the top left? ANSWER: The CGRect defines how far the bounding box extends along each axis from the origin point, so it will never be the center. However...
[ "iphone", "cocos2d-iphone" ]
3
5
1,208
1
0
2011-06-01T01:20:00.610000
2011-06-01T02:10:24.957000
6,195,301
6,195,364
os.getcwd() throws Exception
I have situation when the current directory becomes invalid (ie, when some program deletes it). My Python script calls os.getcwd() which terminates with following exception OSError: [Errno 2] No such file or directory Ideally, it my script would automatically cd into parent directory in such situation. When is the reco...
Ideally, it my script would automatically cd into parent directory in such situation. When is the recommended strategy for implementing this? Just use try/except block for that, that's what for we have them:) try: os.getcwd() except OSError: os.chdir("..") os.getcwd() or something similar... [edit] Anyway I guess such ...
os.getcwd() throws Exception I have situation when the current directory becomes invalid (ie, when some program deletes it). My Python script calls os.getcwd() which terminates with following exception OSError: [Errno 2] No such file or directory Ideally, it my script would automatically cd into parent directory in suc...
TITLE: os.getcwd() throws Exception QUESTION: I have situation when the current directory becomes invalid (ie, when some program deletes it). My Python script calls os.getcwd() which terminates with following exception OSError: [Errno 2] No such file or directory Ideally, it my script would automatically cd into paren...
[ "python" ]
2
2
2,144
1
0
2011-06-01T01:21:57.303000
2011-06-01T01:35:03.373000
6,195,304
6,195,928
Using fread to read the contents of a file into a structure
In the "Advanced Programming in the Unix Environment" book there's a part (ch 8.14, page 251) in which the author shows us the definition of the "acct" struct (used to store accounting records info). He then shows a program in which he reads the accounting data from a file into the struct (the key part of which is): fr...
Yes Your program will be stable. Your question has touched off a bonfire of portability recommendations that you didn't actually ask for. The question you seemed to be asking is "is this code pattern and my program stable?". And the answer to that is yes. You structure will not be reordered. C99 specifically prohibits ...
Using fread to read the contents of a file into a structure In the "Advanced Programming in the Unix Environment" book there's a part (ch 8.14, page 251) in which the author shows us the definition of the "acct" struct (used to store accounting records info). He then shows a program in which he reads the accounting dat...
TITLE: Using fread to read the contents of a file into a structure QUESTION: In the "Advanced Programming in the Unix Environment" book there's a part (ch 8.14, page 251) in which the author shows us the definition of the "acct" struct (used to store accounting records info). He then shows a program in which he reads ...
[ "c", "linux", "struct" ]
3
2
2,871
4
0
2011-06-01T01:22:14.617000
2011-06-01T03:23:25.887000
6,195,305
6,195,416
how to print in c#? i want to print a table(query)
An Administrator needs to run a report that details when a specific user signs in and out over a historical date range. The information is saved to a database. I need to print this information. It will include his information (name, street, registration, etc) plus all of the sign in/out details. What is the best way to...
A very straightforward way of printing is to create either a Crystal Report (as you've tagged as such) or (my preference) a Microsoft Reporting Services Report, that takes the user ID as a parameter, and executes a stored procedure or a parameterized query to get it's data. You can then either export or print, with eit...
how to print in c#? i want to print a table(query) An Administrator needs to run a report that details when a specific user signs in and out over a historical date range. The information is saved to a database. I need to print this information. It will include his information (name, street, registration, etc) plus all ...
TITLE: how to print in c#? i want to print a table(query) QUESTION: An Administrator needs to run a report that details when a specific user signs in and out over a historical date range. The information is saved to a database. I need to print this information. It will include his information (name, street, registrati...
[ "c#", "sql-server", "printing", "crystal-reports" ]
0
1
295
1
0
2011-06-01T01:22:14.947000
2011-06-01T01:45:10.453000
6,195,315
6,195,369
0.5 displays as 0.5 even when I use round(0.5,2)
I have a number like 0.5, I would like to keep two digits in order to make the number 0.50. While the last digit is zero, so it always cannot appear. I have used round(0.5,2) but it doesn't work
You can cheat by using: y <- 0.5 formatC(round(y,2),2,format="f") Note that this changes to character. Hence, it's for display purposes only.
0.5 displays as 0.5 even when I use round(0.5,2) I have a number like 0.5, I would like to keep two digits in order to make the number 0.50. While the last digit is zero, so it always cannot appear. I have used round(0.5,2) but it doesn't work
TITLE: 0.5 displays as 0.5 even when I use round(0.5,2) QUESTION: I have a number like 0.5, I would like to keep two digits in order to make the number 0.50. While the last digit is zero, so it always cannot appear. I have used round(0.5,2) but it doesn't work ANSWER: You can cheat by using: y <- 0.5 formatC(round(y,...
[ "r", "zero", "digit" ]
4
3
549
2
0
2011-06-01T01:24:17.983000
2011-06-01T01:36:07.253000
6,195,316
6,207,770
Configuring .ASP pages in IIS 7.5 in Windows server 2003
I am trying to add a virtual directory in IIS 7.5 version of Windows server 2003. But i could not browse my default.asp page. How can i troubleshoot this issue?
I believe you installed IIS Express7.5... correct? If that is the case, take a look at failed request trace log files located in "%userprofile%\My Documents\IISExpress\TraceLogFiles\" and also see if there are any interesting events in event viewer.
Configuring .ASP pages in IIS 7.5 in Windows server 2003 I am trying to add a virtual directory in IIS 7.5 version of Windows server 2003. But i could not browse my default.asp page. How can i troubleshoot this issue?
TITLE: Configuring .ASP pages in IIS 7.5 in Windows server 2003 QUESTION: I am trying to add a virtual directory in IIS 7.5 version of Windows server 2003. But i could not browse my default.asp page. How can i troubleshoot this issue? ANSWER: I believe you installed IIS Express7.5... correct? If that is the case, tak...
[ "asp-classic", "iis-7.5" ]
1
1
1,001
1
0
2011-06-01T01:25:07.220000
2011-06-01T21:12:28.263000
6,195,324
6,195,503
Deploying rails, paperclip error, no such file to load -- cocaine
Using the paperclip-cloudfiles fork of paperclip: gem 'paperclip-cloudfiles', '~>2.3',:require => 'paperclip' Using passenger and I get the following load error: no such file to load -- cocaine Key part of stack trace:.rvm/gems/ruby-1.9.2-p180/gems/paperclip-cloudfiles-2.3.10.1/lib/paperclip.rb 43 in `' Paperclip works...
[SOLVED]: Downgraded paperclip-cloudfiles to '2.3.8' and it works. Must be a problem with the current version.
Deploying rails, paperclip error, no such file to load -- cocaine Using the paperclip-cloudfiles fork of paperclip: gem 'paperclip-cloudfiles', '~>2.3',:require => 'paperclip' Using passenger and I get the following load error: no such file to load -- cocaine Key part of stack trace:.rvm/gems/ruby-1.9.2-p180/gems/paper...
TITLE: Deploying rails, paperclip error, no such file to load -- cocaine QUESTION: Using the paperclip-cloudfiles fork of paperclip: gem 'paperclip-cloudfiles', '~>2.3',:require => 'paperclip' Using passenger and I get the following load error: no such file to load -- cocaine Key part of stack trace:.rvm/gems/ruby-1.9...
[ "ruby-on-rails", "ruby-on-rails-3", "paperclip" ]
0
0
2,318
5
0
2011-06-01T01:26:28.607000
2011-06-01T02:03:25.580000
6,195,329
6,202,729
How can you hide the arrow that is displayed by default on the HTML5 <details> element in Chrome?
I now its still early but I also know you guys are on top of it. I want to use the HTML5 details element: What's the HTML5 details element? The details element represents a disclosure widget from which the user can obtain additional information or controls. As of this writing, Chrome 12 beta is the only browser to actu...
I didn't plan to answer my own question but I have the solution. Source: http://trac.webkit.org/timeline?from=2011-04-15T16%3A33%3A41-0700&precision=second More about the recommendation for the disclosure widget: http://mail-archive.com/whatwg@lists.whatwg.org/msg26129.html Code details summary::-webkit-details-marker ...
How can you hide the arrow that is displayed by default on the HTML5 <details> element in Chrome? I now its still early but I also know you guys are on top of it. I want to use the HTML5 details element: What's the HTML5 details element? The details element represents a disclosure widget from which the user can obtain ...
TITLE: How can you hide the arrow that is displayed by default on the HTML5 <details> element in Chrome? QUESTION: I now its still early but I also know you guys are on top of it. I want to use the HTML5 details element: What's the HTML5 details element? The details element represents a disclosure widget from which th...
[ "html", "css", "google-chrome", "html-tag-details", "html-tag-summary" ]
133
148
102,003
12
0
2011-06-01T01:27:12.307000
2011-06-01T14:23:22.177000
6,195,332
6,195,410
Add 10 minutes into the future into a MySQL db using PHP/PDO
I want to add a row to a db with a time 'x' amount into the future (different for each row). I have looked through every tutorial/help/whatever I could find via google but nothing seems to help. From what I can tell, the best way is to do it with MySQL. SELECT ADDTIME(now(), '00:10:00') But how do I actually make that ...
Untested, but have you tried: $new_row = $db->prepare("INSERT INTO table (field1, field2, time) VALUES(?,?, ADDTIME(NOW(), '00:10:00'))"); $new_row->execute(array($field1, $field2)) or dieWithDBError($new_row);
Add 10 minutes into the future into a MySQL db using PHP/PDO I want to add a row to a db with a time 'x' amount into the future (different for each row). I have looked through every tutorial/help/whatever I could find via google but nothing seems to help. From what I can tell, the best way is to do it with MySQL. SELEC...
TITLE: Add 10 minutes into the future into a MySQL db using PHP/PDO QUESTION: I want to add a row to a db with a time 'x' amount into the future (different for each row). I have looked through every tutorial/help/whatever I could find via google but nothing seems to help. From what I can tell, the best way is to do it...
[ "php", "mysql", "time", "pdo" ]
1
2
792
4
0
2011-06-01T01:27:59.840000
2011-06-01T01:43:58.750000
6,195,333
6,240,519
code igniter active records - help streamlining process
I am currently using the below code to get a list of uuid's then split them into groups of 1000, then insert those groups into the database. This works fine except this has to work on at times, over a million uuid's The issue is this uses a massive amount of memory, so I need help to streamline this process to use less...
This reworking can insert 1,000,000 "users" in under a minute without any memory limits:) public function create_daily_email($dealId) { $time_start = microtime(true); set_time_limit(0); $deal = $this->ci->deal->get($dealId); if ($deal == false) throw new exception('Unknown Deal Specified'); $message = $this->ci->load-...
code igniter active records - help streamlining process I am currently using the below code to get a list of uuid's then split them into groups of 1000, then insert those groups into the database. This works fine except this has to work on at times, over a million uuid's The issue is this uses a massive amount of memor...
TITLE: code igniter active records - help streamlining process QUESTION: I am currently using the below code to get a list of uuid's then split them into groups of 1000, then insert those groups into the database. This works fine except this has to work on at times, over a million uuid's The issue is this uses a massi...
[ "mysql", "codeigniter", "memory" ]
0
0
564
2
0
2011-06-01T01:28:12.763000
2011-06-05T01:46:42.010000
6,195,335
6,195,354
Linear Regression in Javascript
I want to do Least Squares Fitting in Javascript in a web browser. Currently users enter data point information using HTML text inputs and then I grab that data with jQuery and graph it with Flot. After the user had entered in their data points I would like to present them with a "line of best fit". I imagine I would c...
What kind of linear regression? For something simple like least squares, I'd just program it myself: http://mathworld.wolfram.com/LeastSquaresFitting.html The math is not too hard to follow there, give it a shot for an hour or so and let me know if it's too hard, I can try it. EDIT: Found someone that did it: http://dr...
Linear Regression in Javascript I want to do Least Squares Fitting in Javascript in a web browser. Currently users enter data point information using HTML text inputs and then I grab that data with jQuery and graph it with Flot. After the user had entered in their data points I would like to present them with a "line o...
TITLE: Linear Regression in Javascript QUESTION: I want to do Least Squares Fitting in Javascript in a web browser. Currently users enter data point information using HTML text inputs and then I grab that data with jQuery and graph it with Flot. After the user had entered in their data points I would like to present t...
[ "javascript", "jquery", "statistics", "flot", "linear-regression" ]
41
27
61,565
7
0
2011-06-01T01:28:31.213000
2011-06-01T01:32:50.713000
6,195,339
6,195,725
How to get next sibling of the item in databound items control?
How to get next sibling of the element in visual tree? This elment is dataitem of the databound ItemsSource. My goal is get acces to sibling in code (assume that i have access to the element itself) and then use BringIntoView. Thanks.
For example, if your ItemsControl is a ListBox, the elements will be ListBoxItem objects. If you have one ListBoxItem and you want the next ListBoxItem in the list, you can use the ItemContainerGenerator API to find it like this: public static DependencyObject GetNextSibling(ItemsControl itemsControl, DependencyObject ...
How to get next sibling of the item in databound items control? How to get next sibling of the element in visual tree? This elment is dataitem of the databound ItemsSource. My goal is get acces to sibling in code (assume that i have access to the element itself) and then use BringIntoView. Thanks.
TITLE: How to get next sibling of the item in databound items control? QUESTION: How to get next sibling of the element in visual tree? This elment is dataitem of the databound ItemsSource. My goal is get acces to sibling in code (assume that i have access to the element itself) and then use BringIntoView. Thanks. AN...
[ "c#", "wpf" ]
6
6
1,619
1
0
2011-06-01T01:29:34.700000
2011-06-01T02:47:20.493000
6,195,340
6,196,921
How to make output dependent on UIPicker row selection
I need a single component UIPicker to display different text and perform a different action depending on which row is selected. I am defining the text, so it is not what the picker reads. First, second, and third are all NSStrings. I can't figure out the correct code to make the action dependent on the UIPicker row. He...
didSelectRow:inComponent: is a delegate method invoked on a user action. You shouldn't call it here. What you need is selectedRowInComponent: method in the UIPickerView. Here's a rough implementation of your example using it. -(IBAction)example { switch([example selectedRowInComponent:0]) { case 0: select1.text = first...
How to make output dependent on UIPicker row selection I need a single component UIPicker to display different text and perform a different action depending on which row is selected. I am defining the text, so it is not what the picker reads. First, second, and third are all NSStrings. I can't figure out the correct co...
TITLE: How to make output dependent on UIPicker row selection QUESTION: I need a single component UIPicker to display different text and perform a different action depending on which row is selected. I am defining the text, so it is not what the picker reads. First, second, and third are all NSStrings. I can't figure ...
[ "objective-c", "nsstring", "uitextview", "uilabel", "uipicker" ]
1
0
210
1
0
2011-06-01T01:29:39.390000
2011-06-01T06:01:42.487000
6,195,341
6,195,460
Objective-c search locations with radius
Is there a library in for objective-c that will allow me to specify a radius and a location, and a list of locations and tell me which locations are within that radius? Thanks.
If you have CLLocations then something like this would work: // Given NSArray *locations as an array of CLLocation* that you wish to filter // and given a radius... CLLocationDistance radius = kSomeRadius; // and given a target you want to test against... CLLocation* target = [[CLLocation alloc] initWithLatitude:some...
Objective-c search locations with radius Is there a library in for objective-c that will allow me to specify a radius and a location, and a list of locations and tell me which locations are within that radius? Thanks.
TITLE: Objective-c search locations with radius QUESTION: Is there a library in for objective-c that will allow me to specify a radius and a location, and a list of locations and tell me which locations are within that radius? Thanks. ANSWER: If you have CLLocations then something like this would work: // Given NSArr...
[ "objective-c", "cocoa-touch", "ios", "nsarray" ]
1
2
1,001
1
0
2011-06-01T01:29:48.090000
2011-06-01T01:55:22.077000
6,195,342
6,196,522
iPhone - AudioToolbox and recording
In my application, I'm playing an audio using audio toolbox framework. When its playing, how can I record the same? I tried using AVAudioRecording by setting audio session "Play and Record". But when recording, the volume of the audio being played is getting reduced. How can I use Audiotoolbox framework itself and reco...
You can't use the AVAudioRecorder to record itself. You can use the Audio Queue or the Audio Unit RemoteIO APIs, and capture the audio samples you are putting in the output buffers to play as you play them.
iPhone - AudioToolbox and recording In my application, I'm playing an audio using audio toolbox framework. When its playing, how can I record the same? I tried using AVAudioRecording by setting audio session "Play and Record". But when recording, the volume of the audio being played is getting reduced. How can I use Au...
TITLE: iPhone - AudioToolbox and recording QUESTION: In my application, I'm playing an audio using audio toolbox framework. When its playing, how can I record the same? I tried using AVAudioRecording by setting audio session "Play and Record". But when recording, the volume of the audio being played is getting reduced...
[ "iphone", "audio-recording", "audiotoolbox" ]
1
0
897
1
0
2011-06-01T01:30:18.327000
2011-06-01T05:05:10.500000
6,195,348
6,195,358
How do i say is not, is not
i don't want to say: (trsaz!= v1) && (trsaz!= v2) &&... i want something like: trsaz!= (v1, v4, v7, v11) Is this possible or is there also something else besides!=.
var badList = new[] { v1, v4, v7, v11 }; var result =!badList.Contains(trsaz);
How do i say is not, is not i don't want to say: (trsaz!= v1) && (trsaz!= v2) &&... i want something like: trsaz!= (v1, v4, v7, v11) Is this possible or is there also something else besides!=.
TITLE: How do i say is not, is not QUESTION: i don't want to say: (trsaz!= v1) && (trsaz!= v2) &&... i want something like: trsaz!= (v1, v4, v7, v11) Is this possible or is there also something else besides!=. ANSWER: var badList = new[] { v1, v4, v7, v11 }; var result =!badList.Contains(trsaz);
[ "c#", "boolean-expression" ]
5
12
152
4
0
2011-06-01T01:31:55.377000
2011-06-01T01:33:33.613000
6,195,365
6,195,400
Has any one worked with IBM Net.Data
We have a small old project in Net.data where some development is still occurring. I have the IBM manuals for this product. Does anyone know of any tutorial or other source of information on this language? I was unable to locate any results using Google.
Is this useful? Net.Data Adminstration and Programming Guide: http://www-03.ibm.com/systems/resources/systems_i_software_netdata_dtwa2mst.pdf Net.Data Reference: http://www.ibm.com/systems/i/software/netdata/db2rn.pdf IBM Net.Data for i Samples: http://www-03.ibm.com/systems/i/software/netdata/samples/sample.html Try t...
Has any one worked with IBM Net.Data We have a small old project in Net.data where some development is still occurring. I have the IBM manuals for this product. Does anyone know of any tutorial or other source of information on this language? I was unable to locate any results using Google.
TITLE: Has any one worked with IBM Net.Data QUESTION: We have a small old project in Net.data where some development is still occurring. I have the IBM manuals for this product. Does anyone know of any tutorial or other source of information on this language? I was unable to locate any results using Google. ANSWER: I...
[ "ibm-midrange" ]
2
4
647
4
0
2011-06-01T01:35:06.497000
2011-06-01T01:43:14.010000
6,195,373
6,196,317
Regular expression to get class name with specific substring
I need a regular expression in javascript that will get a string with a specific substring from a list of space delimited strings. For example, I have; widget util cookie i18n-username I want to be able to return only i18n-username. How
You could use the following function, using a regex to match for your string surrounded by either a space or the beginning or end of a line. But you'll have to be careful about preparing any regular expression special characters if you plan to use them, since the search argument will be interpreted as a string instead ...
Regular expression to get class name with specific substring I need a regular expression in javascript that will get a string with a specific substring from a list of space delimited strings. For example, I have; widget util cookie i18n-username I want to be able to return only i18n-username. How
TITLE: Regular expression to get class name with specific substring QUESTION: I need a regular expression in javascript that will get a string with a specific substring from a list of space delimited strings. For example, I have; widget util cookie i18n-username I want to be able to return only i18n-username. How ANS...
[ "javascript", "regex" ]
1
3
7,563
4
0
2011-06-01T01:37:30.343000
2011-06-01T04:34:05.913000
6,195,377
6,195,406
Extend mysqli_result
I have extended PHP's mysqli class, which works fine. But how can I make it return a custom result object (or a boolean for insert/update/delete etc) when querying? namespace MyApp; class MySQLi extends \mysqli { public function query($query, $resultmode = null) { // This needs to return a MySQLiResult or a boolean } }...
Probably the simplest thing to do would be treat your MySQLiResult class as a decorator for mysqli_result. For example class MySQLiResult { private $result; public function __construct(\mysqli_result $result) { $this->result = $result; } } You could then proxy method calls to the internal result and decorate (add func...
Extend mysqli_result I have extended PHP's mysqli class, which works fine. But how can I make it return a custom result object (or a boolean for insert/update/delete etc) when querying? namespace MyApp; class MySQLi extends \mysqli { public function query($query, $resultmode = null) { // This needs to return a MySQLiRe...
TITLE: Extend mysqli_result QUESTION: I have extended PHP's mysqli class, which works fine. But how can I make it return a custom result object (or a boolean for insert/update/delete etc) when querying? namespace MyApp; class MySQLi extends \mysqli { public function query($query, $resultmode = null) { // This needs to...
[ "php", "oop", "mysqli" ]
3
2
2,314
2
0
2011-06-01T01:38:27.533000
2011-06-01T01:43:38.470000
6,195,381
6,195,393
Create copy of list and remove element
I would like to write something like this S = [ 0, 1, 2 ] F = [ S.without(i) for i in range(0,len(S)) ] print F and Python putting out [ [0,1], [0,2],[1,2] ] and have not found something like this in the online reference. Can you help me?
>>> S = [0, 1, 2] >>> F = [S[0:i] + S[i+1:] for i in range(len(S))] >>> print F [[1, 2], [0, 2], [0, 1]] >>> If you don't need the elements to be in any order -- that is, if you can use sets -- and if you want to remove items by value rather than by index, then this is a more elegant solution: >>> S = set(range(3)) >>>...
Create copy of list and remove element I would like to write something like this S = [ 0, 1, 2 ] F = [ S.without(i) for i in range(0,len(S)) ] print F and Python putting out [ [0,1], [0,2],[1,2] ] and have not found something like this in the online reference. Can you help me?
TITLE: Create copy of list and remove element QUESTION: I would like to write something like this S = [ 0, 1, 2 ] F = [ S.without(i) for i in range(0,len(S)) ] print F and Python putting out [ [0,1], [0,2],[1,2] ] and have not found something like this in the online reference. Can you help me? ANSWER: >>> S = [0, 1, ...
[ "python", "list" ]
2
2
6,065
3
0
2011-06-01T01:38:53.820000
2011-06-01T01:42:07.003000
6,195,383
6,195,454
javascript calling object
I'm kind of new to this so a bit confused. I have a js file named rrr.js, in which I have this code: var rrr_rrr2= { // get the domain name from the current url get_domain_name:function() { //code here... }, // other functions here } Now in my HTML page I simply added it like I usually do:
I think Satyajit was almost right. Try closing it like this instead: But also, if this js file is part of your addon, you can't access it directly from an HTML page, unless you put it at a resource: URI or something. Read up on privileged vs. unprivileged code.
javascript calling object I'm kind of new to this so a bit confused. I have a js file named rrr.js, in which I have this code: var rrr_rrr2= { // get the domain name from the current url get_domain_name:function() { //code here... }, // other functions here } Now in my HTML page I simply added it like I usually do:
TITLE: javascript calling object QUESTION: I'm kind of new to this so a bit confused. I have a js file named rrr.js, in which I have this code: var rrr_rrr2= { // get the domain name from the current url get_domain_name:function() { //code here... }, // other functions here } Now in my HTML page I simply added it like...
[ "javascript", "firefox", "firefox-addon" ]
1
1
229
3
0
2011-06-01T01:40:09.550000
2011-06-01T01:52:18.207000
6,195,386
6,195,443
How do I add a navigationbar to my app programmatically?
I set up my app a while ago using a tutorial for setting up the navigationbar in interface builder, but no longer use interface builder in any of my app and would much like to change this 1 thing which does use interface builder to being coded in. So my question is, I have a navigationbar which works, and which appears...
In the AppDelegate.m file, add this: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { RootViewController *rootViewController = [[RootViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewControl...
How do I add a navigationbar to my app programmatically? I set up my app a while ago using a tutorial for setting up the navigationbar in interface builder, but no longer use interface builder in any of my app and would much like to change this 1 thing which does use interface builder to being coded in. So my question ...
TITLE: How do I add a navigationbar to my app programmatically? QUESTION: I set up my app a while ago using a tutorial for setting up the navigationbar in interface builder, but no longer use interface builder in any of my app and would much like to change this 1 thing which does use interface builder to being coded i...
[ "iphone", "objective-c" ]
0
2
2,327
2
0
2011-06-01T01:40:45.293000
2011-06-01T01:50:34.277000
6,195,397
6,195,517
MySQL Query Help Finding Rank by ID
I'm trying to modify the following query to find the rank of a specific videoid and I'm not having much luck can anyone suggest a solution? SELECT videoid wins/loses as win_loss, @curRank:= @curRank + 1 AS rank FROM cb_video, (SELECT @curRank:= 0) r ORDER BY wins/loses DESC I tried doing a subquery like this but it fai...
SELECT a.videoid, (SELECT COUNT(*) FROM cb_video b WHERE a.videoid!=b.videoid AND (b.wins/b.loses) > (a.wins/a.loses))+1 AS rank FROM cb_video a WHERE a.videoid = 116
MySQL Query Help Finding Rank by ID I'm trying to modify the following query to find the rank of a specific videoid and I'm not having much luck can anyone suggest a solution? SELECT videoid wins/loses as win_loss, @curRank:= @curRank + 1 AS rank FROM cb_video, (SELECT @curRank:= 0) r ORDER BY wins/loses DESC I tried d...
TITLE: MySQL Query Help Finding Rank by ID QUESTION: I'm trying to modify the following query to find the rank of a specific videoid and I'm not having much luck can anyone suggest a solution? SELECT videoid wins/loses as win_loss, @curRank:= @curRank + 1 AS rank FROM cb_video, (SELECT @curRank:= 0) r ORDER BY wins/lo...
[ "mysql", "sql", "ranking" ]
1
1
361
3
0
2011-06-01T01:42:46.443000
2011-06-01T02:06:11.380000
6,195,413
6,195,479
Intersection between 3D flat polygons
How to find intersections between two (or more) 3D planar polygons (for the simplest case they are all convex)? Seeking algorithms able to provide the intersection line if there is any. Note the methods proposed for infinite Plane-Plane cases are not useful.
There are 2 cases: Both polygons lie on the same plane. Find all internal points to the first polygon. Arbitrarily take the first polygon, loop through all the vertices of the 2nd polygon and determine whether they lie inside or outside the first polygon. Doing this is easy for convex polygons: see here. Find the inter...
Intersection between 3D flat polygons How to find intersections between two (or more) 3D planar polygons (for the simplest case they are all convex)? Seeking algorithms able to provide the intersection line if there is any. Note the methods proposed for infinite Plane-Plane cases are not useful.
TITLE: Intersection between 3D flat polygons QUESTION: How to find intersections between two (or more) 3D planar polygons (for the simplest case they are all convex)? Seeking algorithms able to provide the intersection line if there is any. Note the methods proposed for infinite Plane-Plane cases are not useful. ANSW...
[ "algorithm", "3d", "intersection", "polygons" ]
1
3
6,632
3
0
2011-06-01T01:44:26.957000
2011-06-01T02:00:20.247000
6,195,424
6,195,447
How to insert a checkbox in a django form
I've a settings page where users can select if they want to receive a newsletter or not. I want a checkbox for this, and I want that Django select it if 'newsletter' is true in database. How can I implement in Django?
models.py: class Settings(models.Model): receive_newsletter = models.BooleanField() #... forms.py: class SettingsForm(forms.ModelForm): receive_newsletter = forms.BooleanField() class Meta: model = Settings And if you want to automatically set receive_newsletter to True according to some criteria in your application, ...
How to insert a checkbox in a django form I've a settings page where users can select if they want to receive a newsletter or not. I want a checkbox for this, and I want that Django select it if 'newsletter' is true in database. How can I implement in Django?
TITLE: How to insert a checkbox in a django form QUESTION: I've a settings page where users can select if they want to receive a newsletter or not. I want a checkbox for this, and I want that Django select it if 'newsletter' is true in database. How can I implement in Django? ANSWER: models.py: class Settings(models....
[ "python", "django", "django-forms" ]
48
79
139,641
3
0
2011-06-01T01:46:40.357000
2011-06-01T01:51:15.087000
6,195,439
6,195,521
Postgres: how do you round a timestamp up or down to the nearest minute?
Is there a postgresql function that will return a timestamp rounded to the nearest minute? The input value is a timestamp and the return value should be a timestamp.
Use the built-in function date_trunc(text, timestamp), for example: select date_trunc('minute', now()) Edit: This truncates to the most recent minute. To get a rounded result, add 30 seconds to the timestamp first, for example: select date_trunc('minute', now() + interval '30 second') This returns the nearest minute. S...
Postgres: how do you round a timestamp up or down to the nearest minute? Is there a postgresql function that will return a timestamp rounded to the nearest minute? The input value is a timestamp and the return value should be a timestamp.
TITLE: Postgres: how do you round a timestamp up or down to the nearest minute? QUESTION: Is there a postgresql function that will return a timestamp rounded to the nearest minute? The input value is a timestamp and the return value should be a timestamp. ANSWER: Use the built-in function date_trunc(text, timestamp),...
[ "postgresql" ]
129
220
96,992
4
0
2011-06-01T01:49:59.690000
2011-06-01T02:06:50.273000
6,195,444
6,195,736
Java store crawleds page to mysql in a unified encoding
I am crawling webpages to MySQL database using Java. These webpages are in various encoding(e.g. GBK, UTF8...) and may contain none ASCII characters, however, I managed to detect each page's encoding and get the readable string(readable string means it displays the same in Eclipse console as in Web Browser ). I get web...
Java will represent the string correctly internally which is shown by the Eclipse console. You should be able to connect to the database using UTF8 and store the data in a UTF8 encoded column. If you want the column to be GBK, I would still connect using UTF8. If this doesn't work, it would be helpful if you can post y...
Java store crawleds page to mysql in a unified encoding I am crawling webpages to MySQL database using Java. These webpages are in various encoding(e.g. GBK, UTF8...) and may contain none ASCII characters, however, I managed to detect each page's encoding and get the readable string(readable string means it displays th...
TITLE: Java store crawleds page to mysql in a unified encoding QUESTION: I am crawling webpages to MySQL database using Java. These webpages are in various encoding(e.g. GBK, UTF8...) and may contain none ASCII characters, however, I managed to detect each page's encoding and get the readable string(readable string me...
[ "java", "mysql", "encoding", "web-crawler" ]
1
0
277
1
0
2011-06-01T01:50:38.427000
2011-06-01T02:48:09.617000
6,195,450
6,196,119
Serializer SimpleXML just send first line
I have a problem trying to send a file xml between Android and a servlet with POST. I'm using ( Simple XML ) for the serializing. My servlet do the response to Android: Serializer serial = new Persister(); OutputStream o = response.getOutputStream(); MyXML myXML = new MyXML(); myXML.setMyElement("test"); serial.write(...
Private access on 'a' might be a problem. Use the POJO options: @Root(name="MyXML") public class MyXML{ private String a; @Element(name="MyElement") public void setMyElement(String a){ this.a=a; } @Element(name="MyElement") public String getMyElement() { return a; } } Let me know if that works for you.
Serializer SimpleXML just send first line I have a problem trying to send a file xml between Android and a servlet with POST. I'm using ( Simple XML ) for the serializing. My servlet do the response to Android: Serializer serial = new Persister(); OutputStream o = response.getOutputStream(); MyXML myXML = new MyXML();...
TITLE: Serializer SimpleXML just send first line QUESTION: I have a problem trying to send a file xml between Android and a servlet with POST. I'm using ( Simple XML ) for the serializing. My servlet do the response to Android: Serializer serial = new Persister(); OutputStream o = response.getOutputStream(); MyXML my...
[ "java", "android", "xml", "servlets", "outputstream" ]
3
1
2,233
1
0
2011-06-01T01:51:39.173000
2011-06-01T04:00:07.820000
6,195,451
6,195,461
how to get wp include directory?
I need to do require_once for my wp plugin development. It seems to me that I need to use absolute path. my current solution is $delimiter = strpos(dirname(__FILE__), "/")!==false?"/":"\\"; //win or unix? $path = explode($delimiter, dirname(__FILE__)); require_once join(array_slice($path,0,count($path)-3),$delimiter)....
Try: require_once realpath(__DIR__.'/../../..').'/wp-admin/includes/plugin.php'; Or replace __DIR__ with dirname(__FILE__) if you are on < PHP 5.3 Or you could try: require_once ABSPATH. WPINC. '/plugin.php';
how to get wp include directory? I need to do require_once for my wp plugin development. It seems to me that I need to use absolute path. my current solution is $delimiter = strpos(dirname(__FILE__), "/")!==false?"/":"\\"; //win or unix? $path = explode($delimiter, dirname(__FILE__)); require_once join(array_slice($pa...
TITLE: how to get wp include directory? QUESTION: I need to do require_once for my wp plugin development. It seems to me that I need to use absolute path. my current solution is $delimiter = strpos(dirname(__FILE__), "/")!==false?"/":"\\"; //win or unix? $path = explode($delimiter, dirname(__FILE__)); require_once jo...
[ "php", "wordpress" ]
8
16
21,824
5
0
2011-06-01T01:52:03.647000
2011-06-01T01:55:22.667000
6,195,453
6,202,760
How to change the label of view/results buttons in Webform drupal-7
I am a newbie in drupal, webform and php. Actually I have installed the drupal-7 with the webform module and I want to modify the text of options i.e. "view" to "create project" and "Results" to "View Projects"... I searched for solution and I noticed that best option is to create a custom module and use hook_form_alte...
"View" and "Results" are actually menu items, which you can modify by implementing hook_menu_alter(). http://drupal.org/node/483324 The following code in a custom module (change MODULENAME to the name of your module) will update the "Results" tab without a hitch, however the "View" tab is trickier because that's the co...
How to change the label of view/results buttons in Webform drupal-7 I am a newbie in drupal, webform and php. Actually I have installed the drupal-7 with the webform module and I want to modify the text of options i.e. "view" to "create project" and "Results" to "View Projects"... I searched for solution and I noticed ...
TITLE: How to change the label of view/results buttons in Webform drupal-7 QUESTION: I am a newbie in drupal, webform and php. Actually I have installed the drupal-7 with the webform module and I want to modify the text of options i.e. "view" to "create project" and "Results" to "View Projects"... I searched for solut...
[ "drupal-7", "drupal-webform" ]
0
1
1,703
2
0
2011-06-01T01:52:05.287000
2011-06-01T14:25:04.690000
6,195,455
6,210,201
why do I get this error building a static library for my iPhone project using XCode 4?
I have an existing iPhone application, and I just wanted to make a static library out of the code, so that I can use it by a separate test application (within the workspace). The application compiles fine, but when I try to compile the library version (which has the same code files) I get the following error: Lexical o...
So, the issue turned out to be I had "-ObjC" set in the "Other Link Flags" option, which I'd put there as at one stage trying to get things working I read this was required - Dereks advice to review the compilation log worked well here
why do I get this error building a static library for my iPhone project using XCode 4? I have an existing iPhone application, and I just wanted to make a static library out of the code, so that I can use it by a separate test application (within the workspace). The application compiles fine, but when I try to compile t...
TITLE: why do I get this error building a static library for my iPhone project using XCode 4? QUESTION: I have an existing iPhone application, and I just wanted to make a static library out of the code, so that I can use it by a separate test application (within the workspace). The application compiles fine, but when ...
[ "iphone", "objective-c", "xcode", "ios", "xcode4" ]
0
2
1,308
2
0
2011-06-01T01:52:23.743000
2011-06-02T03:58:17.613000
6,195,463
6,195,539
PHP returning strange row counts
i am working with a very large data set (786,432 rows to be precise). So, to prevent memory limits I want to loop over the data set in piles of 50,000 rows, so to test this out I thought I would try: function test(){ $start = 0; $end = 50000; $q = $this->db->select('uuid')->from('userRegionLink')->limit($end, $start)-...
It looks like $end is not a global offset just number of records to fetch (offset from $start). Try to set $end always for 50000 and changing only $start.
PHP returning strange row counts i am working with a very large data set (786,432 rows to be precise). So, to prevent memory limits I want to loop over the data set in piles of 50,000 rows, so to test this out I thought I would try: function test(){ $start = 0; $end = 50000; $q = $this->db->select('uuid')->from('userR...
TITLE: PHP returning strange row counts QUESTION: i am working with a very large data set (786,432 rows to be precise). So, to prevent memory limits I want to loop over the data set in piles of 50,000 rows, so to test this out I thought I would try: function test(){ $start = 0; $end = 50000; $q = $this->db->select('u...
[ "mysql", "codeigniter", "mysql-num-rows" ]
0
1
57
1
0
2011-06-01T01:56:23.557000
2011-06-01T02:11:30.787000
6,195,464
6,195,491
How to make a threadsafe call to a 3rd party API (OAuth)?
I'm calling a 3rd party API that uses OAuth for authentication, and I'm wondering how to make this threadsafe: var token = _tokenService.GetCurrentToken(); // eg token could be "ABCDEF" var newToken = oauth.RenewAccessToken(token); // eg newToken could be "123456" _tokenService.UpdateCurrentToken(newToken); // save new...
EDIT Given that this is an ASP.NET application, the easy route (a Monitor lock using a lock { } block) is not suitable. You'll need to use a named Mutex in order to solve this problem. Given your example code, something along these lines would work: using(var m = new Mutex("OAuthToken")) { m.WaitOne(); try { var token...
How to make a threadsafe call to a 3rd party API (OAuth)? I'm calling a 3rd party API that uses OAuth for authentication, and I'm wondering how to make this threadsafe: var token = _tokenService.GetCurrentToken(); // eg token could be "ABCDEF" var newToken = oauth.RenewAccessToken(token); // eg newToken could be "12345...
TITLE: How to make a threadsafe call to a 3rd party API (OAuth)? QUESTION: I'm calling a 3rd party API that uses OAuth for authentication, and I'm wondering how to make this threadsafe: var token = _tokenService.GetCurrentToken(); // eg token could be "ABCDEF" var newToken = oauth.RenewAccessToken(token); // eg newTok...
[ "c#", "oauth", "thread-safety" ]
1
4
426
1
0
2011-06-01T01:57:10.467000
2011-06-01T02:02:14.707000
6,195,467
6,195,758
How do i design database and get data by Category in android
For example data if i categorize data to 3 group: Attraction, City landmark, Park id title content address category 1 GeneralPark xxxxxxxxxxx 1234road Park 2 GreatMuseum wwwwwwwwww 9877road Attraction Look at General Park. its category is Park. and it also in Attraction category. the question is.. how can i design da...
Don't put two things (i.e. 'Park,Attraction') in one column, that is almost always a mistake. The usual way to deal with this situation is to add another table with two columns: create table place_categories ( place_id int not null references place(id), category varchar(255) not null, primary key (place_id, category) )...
How do i design database and get data by Category in android For example data if i categorize data to 3 group: Attraction, City landmark, Park id title content address category 1 GeneralPark xxxxxxxxxxx 1234road Park 2 GreatMuseum wwwwwwwwww 9877road Attraction Look at General Park. its category is Park. and it also ...
TITLE: How do i design database and get data by Category in android QUESTION: For example data if i categorize data to 3 group: Attraction, City landmark, Park id title content address category 1 GeneralPark xxxxxxxxxxx 1234road Park 2 GreatMuseum wwwwwwwwww 9877road Attraction Look at General Park. its category is ...
[ "android", "sql", "database", "cursor" ]
0
1
186
2
0
2011-06-01T01:57:34.520000
2011-06-01T02:51:32.690000
6,195,468
6,195,707
Firefox : Difference between window, document, document.content & content
Developing an extension in Firefox and seems my mistakes are stemming from the fact that I don't understand the differences between what the below mean. Would be great if someone could point, when exactly to use them. Can someone who has worked with Firefox explain it please. I've added what I understand and they might...
In an extension, document is the XUL document for the browser's UI. window is the window for that document (the object used as the script global for the chrome JS, etc). content.document is the document object for the web page in the currently selected tab. content is the window object for the web page in the currently...
Firefox : Difference between window, document, document.content & content Developing an extension in Firefox and seems my mistakes are stemming from the fact that I don't understand the differences between what the below mean. Would be great if someone could point, when exactly to use them. Can someone who has worked w...
TITLE: Firefox : Difference between window, document, document.content & content QUESTION: Developing an extension in Firefox and seems my mistakes are stemming from the fact that I don't understand the differences between what the below mean. Would be great if someone could point, when exactly to use them. Can someon...
[ "firefox", "architecture", "scope" ]
0
1
566
1
0
2011-06-01T01:57:40.797000
2011-06-01T02:44:53.097000
6,195,472
6,195,480
Why won't CSS3 border radius work on images on webkit browsers (Chrome and Safari)?
This works in firefox 4 and ie9 but not chrome or safari. It also doesn't work in opera but who cares about that. So how to get it to work? img { width: 100px; height: 100px; border: 3px solid #fff; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; }
A workaround is to use a div and set the background of the div to the image..rounded { width: 100px; height: 100px; border: 3px solid #fff; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; background: url(image.png) no-repeat; }
Why won't CSS3 border radius work on images on webkit browsers (Chrome and Safari)? This works in firefox 4 and ie9 but not chrome or safari. It also doesn't work in opera but who cares about that. So how to get it to work? img { width: 100px; height: 100px; border: 3px solid #fff; -moz-border-radius: 10px; -webkit-bo...
TITLE: Why won't CSS3 border radius work on images on webkit browsers (Chrome and Safari)? QUESTION: This works in firefox 4 and ie9 but not chrome or safari. It also doesn't work in opera but who cares about that. So how to get it to work? img { width: 100px; height: 100px; border: 3px solid #fff; -moz-border-radius...
[ "html", "css", "cross-browser" ]
0
4
886
2
0
2011-06-01T01:58:26.753000
2011-06-01T02:00:27.750000
6,195,478
6,195,783
Max image size on file upload
I have an ImageField in my form. How would I enforce a file size min/max, something like -- image = forms.ImageField(max_size = 2MB) or image = forms.ImageField(min_size = 100k) Thank you.
models.py class Product(models.Model): image = models.ImageField(upload_to="/a/b/c/") forms.py class ProductForm(forms.ModelForm): # Add some custom validation to our image field def clean_image(self): image = self.cleaned_data.get('image', False) if image: if image._size > 4*1024*1024: raise ValidationError("Image fil...
Max image size on file upload I have an ImageField in my form. How would I enforce a file size min/max, something like -- image = forms.ImageField(max_size = 2MB) or image = forms.ImageField(min_size = 100k) Thank you.
TITLE: Max image size on file upload QUESTION: I have an ImageField in my form. How would I enforce a file size min/max, something like -- image = forms.ImageField(max_size = 2MB) or image = forms.ImageField(min_size = 100k) Thank you. ANSWER: models.py class Product(models.Model): image = models.ImageField(upload_to...
[ "django", "image-processing", "django-forms" ]
50
59
49,115
3
0
2011-06-01T02:00:16.190000
2011-06-01T02:57:32.990000
6,195,481
6,195,509
Recovering a crashed InputStream
I'm writing a server and I'm using an ObjectInputStream to handle proprietary packets. I've recently been sometimes getting some unexpected ClassCastException s when I want call objectInputStream.readObject() and then trying casting them into the proprietary packets. I've been trying to trace the problem and I've been ...
If I understand correctly, your exceptions aren't caused by objectInputStream.readObject(), but by casting the (successfully returned) object to whatever it is you're trying to read, so the exception shouldn't affect the stream.
Recovering a crashed InputStream I'm writing a server and I'm using an ObjectInputStream to handle proprietary packets. I've recently been sometimes getting some unexpected ClassCastException s when I want call objectInputStream.readObject() and then trying casting them into the proprietary packets. I've been trying to...
TITLE: Recovering a crashed InputStream QUESTION: I'm writing a server and I'm using an ObjectInputStream to handle proprietary packets. I've recently been sometimes getting some unexpected ClassCastException s when I want call objectInputStream.readObject() and then trying casting them into the proprietary packets. I...
[ "java", "stream", "inputstream", "classcastexception", "recover" ]
1
1
283
1
0
2011-06-01T02:00:31.697000
2011-06-01T02:04:50.323000