qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
403,549
<p>Can you describe the pros and cons of including an <a href="http://en.wikipedia.org/wiki/Object_identifier" rel="nofollow noreferrer">OID</a> (typically a database row identifier) in a <a href="http://en.wikipedia.org/wiki/Plain_Old_Java_Object" rel="nofollow noreferrer">POJO</a> representing an entity in your model...
[ { "answer_id": 403571, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 1, "selected": false, "text": "<p>Database row identifier = Primary key? If so, there is no pro or con, you have to have it otherwise you can't rela...
2008/12/31
[ "https://Stackoverflow.com/questions/403549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50114/" ]
Can you describe the pros and cons of including an [OID](http://en.wikipedia.org/wiki/Object_identifier) (typically a database row identifier) in a [POJO](http://en.wikipedia.org/wiki/Plain_Old_Java_Object) representing an entity in your model? In fact I'm not talking about issues related to equals/hashcode and so on,...
Database row identifier = Primary key? If so, there is no pro or con, you have to have it otherwise you can't relate the POJO back to its corresponding database row. To retrieve Products and Catalogs, the standard SQL way is to do a Join. For example, with my DAL I can do: ``` SearchCriteria sc = new SearchCriteria()...
403,560
<p>I want to store part of an id, and throw out the rest. For example, I have an html element with an id of 'element-12345'. I want to throw out 'element-' and keep '12345'. How can I accomplish this?</p> <p>I can capture and echo the value, like this:</p> <pre>| storeAttribute | //pathToMyElement@id | myId | | echo ...
[ { "answer_id": 403598, "author": "Salty", "author_id": 50548, "author_profile": "https://Stackoverflow.com/users/50548", "pm_score": 2, "selected": false, "text": "<p>/element-(\\d+)/i</p>\n\n<p>That's a regular expression that would capture the numbers after the dash.</p>\n" }, { ...
2008/12/31
[ "https://Stackoverflow.com/questions/403560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48523/" ]
I want to store part of an id, and throw out the rest. For example, I have an html element with an id of 'element-12345'. I want to throw out 'element-' and keep '12345'. How can I accomplish this? I can capture and echo the value, like this: ``` | storeAttribute | //pathToMyElement@id | myId | | echo | ${!-myId-!} |...
The solution is to use the JavaScript `replace()` function with `storeEval`: ``` | storeAttribute | //pathToMyElement@id | elementID | | storeEval | '${elementID}'.replace("element-", "") | myID | ``` Now if I echo `myID` I get just the ID: ``` | echo | ${...
403,572
<p>I would like to use RNGCryptoServiceProvider as my source of random numbers. As it only can output them as an array of byte values how can I convert them to 0 to 1 double value while preserving uniformity of results?</p>
[ { "answer_id": 403613, "author": "Michael Bray", "author_id": 50356, "author_profile": "https://Stackoverflow.com/users/50356", "pm_score": -1, "selected": false, "text": "<p>You can use the BitConverter.ToDouble(...) method. It takes in a byte array and will return a Double. Thre are ...
2008/12/31
[ "https://Stackoverflow.com/questions/403572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3515/" ]
I would like to use RNGCryptoServiceProvider as my source of random numbers. As it only can output them as an array of byte values how can I convert them to 0 to 1 double value while preserving uniformity of results?
``` byte[] result = new byte[8]; rng.GetBytes(result); return (double)BitConverter.ToUInt64(result,0) / ulong.MaxValue; ```
403,619
<p><li> When does using extension methods make sense? <li> Does adding extension methods to a type affect performance?</p> <p>These questions are follow up to the question i asked earlier about <a href="https://stackoverflow.com/questions/403539/what-are-extension-methods">Extension Methods</a>.</p>
[ { "answer_id": 403627, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 2, "selected": false, "text": "<p><em>From my answer <a href=\"https://stackoverflow.com/questions/403539/what-are-extension-methods#403556\">here<...
2008/12/31
[ "https://Stackoverflow.com/questions/403619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
- When does using extension methods make sense? - Does adding extension methods to a type affect performance? These questions are follow up to the question i asked earlier about [Extension Methods](https://stackoverflow.com/questions/403539/what-are-extension-methods).
When does using extension methods make sense? --------------------------------------------- They make sense when you are using LINQ and want to chain or pipe functional output from one function to another. It improves the readability of the code and allows you to express a concept more elegantly (whatever that is wort...
403,630
<p>I need to search across multiple columns from two tables in my database using Full-Text Search. The two tables in question have the relevant columns full-text indexed.</p> <p>The reason I'm opting for Full-text search: 1. To be able to search accented words easily (cafè) 2. To be able to rank according to word prox...
[ { "answer_id": 403673, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 1, "selected": false, "text": "<p>I would use a stored procedure. The full text method or whatever returns a rank which you can sort by. I am not sure how they w...
2008/12/31
[ "https://Stackoverflow.com/questions/403630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6939/" ]
I need to search across multiple columns from two tables in my database using Full-Text Search. The two tables in question have the relevant columns full-text indexed. The reason I'm opting for Full-text search: 1. To be able to search accented words easily (cafè) 2. To be able to rank according to word proximity, etc...
Using FREETEXTTABLE, you just need to design some algorithm to calculate the merged rank on each joined table result. The example below skews the result towards hits from the book table. ``` SELECT b.Name, a.Name, bkt.[Rank] + akt.[Rank]/2 AS [Rank] FROM Book b INNER JOIN Author a ON b.AuthorID = a.AuthorID INNER JOIN...
403,643
<p>In .NET, what type of exception should be thrown if someone passes an illegal value to the <code>set { }</code> part of a property?</p> <p>Example:</p> <pre><code>public string Provider { get { return _provider; } set { if (String.IsNullOrEmpty(value)) throw new Exception("Provider cannot be nu...
[ { "answer_id": 403656, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx\" rel=\"nofollow noreferrer\">ArgumentEx...
2008/12/31
[ "https://Stackoverflow.com/questions/403643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
In .NET, what type of exception should be thrown if someone passes an illegal value to the `set { }` part of a property? Example: ``` public string Provider { get { return _provider; } set { if (String.IsNullOrEmpty(value)) throw new Exception("Provider cannot be null or empty."); //what type of e...
[ArgumentException](http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx), ArgumentOutOfRangeException, ArgumentNullException or similar.
403,662
<p>How do I convert a string into an array of integers? Can I use <code>sstream</code>, because <code>atoi</code> doesn't work?!</p>
[ { "answer_id": 403680, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 2, "selected": false, "text": "<p>How exactly would you like the conversion to work?\nDo you simply want an array containing the ASCII value of each charact...
2008/12/31
[ "https://Stackoverflow.com/questions/403662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20730/" ]
How do I convert a string into an array of integers? Can I use `sstream`, because `atoi` doesn't work?!
How exactly would you like the conversion to work? Do you simply want an array containing the ASCII value of each character in the array? (so "abc" becomes [97, 98, 99, 0])? Or do you want to parse the string somehow? ("1, 2, 3" becomes an array [1, 2, 3]) In the first case, in C++, I'd do something like this: ``` s...
403,703
<p>I've just deployed a new site using Zend Framework. Due to the popularity of my tutorials I'd like to redirect any request for a tutorial to the relevant page on the new site. So far this is what I've got:</p> <p>URL before Rewrite: <a href="http://neranjara.org/tutorials/?tid=56" rel="nofollow noreferrer">http://n...
[ { "answer_id": 403864, "author": "lpfavreau", "author_id": 35935, "author_profile": "https://Stackoverflow.com/users/35935", "pm_score": 2, "selected": false, "text": "<p>The query string (the parameters passed to your file) won't be in the RewriteRule.</p>\n\n<p>Taken from <a href=\"htt...
2008/12/31
[ "https://Stackoverflow.com/questions/403703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47440/" ]
I've just deployed a new site using Zend Framework. Due to the popularity of my tutorials I'd like to redirect any request for a tutorial to the relevant page on the new site. So far this is what I've got: URL before Rewrite: <http://neranjara.org/tutorials/?tid=56> URL after Rewrite: <http://neranjara.org/article/id...
The query string (the parameters passed to your file) won't be in the RewriteRule. Taken from <http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule>: > > The Pattern will not be matched > against the query string. Instead, you > must use a RewriteCond with the > %{QUERY\_STRING} variable. You can, > ...
403,731
<p>Two machines. Both with .NET 3.5 and the VS 2008 VC++ SP1 redistributables</p> <p>A single exe which uses two signed DLLs, one in C++/CLI and one in C#</p> <p>The exe loads and runs fine on one machine.</p> <p>On the other, I get "Strong Name Validation Failed" on the C++ executable (HRESULT 0x8013141A)</p> <p>A...
[ { "answer_id": 785713, "author": "Colin Desmond", "author_id": 93399, "author_profile": "https://Stackoverflow.com/users/93399", "pm_score": 3, "selected": false, "text": "<p>Is the one the code runs on a \"development\" machine where you might have run \"sn.exe -Vr AssemblyName.dll\" at...
2008/12/31
[ "https://Stackoverflow.com/questions/403731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Two machines. Both with .NET 3.5 and the VS 2008 VC++ SP1 redistributables A single exe which uses two signed DLLs, one in C++/CLI and one in C# The exe loads and runs fine on one machine. On the other, I get "Strong Name Validation Failed" on the C++ executable (HRESULT 0x8013141A) Any ideas?
Open the command prompt as administrator and enter following commands: ``` reg DELETE "HKLM\Software\Microsoft\StrongName\Verification" /f reg ADD "HKLM\Software\Microsoft\StrongName\Verification\*,*" /f reg DELETE "HKLM\Software\Wow6432Node\Microsoft\StrongName\Verification" /f reg ADD "HKLM\Software\Wow6432Node\Micr...
403,736
<p>I am attempting to center my entire page using only CSS and it is proving more complicated than i first expected. Currently my code works in IE but not in Firefox which makes a change. The page can be seen <a href="http://www.ronnieweb.co.cc/test/index.html" rel="nofollow noreferrer">here</a>. Below is the code port...
[ { "answer_id": 403743, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 4, "selected": true, "text": "<p>Change your markup to </p>\n\n<pre><code>&lt;body&gt;\n&lt;div id=\"wrap\"&gt;\n Gubbins in here.\n&lt;/div&gt;\n&...
2008/12/31
[ "https://Stackoverflow.com/questions/403736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50057/" ]
I am attempting to center my entire page using only CSS and it is proving more complicated than i first expected. Currently my code works in IE but not in Firefox which makes a change. The page can be seen [here](http://www.ronnieweb.co.cc/test/index.html). Below is the code portion involved: ``` #wrap { width: 96...
Change your markup to ``` <body> <div id="wrap"> Gubbins in here. </div> </body> ``` EDIT: Looking at the link, you've already done that. You'll want to either add overflow:auto; to #wrap or add a clearing div at the end just before the closing tag on the wrap div. Also, on your example page, the wrap div is m...
403,748
<p>I would like to use a custom version of the standard disclosure accessory image in my UITableView. How can I do this? I'm hoping that sub-classing UITableViewCell is not necessary for something this basic.</p>
[ { "answer_id": 403796, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 8, "selected": true, "text": "<p>You'll need to create a custom view and assign it to the <code>accessoryView</code> property of the <code>UITableViewC...
2008/12/31
[ "https://Stackoverflow.com/questions/403748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
I would like to use a custom version of the standard disclosure accessory image in my UITableView. How can I do this? I'm hoping that sub-classing UITableViewCell is not necessary for something this basic.
You'll need to create a custom view and assign it to the `accessoryView` property of the `UITableViewCell` object. Something like: ``` myCell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"Something" ]]; ```
403,756
<p>In my quest in trying to learn more about OOP in PHP. I have come across the constructor function a good few times and simply can't ignore it anymore. In my understanding, the constructor is called upon the moment I create an object, is this correct?</p> <p>But why would I need to create this constructor if I can u...
[ { "answer_id": 403766, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 4, "selected": true, "text": "<p>Yes the constructor is called when the object is created.</p>\n\n<p>A small example of the usefulness of a construc...
2008/12/31
[ "https://Stackoverflow.com/questions/403756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37418/" ]
In my quest in trying to learn more about OOP in PHP. I have come across the constructor function a good few times and simply can't ignore it anymore. In my understanding, the constructor is called upon the moment I create an object, is this correct? But why would I need to create this constructor if I can use "normal...
Yes the constructor is called when the object is created. A small example of the usefulness of a constructor is this ``` class Bar { // The variable we will be using within our class var $val; // This function is called when someone does $foo = new Bar(); // But this constructor has also an $var with...
403,769
<p>I'm using .net 2.0 with Visual Studio 2005 and I am trying to add two different toolstrips to the top of the form such that they show up side-by-side. I want it to be like Word 2003, where you can add multiple toolstrips to the same row and have them show up in line with each other, rather than dedicating a row to ...
[ { "answer_id": 469868, "author": "Wyzfen", "author_id": 15261, "author_profile": "https://Stackoverflow.com/users/15261", "pm_score": 4, "selected": true, "text": "<p>I created a custom ToolStripPanel so that I could overload the LayoutEngine;</p>\n\n<pre><code>using System.Drawing;\nusi...
2008/12/31
[ "https://Stackoverflow.com/questions/403769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22392/" ]
I'm using .net 2.0 with Visual Studio 2005 and I am trying to add two different toolstrips to the top of the form such that they show up side-by-side. I want it to be like Word 2003, where you can add multiple toolstrips to the same row and have them show up in line with each other, rather than dedicating a row to each...
I created a custom ToolStripPanel so that I could overload the LayoutEngine; ``` using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.Layout; namespace CustomGUI { class CustomToolStripPanel : ToolStripPanel { private LayoutEngine _layoutEngine; public override LayoutEngine Layout...
403,794
<p>Well I was reading this <a href="http://handyfloss.wordpress.com/2008/02/17/summary-of-my-python-optimization-adventures/" rel="noreferrer">post</a> and then I came across a code which was:</p> <pre><code>jokes=range(1000000) domain=[(0,(len(jokes)*2)-i-1) for i in range(0,len(jokes)*2)] </code></pre> <p>I thought...
[ { "answer_id": 403801, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 1, "selected": false, "text": "<p>On a tangentially related note, chaining together generators is much more efficient than chaining together list comprehen...
2008/12/31
[ "https://Stackoverflow.com/questions/403794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33612/" ]
Well I was reading this [post](http://handyfloss.wordpress.com/2008/02/17/summary-of-my-python-optimization-adventures/) and then I came across a code which was: ``` jokes=range(1000000) domain=[(0,(len(jokes)*2)-i-1) for i in range(0,len(jokes)*2)] ``` I thought wouldn't it be better to calculate the value of len(j...
You're not using [`timeit`](http://docs.python.org/library/timeit.html) correctly: the argument to `-s` (setup) is a statement to be executed once initially, so you're really just testing an empty statement. You want to do ``` $ python -m timeit -s "jokes=range(1000000)" "domain=[(0,(len(jokes)*2)-i-1) for i in range(...
403,798
<p>In my view I have an alphabet based selector, to select manufacturers by the first letter of their name. I got that part working. But I have manufacturers whose name starts with a number, for example 3M, or 3DLabs. In the view I have the character "#" to group all those. What should my query/find method look like to...
[ { "answer_id": 403814, "author": "Mitchell Gilman", "author_id": 43219, "author_profile": "https://Stackoverflow.com/users/43219", "pm_score": 2, "selected": false, "text": "<p>You probably want to use a Regular Expression.</p>\n\n<p>What language are you using? </p>\n\n<p>Here is the S...
2008/12/31
[ "https://Stackoverflow.com/questions/403798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In my view I have an alphabet based selector, to select manufacturers by the first letter of their name. I got that part working. But I have manufacturers whose name starts with a number, for example 3M, or 3DLabs. In the view I have the character "#" to group all those. What should my query/find method look like to re...
You probably want to use a Regular Expression. What language are you using? Here is the SQL2005 version: ``` select * from myTable where myField like '[^a-z]%' ```
403,815
<p>I'm writing an application that gets data from URLs, but I want to make it an option whether or not the user uses "clean" urls (ex: <a href="http://example.com/hello/world" rel="nofollow noreferrer">http://example.com/hello/world</a>) or "dirty" urls (ex: <a href="http://example.com/?action=hello&amp;sub=world" rel=...
[ { "answer_id": 403823, "author": "alex", "author_id": 50564, "author_profile": "https://Stackoverflow.com/users/50564", "pm_score": 0, "selected": false, "text": "<p>sounds like a pain, but i guess create a function that analyzes the URL for every request. First determine if it's \"dirty...
2008/12/31
[ "https://Stackoverflow.com/questions/403815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29291/" ]
I'm writing an application that gets data from URLs, but I want to make it an option whether or not the user uses "clean" urls (ex: <http://example.com/hello/world>) or "dirty" urls (ex: <http://example.com/?action=hello&sub=world>). What would be the best way to get variables form both URL schemes?
If your mod\_rewrite has a rule like the following: ``` RewriteRule ^hello/world /?action=hello&sub=world [NC,L] ``` or, the more generalised: ``` // Assuming only lowercase letters in action & sub.. RewriteRule ^([a-z]+)/([a-z]+) /?action=$1&sub=$2 [NC,L] ``` then the same PHP script is being called, with the `$...
403,820
<p>I'm trying for the past several hours to figure out how to do this, but with no luck. There are several potential solutions for this when searching Google, but nothing seems to work.</p> <p>I'm trying to customize the background color of the standard UILabel that goes in a UITableViewCell (since I already customize...
[ { "answer_id": 403827, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 2, "selected": true, "text": "<p>It appears that you're assigning the text to the cell instead of the label. You probably want:</p>\n\n<pre><code>label...
2008/12/31
[ "https://Stackoverflow.com/questions/403820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
I'm trying for the past several hours to figure out how to do this, but with no luck. There are several potential solutions for this when searching Google, but nothing seems to work. I'm trying to customize the background color of the standard UILabel that goes in a UITableViewCell (since I already customized the back...
It appears that you're assigning the text to the cell instead of the label. You probably want: ``` label.text = @"Sample text here"; ``` Also, you'll need to set the label's frame to what you require: ``` label.frame = CGRectMake(10,10, 80, 40); ``` or directly in the constructor: ``` label = [[UILabel alloc] in...
403,822
<p>I have a file called main.py and a file called classes.py</p> <p>main.py contains the application and what's happening while class.py contains some classes.</p> <p>main.py has the following code</p> <p><strong>main.py</strong></p> <pre><code>import classes def addItem(text): print text myClass = classes.Ex...
[ { "answer_id": 403832, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 4, "selected": true, "text": "<p>I couldn't answer this any better than <a href=\"http://mail.python.org/pipermail/python-list/2000-December/059926.html\" rel=...
2008/12/31
[ "https://Stackoverflow.com/questions/403822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
I have a file called main.py and a file called classes.py main.py contains the application and what's happening while class.py contains some classes. main.py has the following code **main.py** ``` import classes def addItem(text): print text myClass = classes.ExampleClass() ``` And then we have classes.py ...
I couldn't answer this any better than [this post by Alex Martelli](http://mail.python.org/pipermail/python-list/2000-December/059926.html). Basically any way you try to do this will lead to trouble and you are much better off refactoring the code to avoid mutual dependencies between two modules... If you have two mo...
403,836
<p>I have a function that identify coordinates on a page, and I am returning them as a</p> <pre><code>Dictionary&lt;int, Collection&lt;Rectangle&gt;&gt; GetDocumentCoordinates(int DocumentId) </code></pre> <p>However, later I need information about each page - if it was validated, what is the page resolution, color/b...
[ { "answer_id": 403862, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>It seems like you need a lot of data out. The last option should be fine, and is extensible; it you wanted (to sim...
2008/12/31
[ "https://Stackoverflow.com/questions/403836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48684/" ]
I have a function that identify coordinates on a page, and I am returning them as a ``` Dictionary<int, Collection<Rectangle>> GetDocumentCoordinates(int DocumentId) ``` However, later I need information about each page - if it was validated, what is the page resolution, color/bw, etc. I could create another functio...
The last option is definitely the best. I've found that, when taking or returning complex data with multiple meanings, creating a complex type to encapsulate this data is the best practice for a number of reasons. First, your return data probably will change as your design changes. Encapsulating this data in an objec...
403,846
<p>What would be the best way to loop through all radio buttons on my page and alert the user if one of them is unchecked for a particular question?</p> <p>Note: there are multiple questions on one page.</p> <pre><code>&lt;li&gt; &lt;fieldset&gt; &lt;h3&gt;What music do you listen to?&lt;/h3&gt; &lt;ul...
[ { "answer_id": 403889, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 2, "selected": false, "text": "<p>Try these:</p>\n\n<p><a href=\"https://stackoverflow.com/questions/249214/find-all-radio-groups-whic...
2008/12/31
[ "https://Stackoverflow.com/questions/403846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48973/" ]
What would be the best way to loop through all radio buttons on my page and alert the user if one of them is unchecked for a particular question? Note: there are multiple questions on one page. ``` <li> <fieldset> <h3>What music do you listen to?</h3> <ul class="answerList"> <li> ...
``` if (undefined === $("input[name='answer8']:checked").val()) { // do something } ```
403,865
<p>I have a list of numbers and I want to add up all the different combinations. For example:</p> <ul> <li>number as 1,4,7 and 13</li> <li>the output would be:</li> </ul> <p><br></p> <pre><code>1+4=5 1+7=8 1+13=14 4+7=11 4+13=17 7+13=20 1+4+7=12 1+4+13=18 1+7+13=21 4+7+13=24 1+4+7+13=25 </code></pre> <p>Is there a ...
[ { "answer_id": 403882, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 2, "selected": false, "text": "<p>You can enumerate all subsets using a bitvector.</p>\n\n<p>In a for loop, go from 0 to 2 to the Nth power minus 1 (or...
2008/12/31
[ "https://Stackoverflow.com/questions/403865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50577/" ]
I have a list of numbers and I want to add up all the different combinations. For example: * number as 1,4,7 and 13 * the output would be: ``` 1+4=5 1+7=8 1+13=14 4+7=11 4+13=17 7+13=20 1+4+7=12 1+4+13=18 1+7+13=21 4+7+13=24 1+4+7+13=25 ``` Is there a formula to calculate this with different numbers?
A simple way to do this is to create a bit set with as much bits as there are numbers. In your example 4. Then count from 0001 to 1111 and sum each number that has a 1 on the set: Numbers 1,4,7,13: ``` 0001 = 13=13 0010 = 7=7 0011 = 7+13 = 20 1111 = 1+4+7+13 = 25 ```
403,868
<p>I am using jQuery for my AJAX calls to an ASP.NET backend using <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/" rel="nofollow noreferrer">this approach</a>. I am using .ajaxStart and .ajaxStop to show and hide a progress indicator. When the AJAX request finishes very quickly...
[ { "answer_id": 403882, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 2, "selected": false, "text": "<p>You can enumerate all subsets using a bitvector.</p>\n\n<p>In a for loop, go from 0 to 2 to the Nth power minus 1 (or...
2008/12/31
[ "https://Stackoverflow.com/questions/403868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29426/" ]
I am using jQuery for my AJAX calls to an ASP.NET backend using [this approach](http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/). I am using .ajaxStart and .ajaxStop to show and hide a progress indicator. When the AJAX request finishes very quickly, the progress indicator "blinks" becaus...
A simple way to do this is to create a bit set with as much bits as there are numbers. In your example 4. Then count from 0001 to 1111 and sum each number that has a 1 on the set: Numbers 1,4,7,13: ``` 0001 = 13=13 0010 = 7=7 0011 = 7+13 = 20 1111 = 1+4+7+13 = 25 ```
403,897
<p>sorry for my previous question which was very ambiguous, but i think if i get the answer to this question I can work it out. In the program below i have selected the barcodes of products where the amount is less than the quantity. I want to say, that if the barcodes(in the fridge table) match barcodes in another tab...
[ { "answer_id": 403941, "author": "Adam Peck", "author_id": 26658, "author_profile": "https://Stackoverflow.com/users/26658", "pm_score": 3, "selected": false, "text": "<pre><code>UPDATE products SET stock = 0 WHERE barcode IN ( \n SELECT fridge.barcode FROM fridge WHERE fridge.amount ...
2008/12/31
[ "https://Stackoverflow.com/questions/403897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47204/" ]
sorry for my previous question which was very ambiguous, but i think if i get the answer to this question I can work it out. In the program below i have selected the barcodes of products where the amount is less than the quantity. I want to say, that if the barcodes(in the fridge table) match barcodes in another table(...
``` UPDATE products SET stock = 0 WHERE barcode IN ( SELECT fridge.barcode FROM fridge WHERE fridge.amount < fridge.quantity ); ``` I know this doesn't answer the question exactly but two SQL statements are not required. To do it in python: ``` import MySQLdb def order(): db = MySQLdb.connect(host='localh...
403,924
<p>I have a coworker looking for this, and I don't recall ever running into anything like that.</p> <p>Is there a reasonable technique that would let you simulate it?</p> <pre><code>SELECT PRODUCT(X) FROM ( SELECT 3 X FROM DUAL UNION ALL SELECT 5 X FROM DUAL UNION ALL SELECT 2 X FROM DUAL ) </cod...
[ { "answer_id": 403928, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "<pre><code>DECLARE @a int\nSET @a = 1\n-- re-assign @a for each row in the result\n-- as what @a was before * the value in the...
2008/12/31
[ "https://Stackoverflow.com/questions/403924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
I have a coworker looking for this, and I don't recall ever running into anything like that. Is there a reasonable technique that would let you simulate it? ``` SELECT PRODUCT(X) FROM ( SELECT 3 X FROM DUAL UNION ALL SELECT 5 X FROM DUAL UNION ALL SELECT 2 X FROM DUAL ) ``` would yield 30
``` select exp(sum(ln(col))) from table; ``` edit: if col always > 0
403,929
<p>Consider the following code:</p> <pre><code>#include &lt;stdio.h&gt; namespace Foo { template &lt;typename T&gt; void foo(T *, int) { puts("T"); } template &lt;typename T&gt; struct foo_fun { static void fun() { foo((T *)0, 0); }; }; } namespace Foo { void foo(int *, int) { puts("int"); } } usin...
[ { "answer_id": 403958, "author": "CB Bailey", "author_id": 19563, "author_profile": "https://Stackoverflow.com/users/19563", "pm_score": 4, "selected": true, "text": "<p>The second <code>void foo(...</code> is an overload (and not a specialization) which is not visible at the definition ...
2008/12/31
[ "https://Stackoverflow.com/questions/403929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28888/" ]
Consider the following code: ``` #include <stdio.h> namespace Foo { template <typename T> void foo(T *, int) { puts("T"); } template <typename T> struct foo_fun { static void fun() { foo((T *)0, 0); }; }; } namespace Foo { void foo(int *, int) { puts("int"); } } using namespace Foo; int main() { ...
The second `void foo(...` is an overload (and not a specialization) which is not visible at the definition of `foo_fun::fun` so it won't be found in the context of the template definition. Because `T*` is a dependent type, resolution of `foo` in the expression `foo((T*)0, 0)` will be delayed until template instantiatio...
403,943
<p>I'm not certain where the error is resulting (from silverlight, from wcf, something else...) but, I have a WCF service being called from Silverlight. The method returns a class, with a property that does not have a setter. This throws an error. If I add a setter to the property then it does not give an error.</p> <...
[ { "answer_id": 404713, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 2, "selected": true, "text": "<p>In your example PropertyB is not marked with a DataMember attribute meaning that it won't be exposed in the WSDL ...
2008/12/31
[ "https://Stackoverflow.com/questions/403943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm not certain where the error is resulting (from silverlight, from wcf, something else...) but, I have a WCF service being called from Silverlight. The method returns a class, with a property that does not have a setter. This throws an error. If I add a setter to the property then it does not give an error. The erro...
In your example PropertyB is not marked with a DataMember attribute meaning that it won't be exposed in the WSDL and ignored by the serializer. But if you mark PropertyB with a DataMember then you must have a setter (private, proptected or public) in order to serialize it correctly otherwise you may get an exception. T...
403,967
<p>How can I reference the script element that loaded the javascript that is currently running?</p> <p>Here's the situation. I have a "master" script being loaded high in the page, first thing under the HEAD tag.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/x...
[ { "answer_id": 403986, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": false, "text": "<p>Probably the easiest thing to do would be to give your scrip tag an <code>id</code> attribute.</p>\n" }, { "answer...
2008/12/31
[ "https://Stackoverflow.com/questions/403967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I reference the script element that loaded the javascript that is currently running? Here's the situation. I have a "master" script being loaded high in the page, first thing under the HEAD tag. ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transit...
How to get the current script element: ====================================== 1. Use `document.currentScript` =============================== [`document.currentScript`](https://developer.mozilla.org/en-US/docs/Web/API/document.currentScript) will return the `<script>` element whose script is currently being processed...
404,002
<p>I'm trying to convert from a System.Drawing.Color to a Silverlight System.Windows.Media.Color. I'm actually trying to pass this color through a service.</p> <p>The System.Drawing.Color, passed over the wire, does not serialize the argb value independently.</p> <p>I can convert the argb value to a 32-bit int</p> <...
[ { "answer_id": 403986, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": false, "text": "<p>Probably the easiest thing to do would be to give your scrip tag an <code>id</code> attribute.</p>\n" }, { "answer...
2008/12/31
[ "https://Stackoverflow.com/questions/404002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to convert from a System.Drawing.Color to a Silverlight System.Windows.Media.Color. I'm actually trying to pass this color through a service. The System.Drawing.Color, passed over the wire, does not serialize the argb value independently. I can convert the argb value to a 32-bit int ``` [DataMember] pub...
How to get the current script element: ====================================== 1. Use `document.currentScript` =============================== [`document.currentScript`](https://developer.mozilla.org/en-US/docs/Web/API/document.currentScript) will return the `<script>` element whose script is currently being processed...
404,010
<p>I am writing c# code in .Net 2008 Winforms.</p> <p>I created a print preview window to create a report. It works fine I can preview the report and then print it. The only problem is it is not as flexible as the Office Print preview. The users cannot chose a printer other that the default printer and they cannot lim...
[ { "answer_id": 404026, "author": "Dour High Arch", "author_id": 22437, "author_profile": "https://Stackoverflow.com/users/22437", "pm_score": 3, "selected": false, "text": "<p>Print Preview and Print are different functions and should be different menu options. Choosing Print Preview sho...
2008/12/31
[ "https://Stackoverflow.com/questions/404010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50593/" ]
I am writing c# code in .Net 2008 Winforms. I created a print preview window to create a report. It works fine I can preview the report and then print it. The only problem is it is not as flexible as the Office Print preview. The users cannot chose a printer other that the default printer and they cannot limit the pri...
Print Preview and Print are different functions and should be different menu options. Choosing Print Preview should not print your document, it is entirely likely that a user would want to see what their document looks like laid out on a page without actually printing it. To print a page and allow selecting printer de...
404,015
<p>I am trying to understand the file format of a Visual FoxPro compact index (*.IDX). I am currently referring to <a href="http://msdn.microsoft.com/en-us/library/s8tb8f47(VS.80).aspx" rel="nofollow noreferrer">Microsoft's documentation</a> for guidance.</p> <p>The index is a B-tree of 512-byte nodes. Each leaf ("ext...
[ { "answer_id": 404493, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa975366(VS.71).aspx\" rel=\"nofollow noreferrer\">Microsoft says</a> t...
2008/12/31
[ "https://Stackoverflow.com/questions/404015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41619/" ]
I am trying to understand the file format of a Visual FoxPro compact index (\*.IDX). I am currently referring to [Microsoft's documentation](http://msdn.microsoft.com/en-us/library/s8tb8f47(VS.80).aspx) for guidance. The index is a B-tree of 512-byte nodes. Each leaf ("exterior") node contains multiple entries. Each e...
After discovering the XBase::Index Perl module, I have determined that the keys in the exterior node are effectively the same length as the fixed-length keys found in the interior nodes, except any trailing spaces are removed. That is what the "trailing byte count" mentioned in the documentation refers to (how many tra...
404,019
<p>I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on <a href="http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/" rel="noreferrer">this article</a>).<br/> I've created several windows, and am now attempting to create a common style ...
[ { "answer_id": 404103, "author": "Muad'Dib", "author_id": 49910, "author_profile": "https://Stackoverflow.com/users/49910", "pm_score": 0, "selected": false, "text": "<p>if you load it in Window.Resource, the dictionary is only available for the children of that window. You need to have ...
2008/12/31
[ "https://Stackoverflow.com/questions/404019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50597/" ]
I have a C# (2008/.NET 3.5) class library assembly that supports WPF (based on [this article](http://dotupdate.wordpress.com/2007/12/05/how-to-add-a-wpf-control-library-template-to-visual-c-express-2008/)). I've created several windows, and am now attempting to create a common style set for them. However, as it's a ...
Try adding ``` Style={DynamicResource MyStyle} ``` You cannot use a StaticResource in this case.
404,020
<p>In my Flex interface, I've got a few List components that are data bound to ArrayCollections. I'm finding that when the ArrayCollections are updated (by Web services) and the data bindings for the Lists update, each List is reset and its selectedIndex is dropped. This is a problem if a user is in the middle of a tas...
[ { "answer_id": 404103, "author": "Muad'Dib", "author_id": 49910, "author_profile": "https://Stackoverflow.com/users/49910", "pm_score": 0, "selected": false, "text": "<p>if you load it in Window.Resource, the dictionary is only available for the children of that window. You need to have ...
2008/12/31
[ "https://Stackoverflow.com/questions/404020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40956/" ]
In my Flex interface, I've got a few List components that are data bound to ArrayCollections. I'm finding that when the ArrayCollections are updated (by Web services) and the data bindings for the Lists update, each List is reset and its selectedIndex is dropped. This is a problem if a user is in the middle of a task a...
Try adding ``` Style={DynamicResource MyStyle} ``` You cannot use a StaticResource in this case.
404,024
<p>I'm writing an ItemAdding handler for a SharePoint list, and the list contains multi-user fields. Since the SPItem is not actually available at this point, I think I'm relegated to using the string that comes back from the SPItemEventDataCollection. That string will look something like this when user1, user2, and ...
[ { "answer_id": 404964, "author": "Øyvind Skaar", "author_id": 49194, "author_profile": "https://Stackoverflow.com/users/49194", "pm_score": 0, "selected": false, "text": "<p>This works for me getting a SPSuser from a user field It should be the same thing for extracting it from event dat...
2008/12/31
[ "https://Stackoverflow.com/questions/404024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]
I'm writing an ItemAdding handler for a SharePoint list, and the list contains multi-user fields. Since the SPItem is not actually available at this point, I think I'm relegated to using the string that comes back from the SPItemEventDataCollection. That string will look something like this when user1, user2, and user3...
SPFieldUserValueCollection does exactly what you're looking for. Its constructor accepts an SPWeb and string of users. The SPFieldUserValue items in the collection provide a User property that returns the corresponding SPUser objects for the web. ``` private void ProcessUsers(SPListItem item, string fieldName) { str...
404,029
<p>Not a SQL person at all. Have the following code a consultant wrote. </p> <p>First, it makes sure only an elementary school has been chosen - then, after the BEGIN, if the variable @Term equals a 3 we want to do the stuff under that IF statement. Here's the problem. When @Term is not = 3 we still want to drop ...
[ { "answer_id": 404035, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "<p>If this is MS Sql Server then what you have should work fine... \nIn fact, technically, you don;t need the Begi...
2008/12/31
[ "https://Stackoverflow.com/questions/404029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Not a SQL person at all. Have the following code a consultant wrote. First, it makes sure only an elementary school has been chosen - then, after the BEGIN, if the variable @Term equals a 3 we want to do the stuff under that IF statement. Here's the problem. When @Term is not = 3 we still want to drop down and do the...
It has to do with the Normal Form for the SQL language. `IF` statements can, by definition, only take a **single** SQL statement. However, there is a special kind of SQL statement which can contain multiple SQL statements, the `BEGIN-END` block. If you omit the `BEGIN-END` block, your SQL will run fine, but it will on...
404,043
<p>I've done a lot of research on this,but I'm unable to solve this problem. I've got a Div with several Divs within it that I want to hide before switching on a TinyMCE instance.</p> <p>I'm doing this via jQuery - </p> <pre><code>$(".drop").hide() </code></pre> <p>This works fine, and every browser engine except T...
[ { "answer_id": 404211, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 0, "selected": false, "text": "<p>You could try applying a style that sets the display to something other than none, for example:</p>\n\n<pre><code>.drop\...
2008/12/31
[ "https://Stackoverflow.com/questions/404043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1649/" ]
I've done a lot of research on this,but I'm unable to solve this problem. I've got a Div with several Divs within it that I want to hide before switching on a TinyMCE instance. I'm doing this via jQuery - ``` $(".drop").hide() ``` This works fine, and every browser engine except Trident (IE) hides them. If I inspe...
This is because inside an editable element IE makes everything, including elements hidden with display: none, editable. There's nothing you can do about it except remove the elements you wish to hide from the page's DOM. There's a reference to this behaviour of IE here: <http://msdn.microsoft.com/en-us/library/aa77002...
404,073
<p>My client asked me (a JavaScript client-side programmer) to change the order of the options so that their company's option appears at the top of a select box when the page loads.</p> <p>The following code works in Firefox but fails in Internet Explorer 7 when I try to swap two options:</p> <pre><code> function ...
[ { "answer_id": 404211, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 0, "selected": false, "text": "<p>You could try applying a style that sets the display to something other than none, for example:</p>\n\n<pre><code>.drop\...
2008/12/31
[ "https://Stackoverflow.com/questions/404073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18149/" ]
My client asked me (a JavaScript client-side programmer) to change the order of the options so that their company's option appears at the top of a select box when the page loads. The following code works in Firefox but fails in Internet Explorer 7 when I try to swap two options: ``` function load{ var shi...
This is because inside an editable element IE makes everything, including elements hidden with display: none, editable. There's nothing you can do about it except remove the elements you wish to hide from the page's DOM. There's a reference to this behaviour of IE here: <http://msdn.microsoft.com/en-us/library/aa77002...
404,109
<p>Does anyone have a clue what I name this XML document and where to put it now that I have it created?</p> <p>I would like to provide an OSDD (OpenSearch description document) on my site so that Google Chrome will automatically pick up search capabilities for it. Google tells me that's <a href="http://www.google.com...
[ { "answer_id": 404128, "author": "Micah", "author_id": 17744, "author_profile": "https://Stackoverflow.com/users/17744", "pm_score": 3, "selected": false, "text": "<p>It should be stored in the root directory of you website. You just add a link to it in your webpages like this:</p>\n\n<p...
2008/12/31
[ "https://Stackoverflow.com/questions/404109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48700/" ]
Does anyone have a clue what I name this XML document and where to put it now that I have it created? I would like to provide an OSDD (OpenSearch description document) on my site so that Google Chrome will automatically pick up search capabilities for it. Google tells me that's [how it is done](http://www.google.com/c...
It should be stored in the root directory of you website. You just add a link to it in your webpages like this: ``` <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" /> ```
404,141
<p>First, how do I format the XML processing instruction, is it:</p> <pre><code>&lt;?processingInstructionName attribute="value" attribute2="value2"?&gt; </code></pre> <p>Using StAX, I then want to read it by handling the <code>XMLStreamConstants.PROCESSING_INSTRUCTION</code> (<a href="http://java.sun.com/javase/6/do...
[ { "answer_id": 404355, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 3, "selected": true, "text": "<blockquote>\n<p>1.Is the XML formatting correct?</p>\n</blockquote>\n<p><strong>Yes</strong>, however <strong>do...
2008/12/31
[ "https://Stackoverflow.com/questions/404141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2134/" ]
First, how do I format the XML processing instruction, is it: ``` <?processingInstructionName attribute="value" attribute2="value2"?> ``` Using StAX, I then want to read it by handling the `XMLStreamConstants.PROCESSING_INSTRUCTION` ([javadoc](http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLStreamConstants...
> > 1.Is the XML formatting correct? > > > **Yes**, however **do note that a [processing instruction](http://www.w3.org/TR/2006/REC-xml-20060816/#sec-pi) does not have [attributes](http://www.w3.org/TR/2006/REC-xml-20060816/#attdecls)** -- only data. What looks like attributes are part of the data and some people ...
404,146
<p>On Windows, how can my user-mode program get the driver version number(s) for the video card(s) installed?</p> <p>Programs like ATI's "Catalyst Control Center" can display this information to the user or include it automatically into bug reports. How do they get it?</p> <p>I've been looking thru the PSDK document...
[ { "answer_id": 404356, "author": "BobbyShaftoe", "author_id": 38426, "author_profile": "https://Stackoverflow.com/users/38426", "pm_score": 0, "selected": false, "text": "<p>I've had to solve this problem before. I believe you actually have to get the File Version information of the asso...
2008/12/31
[ "https://Stackoverflow.com/questions/404146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40756/" ]
On Windows, how can my user-mode program get the driver version number(s) for the video card(s) installed? Programs like ATI's "Catalyst Control Center" can display this information to the user or include it automatically into bug reports. How do they get it? I've been looking thru the PSDK documentation, and I can't...
In PowerShell: ``` Get-WmiObject Win32_VideoController | format-table Name, Description,VideoProcessor,DriverVersion ``` The WMI objects are also available from any language that speaks COM or .Net. ETA: You may wish to exclude records without a value for VideoProcessor, like the Live Mesh drivers. I did that by in...
404,163
<pre><code>var y = new w(); var x = y.z; y.z= function() { doOneThing(); x(); } </code></pre> <p><em>where <code>w</code> does not contain a <code>z</code> object but contains other objects (e.g, <code>a</code>, <code>b</code>, <code>c</code>)</em></p> <p>What is <code>x();</code> possibly referring t...
[ { "answer_id": 404168, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "<pre><code>var y = new w();\n\n// Create a global variable x referring to the y.z method\nvar x = y.z;\n\ny.z= function() {\n...
2008/12/31
[ "https://Stackoverflow.com/questions/404163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49881/" ]
``` var y = new w(); var x = y.z; y.z= function() { doOneThing(); x(); } ``` *where `w` does not contain a `z` object but contains other objects (e.g, `a`, `b`, `c`)* What is `x();` possibly referring too? (Again, this is JavaScript) Is the function calling itself?
``` var y = new w(); var x = y.z; # x = undefined ( you say there is no w().z ) y.z= function() { doOneThing(); x(); # undefined, unless doOneThing defines x }; ``` however, if you manage to define x sometime before y.z(); then x() will be whatever it was defined at that time. the following code ...
404,169
<p>While browsing the various option switches for my compiler (GNU C++ 3.2.3 is supported by my organization for my given hardware configuration), I ran across this:</p> <pre><code>-glevel : Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro ex...
[ { "answer_id": 404220, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 2, "selected": false, "text": "<p>I have <strong>tried <code>-g3</code> off and on since 1992</strong> and I have <strong>never gotten it to do any...
2008/12/31
[ "https://Stackoverflow.com/questions/404169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3778/" ]
While browsing the various option switches for my compiler (GNU C++ 3.2.3 is supported by my organization for my given hardware configuration), I ran across this: ``` -glevel : Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when y...
Your question appears to imply that you don't understand what macros are. *Of course* you can't step into a macro. The -g3 is quite useful for "macro heavy" programs. Consider: ``` int main() { int i; for (i = 0; i < 20; ++i) { #define A(x) case x: printf(#x "\n"); break switch(i) { A(1); A(2); A(3); A(...
404,175
<p>I am ftp'ing files from an external server, then deleting them on the external server, and one file failed because there was a space in the filename. I changed my ftp delete command to have quotes around the filename.</p> <pre><code>ftpStream.WriteLine("delete """ &amp; FileToDelete &amp; """") </code></pre> <p>B...
[ { "answer_id": 404190, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 0, "selected": false, "text": "<p>See section 5.3 of the FTP RFC <a href=\"http://www.faqs.org/rfcs/rfc959.html\" rel=\"nofollow noreferrer\">(RFC 959)<...
2008/12/31
[ "https://Stackoverflow.com/questions/404175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22523/" ]
I am ftp'ing files from an external server, then deleting them on the external server, and one file failed because there was a space in the filename. I changed my ftp delete command to have quotes around the filename. ``` ftpStream.WriteLine("delete """ & FileToDelete & """") ``` But, are there other characters that...
Any characters that are reserved by the file system won't be allowed. This usually includes spaces, commas, slashes, colons, quetion marks, double quotes, etc. But as JaredPar mentioned, space is probably the only universal offender since each file system has its own set of reserved characters that don't always overlap...
404,186
<p>i have a stored procedure that creates a table then fills this table somehow from tables of the database then selects everything from this table then drops this table.the problem is,how can i use the selected columns from that dropped table im using DataContext i always put the result of the the stored procedure in ...
[ { "answer_id": 404224, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 1, "selected": false, "text": "<p><strong>EDIT:</strong>\nPlease read the comments left at the end of your question. If you won't participate like eve...
2008/12/31
[ "https://Stackoverflow.com/questions/404186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i have a stored procedure that creates a table then fills this table somehow from tables of the database then selects everything from this table then drops this table.the problem is,how can i use the selected columns from that dropped table im using DataContext i always put the result of the the stored procedure in a l...
**EDIT:** Please read the comments left at the end of your question. If you won't participate like everyone else does it gets confusing and frustrating, and those who would willingly help you will just ignore your request. Please supply some information in your post. If we dont have clear information, we are guessing ...
404,199
<p>This is related to <a href="https://stackoverflow.com/questions/153420/is-it-feasible-to-create-a-rest-client-with-flex">this question</a>. I'm writing a Flex app (a WindowedApplication) that uses REST. Everything's fine when I post with valid authentication, but if I happen to pass an invalid username or password t...
[ { "answer_id": 404251, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 2, "selected": true, "text": "<p>From the Twitter API Doc <a href=\"http://apiwiki.twitter.com/REST+API+Documentation#Authentication\" rel=\"nofollow nor...
2008/12/31
[ "https://Stackoverflow.com/questions/404199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87798/" ]
This is related to [this question](https://stackoverflow.com/questions/153420/is-it-feasible-to-create-a-rest-client-with-flex). I'm writing a Flex app (a WindowedApplication) that uses REST. Everything's fine when I post with valid authentication, but if I happen to pass an invalid username or password to the REST API...
From the Twitter API Doc [here](http://apiwiki.twitter.com/REST+API+Documentation#Authentication): > > suppress\_response\_codes: If this > parameter is present, all responses > will be returned with a 200 OK status > code - even errors. This parameter > exists to accommodate Flash and > JavaScript applications ...
404,226
<p>I know this is a pretty basic question, and I <em>think</em> I know the answer...but I'd like to confirm.</p> <p>Are these queries truly equivalent?</p> <pre><code>SELECT * FROM FOO WHERE BAR LIKE 'X' SELECT * FROM FOO WHERE BAR ='X' </code></pre> <p>Perhaps there is a performance overhead in using like with no w...
[ { "answer_id": 404234, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 3, "selected": false, "text": "<p>Any good optimizer would reduce the first expression to the second.</p>\n" }, { "answer_id": 404237, "...
2008/12/31
[ "https://Stackoverflow.com/questions/404226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27657/" ]
I know this is a pretty basic question, and I *think* I know the answer...but I'd like to confirm. Are these queries truly equivalent? ``` SELECT * FROM FOO WHERE BAR LIKE 'X' SELECT * FROM FOO WHERE BAR ='X' ``` Perhaps there is a performance overhead in using like with no wild cards? I have an app that optional...
As @ocdecio says, if the optimizer is smart enough there should be no difference, but if you want to make sure about what is happening behind the scenes you should compare the two query's execution plans.
404,231
<p>I have this enum:</p> <pre><code>enum ButtonState { BUTTON_NORMAL = 0, BUTTON_PRESSED = 1, BUTTON_CLICKED = 2 }; const u8 NUM_BUTTON_STATES = 3; </code></pre> <p>In my Button class I have member variables <code>ButtonState state;</code> and <code>ButtonColors colors[NUM_BUTTON_STATES];</code>. When dr...
[ { "answer_id": 404242, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Question 1: I think it's good programming style. I use it all the time.\nQuestion 2: As far as I know, it is guaranteed to ...
2008/12/31
[ "https://Stackoverflow.com/questions/404231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
I have this enum: ``` enum ButtonState { BUTTON_NORMAL = 0, BUTTON_PRESSED = 1, BUTTON_CLICKED = 2 }; const u8 NUM_BUTTON_STATES = 3; ``` In my Button class I have member variables `ButtonState state;` and `ButtonColors colors[NUM_BUTTON_STATES];`. When drawing the button, I use `colors[state]` to get t...
***Is this good programming style?*** I think so. I do the same thing quite frequently. ***Is there a better way to do it?*** ``` class Button { public: // Used for array indexes! Don't change the numbers! enum State { NORMAL = 0, PRESSED, CLICKED, NUMBER_OF_BUTTON_STATES }; }; ``` Drawbac...
404,232
<p>I am trying to pass a reference to a two-dimensional array to a function in C++. I know the size of both dimensions at compile time. Here is what I have right now:</p> <pre><code>const int board_width = 80; const int board_height = 80; void do_something(int[board_width][board_height]&amp; array); //function protot...
[ { "answer_id": 404243, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": -1, "selected": false, "text": "<p>I think this is what you want:</p>\n\n<pre><code>void do_something(int array[board_width][board_height]);\n</code></pr...
2008/12/31
[ "https://Stackoverflow.com/questions/404232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to pass a reference to a two-dimensional array to a function in C++. I know the size of both dimensions at compile time. Here is what I have right now: ``` const int board_width = 80; const int board_height = 80; void do_something(int[board_width][board_height]& array); //function prototype ``` But this...
If you know the size at compile time, this will do it: ``` //function prototype void do_something(int (&array)[board_width][board_height]); ``` Doing it with ``` void do_something(int array[board_width][board_height]); ``` Will actually pass a pointer to the first sub-array of the two dimensional array ("board\_w...
404,258
<p>For some reason the following code fails. You can't simply erase a reverse_iterator by using its base() method. </p> <pre><code>#include &lt;set&gt; #include &lt;iostream&gt; int main() { std::set&lt;int&gt; setOfInts; setOfInts.insert(1); setOfInts.insert(2); setOfInts.insert(3); std::set&lt;...
[ { "answer_id": 404261, "author": "Brian", "author_id": 16457, "author_profile": "https://Stackoverflow.com/users/16457", "pm_score": -1, "selected": false, "text": "<p>Call <code>erase</code> with the iterator itself (no need to use <code>base</code>).</p>\n\n<pre><code>#include &lt;set&...
2008/12/31
[ "https://Stackoverflow.com/questions/404258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8123/" ]
For some reason the following code fails. You can't simply erase a reverse\_iterator by using its base() method. ``` #include <set> #include <iostream> int main() { std::set<int> setOfInts; setOfInts.insert(1); setOfInts.insert(2); setOfInts.insert(3); std::set<int>::reverse_iterator rev_iter = ...
Apparently the solution is what base() returns is 1 off. The following identity holds for a reverse\_iterator: ``` &*(reverse_iterator(i)) == &*(i - 1) ``` Or in other words, the reverse\_iterator is always one pass the regular iterator it is the base of. Not sure why. In GCC ====== Simply change ``` // ...
404,278
<p>Anyone know why the MINUTE method in java.util.Caldendar returns an incorrect minute?</p> <pre><code>import java.util.Calendar; public class Clock { // Instance fields private Calendar time; /** * Constructor. Starts the clock at the current operating system time */ public Clock() { ...
[ { "answer_id": 404283, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 5, "selected": false, "text": "<p>Calendar.MINUTE isn't the actual minute but rather a constant index value to pass into \"get()\" in order to ge...
2008/12/31
[ "https://Stackoverflow.com/questions/404278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Anyone know why the MINUTE method in java.util.Caldendar returns an incorrect minute? ``` import java.util.Calendar; public class Clock { // Instance fields private Calendar time; /** * Constructor. Starts the clock at the current operating system time */ public Clock() { System....
Calendar.MINUTE isn't the actual minute but rather a constant index value to pass into "get()" in order to get the value. For example: ``` System.out.println(this.time.get(Calendar.HOUR_OF_DAY) + ":" + this.time.get(Calendar.MINUTE)); ```
404,290
<p>I'm trying to create a splash screen that shows assemblies (all referenced library) loading status. I use AppDomain.AssemblyLoad AssemblyLoadEventHandler delegate to catch what assembly is being loaded but the problem is the event is not triggered when the program initializes. I tried register the event handler in a...
[ { "answer_id": 404309, "author": "Michael Bray", "author_id": 50356, "author_profile": "https://Stackoverflow.com/users/50356", "pm_score": 0, "selected": false, "text": "<p>Hmm I'm not sure about the VB syntax, but in C#, I would put it in the Program's Main(...):</p>\n\n<pre><code>stat...
2008/12/31
[ "https://Stackoverflow.com/questions/404290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a splash screen that shows assemblies (all referenced library) loading status. I use AppDomain.AssemblyLoad AssemblyLoadEventHandler delegate to catch what assembly is being loaded but the problem is the event is not triggered when the program initializes. I tried register the event handler in appl...
One issue you are going to run into is that assemblies in .Net are not loaded until they are needed. For instance, create a new assembly with a "Hello World" class in it, reference it with any executable, then delete the new assembly from the working directory, at no time will you notice that it is loaded. Next, on a...
404,313
<p>I have a table that has about 1/2 million records in it.</p> <p>Each month we get about 1/2 million more records to import. These are currently shoved into another table in the DB, but will eventually be loaded directly from a txt file. For each of these new records, I have to determine if we have that record alr...
[ { "answer_id": 404321, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "<p>Take a look at the .NET Framework 2.0's <a href=\"http://blogs.msdn.com/nikhilsi/archive/2008/06/11/bulk-insert-int...
2009/01/01
[ "https://Stackoverflow.com/questions/404313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
I have a table that has about 1/2 million records in it. Each month we get about 1/2 million more records to import. These are currently shoved into another table in the DB, but will eventually be loaded directly from a txt file. For each of these new records, I have to determine if we have that record already, and if...
Yes, move the logic to a single stored proc that will do a Bulk Insert into a temp table (without Logging, and then process all the records in the temp table in two separate statements... One Update for all the records that do exist in the desti Table, and One Insert for all those that do not ``` Update DestTable S...
404,322
<p>I need to be able to programmatically transcode mpeg-2 files to .mp4, .mp3, .wmv, .rm (optional), and .flv (optional), and hopefully generate a thumbnail as well. I found the Java Media Framework, but it frankly looks pretty crappy. This will be running a Linux server, so I could shell out to ffmpeg using Commons Ex...
[ { "answer_id": 404333, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 0, "selected": false, "text": "<p>The popular transcoding applications for Linux are ffmpeg, <a href=\"http://www.transcoding.org/cgi-bin/transcode\" r...
2009/01/01
[ "https://Stackoverflow.com/questions/404322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42891/" ]
I need to be able to programmatically transcode mpeg-2 files to .mp4, .mp3, .wmv, .rm (optional), and .flv (optional), and hopefully generate a thumbnail as well. I found the Java Media Framework, but it frankly looks pretty crappy. This will be running a Linux server, so I could shell out to ffmpeg using Commons Exec ...
Ffmpeg is the best and easiest. To output/convert video: ``` ffmpeg -i {input}.ext -r {target_frame_rate} -ar {target_audio_rate} -b {target_bitrate} -s {width}x{height} {target}.ext ``` And your screenshot: ``` ffmpeg -i {input}.ext -r 1 -ss 00:00:04:005 -t 00:00:01 -an -s {width}x{height} {target_name}%d.jpg ```...
404,332
<p>In my ASP.NET application, I want to use regular expressions to change URLs into hyper links in user posts, for example:</p> <pre><code>http://www.somesite.com/default.aspx </code></pre> <p>to</p> <pre><code>&lt;a href="http://www.somesite.com/default.aspx"&gt;http://www.somesite.com/default.aspx&lt;/a&gt; </c...
[ { "answer_id": 404335, "author": "Michael Bray", "author_id": 50356, "author_profile": "https://Stackoverflow.com/users/50356", "pm_score": 3, "selected": false, "text": "<p>This is an example of where <a href=\"http://msmvps.com/blogs/jon_skeet/archive/2005/09/21/67247.aspx\" rel=\"nofo...
2009/01/01
[ "https://Stackoverflow.com/questions/404332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
In my ASP.NET application, I want to use regular expressions to change URLs into hyper links in user posts, for example: ``` http://www.somesite.com/default.aspx ``` to ``` <a href="http://www.somesite.com/default.aspx">http://www.somesite.com/default.aspx</a> ``` This is fairly easy using Regex.Replace(), but...
This is an example of where [JUST using a Regex is trying to do too much](http://msmvps.com/blogs/jon_skeet/archive/2005/09/21/67247.aspx). I would recommend using Regex to FIND the patterns, but use code logic to adjust the output to your liking. It's not too hard to output the new pattern with replacements, but tryin...
404,344
<p>I'm trying to grab a specific bit of raw text from a web site. Using this site and other sources, I learned how to grab specific images using simpleXML and xpath.</p> <p>However the same approach doesn't appear to be working for grabbing raw text. Here's what's NOT working right now.</p> <pre><code>// first I set...
[ { "answer_id": 404376, "author": "Salty", "author_id": 50548, "author_profile": "https://Stackoverflow.com/users/50548", "pm_score": 0, "selected": false, "text": "<p>Try checking <a href=\"http://us.php.net/manual/en/class.domelement.php#86803\" rel=\"nofollow noreferrer\">this</a> page...
2009/01/01
[ "https://Stackoverflow.com/questions/404344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to grab a specific bit of raw text from a web site. Using this site and other sources, I learned how to grab specific images using simpleXML and xpath. However the same approach doesn't appear to be working for grabbing raw text. Here's what's NOT working right now. ``` // first I set the xpath of the div ...
One thing to note, is that when you are using print\_r or var\_dump on SimpleXML objects you won't see the "text" of the object (or sometimes the attributes). So to see *everything* you should output full XML string using $variable->AsXml(). And to get the text you need to cast the SimpleXml object to a string. This a...
404,346
<p>Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1/2 +1/3 +1/4...</p>
[ { "answer_id": 404354, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 2, "selected": false, "text": "<p>This ought to do the trick.</p>\n\n<pre><code>def calc_harmonic(n):\n return sum(1.0/d for d in range(2,n+1))\n</c...
2009/01/01
[ "https://Stackoverflow.com/questions/404346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47204/" ]
Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1/2 +1/3 +1/4...
[@Kiv's answer](https://stackoverflow.com/questions/404346/python-program-to-calculate-harmonic-series#404425) is correct but it is slow for large n if you don't need an infinite precision. It is better to use an [asymptotic formula](http://en.wikipedia.org/wiki/Harmonic_number) in this case: ![asymptotic expansion fo...
404,368
<p>In working with objects and interfaces what is the best practice for writing to the database? There is a plethora of opinions regarding the object design but I am unclear about the database end. A simple example: </p> <p>Suppose a Contact base class that contains the common fields such as contact name (Bill, Fred, ...
[ { "answer_id": 404384, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 2, "selected": false, "text": "<p>It is my experience that when it comes to databases, good relational design has to come first if you want to have ...
2009/01/01
[ "https://Stackoverflow.com/questions/404368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50622/" ]
In working with objects and interfaces what is the best practice for writing to the database? There is a plethora of opinions regarding the object design but I am unclear about the database end. A simple example: Suppose a Contact base class that contains the common fields such as contact name (Bill, Fred, Sally) and...
It is my experience that when it comes to databases, good relational design has to come first if you want to have any semblance of performance. After that, my model is quite simple: one table, one class. If I have a self referential relationship, I create another class deriving straight from the original. Joins are def...
404,377
<p>I am constructing a large HTML document from fragments supplied by users that have the annoying habit of being malformed in various ways. Browsers are robust and forgiving enough but I want to be able to validate and (ideally) fix any malformed HTML if at all possible. For example:</p> <pre><code>&lt;td&gt;&lt;b&...
[ { "answer_id": 404380, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": true, "text": "<p>You can use <a href=\"http://devzone.zend.com/article/761-Tidying-up-your-HTML-with-PHP-5\" rel=\"noreferrer\">HTML Tidy<...
2009/01/01
[ "https://Stackoverflow.com/questions/404377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am constructing a large HTML document from fragments supplied by users that have the annoying habit of being malformed in various ways. Browsers are robust and forgiving enough but I want to be able to validate and (ideally) fix any malformed HTML if at all possible. For example: ``` <td><b>Title</td> ``` can be r...
You can use [HTML Tidy](http://devzone.zend.com/article/761-Tidying-up-your-HTML-with-PHP-5), man pages are [here](http://au.php.net/tidy).
404,379
<p>I have an order page that is being rendered from a Model object (Order) with a few properties. One of the properties of the Order object is</p> <pre><code>public List&lt;OrderItem&gt; Items { get; set; }; </code></pre> <p>and the other is</p> <pre><code>public List&lt;OrderComment&gt; Comments { get; set; }; </c...
[ { "answer_id": 404399, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 0, "selected": false, "text": "<p>Make sure your call to render the user control passes the right data the Render function.</p>\n\n\n\n<p>(My memories ...
2009/01/01
[ "https://Stackoverflow.com/questions/404379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I have an order page that is being rendered from a Model object (Order) with a few properties. One of the properties of the Order object is ``` public List<OrderItem> Items { get; set; }; ``` and the other is ``` public List<OrderComment> Comments { get; set; }; ``` My main page is declared like this: ``` public...
Yes. Using `RenderPartial` you can use the signature that supplies the model and simply use whatever model object is available to you in the current View. ``` <% foreach (OrderItem orderItem in ViewData.Model.OrderItems) { %> <%= Html.RenderPartial( "OrderItem", orderItem, ViewData ) %> <% } %> ``` You ca...
404,391
<p>How do I get the actual value (or text) of the item selected in an HTML select box? Here are the main methods I've tried...</p> <pre><code> document.getElementById('PlaceNames').value </code></pre> <pre><code> $("#PlaceNames option:selected").val() </code></pre> <pre><code> $("#PlaceNames option:selected").text(...
[ { "answer_id": 404394, "author": "MonkeyBrother", "author_id": 16296, "author_profile": "https://Stackoverflow.com/users/16296", "pm_score": 0, "selected": false, "text": "<p>var plid = $('#PlaceNames').val();</p>\n\n<p>val placename = $('#PlaceNames option[value=\\''+plid.toString()+'\\...
2009/01/01
[ "https://Stackoverflow.com/questions/404391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49294/" ]
How do I get the actual value (or text) of the item selected in an HTML select box? Here are the main methods I've tried... ``` document.getElementById('PlaceNames').value ``` ``` $("#PlaceNames option:selected").val() ``` ``` $("#PlaceNames option:selected").text() ``` And I've tried various variations on th...
`$('#placeNames').val()` returns the [value](http://docs.jquery.com/Attributes/val) of the selected option in the latest version of jQuery.
404,450
<p>I am finishing off a C# ASP.NET program that allows the user to build their own computer by selecting hardware components such as memory, cpu, etc from a drop down lists. The SQL datatable has 3 columns; ComputerID, Attribute and Value. The computerID is an ID that corresponds to a certain computer in my main datata...
[ { "answer_id": 404456, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 0, "selected": false, "text": "<p>I'm assuming you're asking:</p>\n\n<blockquote>\n <p>How do I refine the content of a search I've done using LINQ to SQL?</p>\...
2009/01/01
[ "https://Stackoverflow.com/questions/404450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am finishing off a C# ASP.NET program that allows the user to build their own computer by selecting hardware components such as memory, cpu, etc from a drop down lists. The SQL datatable has 3 columns; ComputerID, Attribute and Value. The computerID is an ID that corresponds to a certain computer in my main datatable...
You need to use Concat as a "Union All". ``` IQueryable<ComputerAttribute> results = null; foreach(ComputerRequirement z in requirements) { //must assign to a locally scoped variable to avoid using // the same reference in all of the where methods. ComputerRequirement cr = z; if (results == null) { resu...
404,470
<p>My REST API returns JSON. </p> <p>I'm currently returning text/plain as the MIME type, but it feels funny. Should I be returning <code>application/x-javascript</code> or some other type?</p> <p>The second question is with regard to the HTTP status code for error conditions. If my REST API is returning an error sta...
[ { "answer_id": 404472, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 7, "selected": true, "text": "<p>The <a href=\"http://www.ietf.org/rfc/rfc4627.txt\" rel=\"noreferrer\">JSON</a> spec suggests <code>application/json<...
2009/01/01
[ "https://Stackoverflow.com/questions/404470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
My REST API returns JSON. I'm currently returning text/plain as the MIME type, but it feels funny. Should I be returning `application/x-javascript` or some other type? The second question is with regard to the HTTP status code for error conditions. If my REST API is returning an error state, I am returning as JSON ...
The [JSON](http://www.ietf.org/rfc/rfc4627.txt) spec suggests `application/json`, and that seems to be supported by the [IETF](http://www.ietf.org/rfc/rfc4627.txt) and [IANA](http://www.iana.org/assignments/media-types/application/) registry. On the second question, I think if the message handling fails in some way yo...
404,484
<p>Using Grails 1.1 beta2 and a JSP page. The JSP includes the CSS reference:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="styles.css"&gt; </code></pre> <p>When this line is included Grails pukes with the error:</p> <pre><code>[7000] errors.GrailsExceptionResolver java.lang.NumberFormatException: F...
[ { "answer_id": 404472, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 7, "selected": true, "text": "<p>The <a href=\"http://www.ietf.org/rfc/rfc4627.txt\" rel=\"noreferrer\">JSON</a> spec suggests <code>application/json<...
2009/01/01
[ "https://Stackoverflow.com/questions/404484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
Using Grails 1.1 beta2 and a JSP page. The JSP includes the CSS reference: ``` <link rel="stylesheet" type="text/css" href="styles.css"> ``` When this line is included Grails pukes with the error: ``` [7000] errors.GrailsExceptionResolver java.lang.NumberFormatException: For input string: "styles" org.codehaus.groo...
The [JSON](http://www.ietf.org/rfc/rfc4627.txt) spec suggests `application/json`, and that seems to be supported by the [IETF](http://www.ietf.org/rfc/rfc4627.txt) and [IANA](http://www.iana.org/assignments/media-types/application/) registry. On the second question, I think if the message handling fails in some way yo...
404,498
<p>How do I add rows programmatically to a DataGridTable in C#? When the user selects an option, I want to repopulate a DataGridTable with fresh data, which I am acquiring as shown below:</p> <pre><code> connect.Open(); MySqlCommand comm = connect.CreateCommand(); comm.CommandText = getCustomerI...
[ { "answer_id": 404472, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 7, "selected": true, "text": "<p>The <a href=\"http://www.ietf.org/rfc/rfc4627.txt\" rel=\"noreferrer\">JSON</a> spec suggests <code>application/json<...
2009/01/01
[ "https://Stackoverflow.com/questions/404498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
How do I add rows programmatically to a DataGridTable in C#? When the user selects an option, I want to repopulate a DataGridTable with fresh data, which I am acquiring as shown below: ``` connect.Open(); MySqlCommand comm = connect.CreateCommand(); comm.CommandText = getCustomerInvoices + cust...
The [JSON](http://www.ietf.org/rfc/rfc4627.txt) spec suggests `application/json`, and that seems to be supported by the [IETF](http://www.ietf.org/rfc/rfc4627.txt) and [IANA](http://www.iana.org/assignments/media-types/application/) registry. On the second question, I think if the message handling fails in some way yo...
404,513
<p>I am just starting with C++ and got some problems in understanding how the scope for private member variables in a class works. Please see the below code</p> <pre><code>class Foo{ private: std::vector&lt;int&gt; container; public: // other methods }; int main(int argc, char* argv[]) { F...
[ { "answer_id": 404517, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "<ol>\n<li>Yes, the <em>lifetime</em> of the container member will last as long as the object that contains i...
2009/01/01
[ "https://Stackoverflow.com/questions/404513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
I am just starting with C++ and got some problems in understanding how the scope for private member variables in a class works. Please see the below code ``` class Foo{ private: std::vector<int> container; public: // other methods }; int main(int argc, char* argv[]) { Foo* foo = new Foo; ...
1. Yes, the *lifetime* of the container member will last as long as the object that contains it exists, which is until you call `delete` on the pointer pointing to it (`foo` in your case). 2. No, there is no reason to do that. Making it a pointer requires you to create a dynamic object of `vector<int>` which you would ...
404,522
<p>I have a case where the child view sends notification to its parent view. Now I'm calling <code>addObserver:</code> in <code>viewWillAppear:</code> and <code>removeObserver:</code> in <code>viewWillDisappear:</code>. But, I'm guessing this is not correct since <code>viewWillAppear:</code> calls when view is refreshe...
[ { "answer_id": 404720, "author": "Mustafa", "author_id": 49739, "author_profile": "https://Stackoverflow.com/users/49739", "pm_score": 1, "selected": false, "text": "<p>I guess the correct positions to register for notification is <code>viewDidLoad</code> method, and correct position to ...
2009/01/01
[ "https://Stackoverflow.com/questions/404522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49739/" ]
I have a case where the child view sends notification to its parent view. Now I'm calling `addObserver:` in `viewWillAppear:` and `removeObserver:` in `viewWillDisappear:`. But, I'm guessing this is not correct since `viewWillAppear:` calls when view is refreshed. ``` [[NSNotificationCenter defaultCenter] addObserver...
Actually, this is a bad idea. When memory gets low, your view controller may get sent a memory warning. The default behavior in this instance is to clear out your view (if you're not currently on screen). In this case, you could get the viewDidLoad message sent a second time (after the memory event, when your view is b...
404,534
<p>I ran across this case of <code>UnboundLocalError</code> recently, which seems strange:</p> <pre><code>import pprint def main(): if 'pprint' in globals(): print 'pprint is in globals()' pprint.pprint('Spam') from pprint import pprint pprint('Eggs') if __name__ == '__main__': main() </code></pre> ...
[ { "answer_id": 404610, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 3, "selected": true, "text": "<p>Looks like Python sees the <code>from pprint import pprint</code> line and marks <code>pprint</code> as a name local...
2009/01/01
[ "https://Stackoverflow.com/questions/404534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I ran across this case of `UnboundLocalError` recently, which seems strange: ``` import pprint def main(): if 'pprint' in globals(): print 'pprint is in globals()' pprint.pprint('Spam') from pprint import pprint pprint('Eggs') if __name__ == '__main__': main() ``` Which produces: ``` pprint is in ...
Looks like Python sees the `from pprint import pprint` line and marks `pprint` as a name local to `main()` *before* executing any code. Since Python thinks pprint ought to be a local variable, referencing it with `pprint.pprint()` before "assigning" it with the `from..import` statement, it throws that error. That's a...
404,547
<p>This problem is a continuation of a previous problem:</p> <p><a href="https://stackoverflow.com/questions/402432/c-returning-and-inserting-a-2d-array-object">C++ Returning and Inserting a 2D array object</a></p> <p>and it is highly recommended to view the link to understand the following.</p> <p>I followed throug...
[ { "answer_id": 405830, "author": "Joseph Garvin", "author_id": 50385, "author_profile": "https://Stackoverflow.com/users/50385", "pm_score": 0, "selected": false, "text": "<p>I see a few issues:</p>\n\n<p>1) It's possible you simply haven't cut and paste everything, but it looks like you...
2009/01/01
[ "https://Stackoverflow.com/questions/404547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This problem is a continuation of a previous problem: [C++ Returning and Inserting a 2D array object](https://stackoverflow.com/questions/402432/c-returning-and-inserting-a-2d-array-object) and it is highly recommended to view the link to understand the following. I followed through Adam Rosenfield's answer and it s...
> > > ``` > int i, j; > > Grid myGrid; > Piece myPiece; > > //First two lines of Adam's Code > int (*arrayPtr)[4][4] = myPiece.returnPiece(); > int cell = (*arrayPtr)[i][j]; > > //compiler error > myGrid.insertArray(cell); <--- Problem > > ``` > > If you want to copy a piece (or 4x4 section), you have to pass ...
404,549
<p>Sometimes I want to write a "major" comment to describe a large block of code and then write "minor" comments to describe a few of the lines within that block of code:</p> <pre><code>// Major comment // Minor comment ... // Minor comment 2 ... </code></pre> <p>The major comment looks strange without code directl...
[ { "answer_id": 404559, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 1, "selected": false, "text": "<p>I use something like this, to make it look more like a \"heading\" or separator for the following block of code...
2009/01/01
[ "https://Stackoverflow.com/questions/404549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
Sometimes I want to write a "major" comment to describe a large block of code and then write "minor" comments to describe a few of the lines within that block of code: ``` // Major comment // Minor comment ... // Minor comment 2 ... ``` The major comment looks strange without code directly beneath it, and you can'...
``` // Major comment // ------------- ... // Minor comment ... ... // Minor comment (end of line) ```
404,557
<h2>Duplicate</h2> <p><a href="https://stackoverflow.com/questions/308466/modifying-a-collection-while-iterating-through-it-c">Modifying A Collection While Iterating Through It</a></p> <hr> <p>Has anyone a nice pattern to allow me to get around the inability to remove objects while I loop through an enumerable colle...
[ { "answer_id": 404569, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 2, "selected": false, "text": "<p>Do the inverse, creating a new list:</p>\n\n<pre><code>List myFilteredList = new List();\nforeach (MyObject myO...
2009/01/01
[ "https://Stackoverflow.com/questions/404557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
Duplicate --------- [Modifying A Collection While Iterating Through It](https://stackoverflow.com/questions/308466/modifying-a-collection-while-iterating-through-it-c) --- Has anyone a nice pattern to allow me to get around the inability to remove objects while I loop through an enumerable collection (eg, an IList o...
There's a useful `List<T>.RemoveAll(Predicate<T> match)` method which I think is designed for this: <http://msdn.microsoft.com/en-us/library/wdka673a.aspx>
404,601
<p>Suppose you're working with a customer's domain experts. You realize (or at least have a reasonable belief) that your model of their problem is clearer than theirs. How do you convince them that they should go your way.</p> <p>In my case, it is fairly clear what the main thrust of the requirements are (e.g. a tradi...
[ { "answer_id": 404635, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 2, "selected": false, "text": "<p>I never try to change the domain experts mental model of the domain...they are the experts after all. However...
2009/01/01
[ "https://Stackoverflow.com/questions/404601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17205/" ]
Suppose you're working with a customer's domain experts. You realize (or at least have a reasonable belief) that your model of their problem is clearer than theirs. How do you convince them that they should go your way. In my case, it is fairly clear what the main thrust of the requirements are (e.g. a trading system ...
I never try to change the domain experts mental model of the domain...they are the experts after all. However, if I model it slightly different from their model then I make sure that it can still produce the same effect. So I accept their view, model it my own way and then present it to them the way they understand it....
404,617
<p>We are developing a Flash site with PHP. the problem is that it storing the cache , but we have to disable the cache using JavaScript or PHP.</p> <p>How can I disable caching?</p>
[ { "answer_id": 404647, "author": "cowgod", "author_id": 6406, "author_profile": "https://Stackoverflow.com/users/6406", "pm_score": 5, "selected": false, "text": "<p>A common practice to disable browser caching is to set an expiration to a date in the past in the HTTP header. Different ...
2009/01/01
[ "https://Stackoverflow.com/questions/404617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We are developing a Flash site with PHP. the problem is that it storing the cache , but we have to disable the cache using JavaScript or PHP. How can I disable caching?
A common practice to disable browser caching is to set an expiration to a date in the past in the HTTP header. Different browsers utilize HTTP header values differently so it is important to use many if not all of the following settings: ``` <?php header("Expires: Tue, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified...
404,651
<p>With a listbox, I have the following code to extract the item selected:</p> <pre><code> private void inventoryList_SelectedIndexChanged(object sender, EventArgs e) { String s = inventoryList.SelectedItem.ToString(); s = s.Substring(0, s.IndexOf(':')); bookDetailTable.Rows.Clear(); ...
[ { "answer_id": 404663, "author": "Mitchell Gilman", "author_id": 43219, "author_profile": "https://Stackoverflow.com/users/43219", "pm_score": 5, "selected": true, "text": "<p>I think that this is what you're looking for. But if not, hopefully it will give you a start. </p>\n\n<pre><cod...
2009/01/01
[ "https://Stackoverflow.com/questions/404651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
With a listbox, I have the following code to extract the item selected: ``` private void inventoryList_SelectedIndexChanged(object sender, EventArgs e) { String s = inventoryList.SelectedItem.ToString(); s = s.Substring(0, s.IndexOf(':')); bookDetailTable.Rows.Clear(); ... ...
I think that this is what you're looking for. But if not, hopefully it will give you a start. ``` private void dataGridView1_SelectionChanged(object sender, EventArgs e) { DataGridView dgv = (DataGridView)sender; //User selected WHOLE ROW (by clicking in the margin) if (dgv.SelectedRows.Count> 0) ...
404,698
<p>In replies to <a href="https://stackoverflow.com/questions/391503/if-condition-continue-or-if-condition-style-preference">one of my questions</a>, I received a number of answers saying that style 2 may perform better than style 1. I don't understand how, since I believe they should emit essentially the same machine ...
[ { "answer_id": 404704, "author": "Kim Stebel", "author_id": 46450, "author_profile": "https://Stackoverflow.com/users/46450", "pm_score": 0, "selected": false, "text": "<p>Performance should be identical, whoever said otherwise must have been...confused.</p>\n" }, { "answer_id": ...
2009/01/01
[ "https://Stackoverflow.com/questions/404698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
In replies to [one of my questions](https://stackoverflow.com/questions/391503/if-condition-continue-or-if-condition-style-preference), I received a number of answers saying that style 2 may perform better than style 1. I don't understand how, since I believe they should emit essentially the same machine instructions (...
I had to check this. Here is my version of the code: ``` using System; using System.Collections.Generic; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Tester t=new Tester(); t.Method1(new Stack<string>(), new MsgParser(), true, true)...
404,701
<p>I would like to display tagcloud in my home page. Found this wordpress flash plugin <a href="http://alexisyes.com/tags/wpcumulus" rel="nofollow noreferrer">http://alexisyes.com/tags/wpcumulus</a> , but for that i needed to setup wordpress. I am wondering whether there is any other standalone plugin similar to wpcumu...
[ { "answer_id": 404714, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 2, "selected": true, "text": "<p>You could definitely use wpcumulus (I just downloaded it and checked it out). You just have to figure out what data it needs to ...
2009/01/01
[ "https://Stackoverflow.com/questions/404701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to display tagcloud in my home page. Found this wordpress flash plugin <http://alexisyes.com/tags/wpcumulus> , but for that i needed to setup wordpress. I am wondering whether there is any other standalone plugin similar to wpcumulus which can be configurable. I don't want to install wordpress but i woul...
You could definitely use wpcumulus (I just downloaded it and checked it out). You just have to figure out what data it needs to create a tag cloud. First, you need to download the swf and add it to your site. You can take a look of an installed version / demo of it to see the proper swf embed html. Next, you have to ...
404,744
<p>I have an application that resides in a single .py file. I've been able to get pyInstaller to bundle it successfully into an EXE for Windows. The problem is, the application requires a .cfg file that always sits directly beside the application in the same directory.</p> <p>Normally, I build the path using the fol...
[ { "answer_id": 404750, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 8, "selected": true, "text": "<p>I found a solution. You need to check if the application is running as a script or as a frozen exe:</p>\n\n<pre><code>im...
2009/01/01
[ "https://Stackoverflow.com/questions/404744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46914/" ]
I have an application that resides in a single .py file. I've been able to get pyInstaller to bundle it successfully into an EXE for Windows. The problem is, the application requires a .cfg file that always sits directly beside the application in the same directory. Normally, I build the path using the following code:...
I found a solution. You need to check if the application is running as a script or as a frozen exe: ``` import os import sys config_name = 'myapp.cfg' # determine if application is a script file or frozen exe if getattr(sys, 'frozen', False): application_path = os.path.dirname(sys.executable) elif __file__: ...
404,774
<p>I have this tiny Qt project with a project file like this:</p> <pre><code>TEMPLATE = lib TARGET = record32 VERSION = 0.0.1 DEPENDPATH += . INCLUDEPATH += . CONFIG += shared SOURCES += recorder.cpp HEADERS += recorder.h </code></pre> <p>When I compile a library from it by <code>qmake &amp;&amp; nmake</code>, it re...
[ { "answer_id": 405008, "author": "Reed Hedges", "author_id": 39686, "author_profile": "https://Stackoverflow.com/users/39686", "pm_score": 4, "selected": true, "text": "<p>It comes from the first part of VERSION. The \"lib\" TEMPLATE is adding it.</p>\n\n<p>IMO it's a good idea to inclu...
2009/01/01
[ "https://Stackoverflow.com/questions/404774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40657/" ]
I have this tiny Qt project with a project file like this: ``` TEMPLATE = lib TARGET = record32 VERSION = 0.0.1 DEPENDPATH += . INCLUDEPATH += . CONFIG += shared SOURCES += recorder.cpp HEADERS += recorder.h ``` When I compile a library from it by `qmake && nmake`, it results into files ``` record32.obj record320....
It comes from the first part of VERSION. The "lib" TEMPLATE is adding it. IMO it's a good idea to include it in the library name, since it avoids the infamous "DLL Hell" that happens on Windows where this convention is not followed consistently... By naming the library files to include the major version number, users ...
404,795
<p>I was recently teaching myself Python and discovered the LBYL/EAFP idioms with regards to error checking before code execution. In Python, it seems the accepted style is EAFP, and it seems to work well with the language.</p> <p>LBYL (<strong><em>L</strong>ook <strong>B</strong>efore <strong>Y</strong>ou <strong>L</...
[ { "answer_id": 404802, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 4, "selected": true, "text": "<p>Personally, and I think this is backed up by convention, EAFP is never a good way to go.\nYou can look at it as an eq...
2009/01/01
[ "https://Stackoverflow.com/questions/404795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49018/" ]
I was recently teaching myself Python and discovered the LBYL/EAFP idioms with regards to error checking before code execution. In Python, it seems the accepted style is EAFP, and it seems to work well with the language. LBYL (***L***ook **B**efore **Y**ou **L**eap): ``` def safe_divide_1(x, y): if y == 0: ...
Personally, and I think this is backed up by convention, EAFP is never a good way to go. You can look at it as an equivalent to the following: ``` if (o != null) o.doSomething(); else // handle ``` as opposed to: ``` try { o.doSomething() } catch (NullPointerException npe) { // handle } ``` Moreo...
404,804
<pre><code>public class CovariantTest { public A getObj() { return new A(); } public static void main(String[] args) { CovariantTest c = new SubCovariantTest(); System.out.println(c.getObj().x); } } class SubCovariantTest extends CovariantTest { public B getObj() { ...
[ { "answer_id": 404812, "author": "Spoike", "author_id": 3713, "author_profile": "https://Stackoverflow.com/users/3713", "pm_score": 4, "selected": false, "text": "<p>Java <strong>doesn't override fields</strong> (aka. attributes or member variables). Instead they <a href=\"http://leepoin...
2009/01/01
[ "https://Stackoverflow.com/questions/404804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40945/" ]
``` public class CovariantTest { public A getObj() { return new A(); } public static void main(String[] args) { CovariantTest c = new SubCovariantTest(); System.out.println(c.getObj().x); } } class SubCovariantTest extends CovariantTest { public B getObj() { return ...
This is because in Java member variables don't override, they *shadow* (unlike methods). Both A and B have a variable x. Since c is *declared* to be of type CovarientTest, the return of getObj() is implicitly an A, not B, so you get A's x, not B's x.
404,825
<p>How to return a list in Python???</p> <p>When I tried returning a list,I got an empty list.What's the reason???</p>
[ { "answer_id": 404837, "author": "Autoplectic", "author_id": 49994, "author_profile": "https://Stackoverflow.com/users/49994", "pm_score": 0, "selected": false, "text": "<p>to wit:</p>\n\n<pre><code>In [1]: def pants():\n ...: return [1, 2, 'steve']\n ...: \nIn [2]: pants()\nOut[...
2009/01/01
[ "https://Stackoverflow.com/questions/404825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
How to return a list in Python??? When I tried returning a list,I got an empty list.What's the reason???
As Andrew commented, you will receive better answers if you show us the code you are currently using. Also if you could state what version of Python you are using that would be great. There are a few ways you can return a list. Say for example we have a function called retlist. ``` def retlist(): return [] ``` ...
404,830
<p>I have an application in which I'm trying to capture the shift key modifier to perform an action, however when I run the program and press and normal key without the shift key modifier I get a beep and the modifier and key are not sent to my keyDown event. The relevant code is:</p> <pre><code>NSString* eventChars ...
[ { "answer_id": 404895, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 1, "selected": false, "text": "<p>From your code it looks like the code that checks for the modifier is never reached.\nAnything that is not \"w,x,a,d\" is s...
2009/01/01
[ "https://Stackoverflow.com/questions/404830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2594/" ]
I have an application in which I'm trying to capture the shift key modifier to perform an action, however when I run the program and press and normal key without the shift key modifier I get a beep and the modifier and key are not sent to my keyDown event. The relevant code is: ``` NSString* eventChars = [theEvent cha...
First, -charactersIgnoringModifiers doesn't ignore the shift key, so you will still get shifted characters (i.e UPPERCASE and !%#$%^&\*) returned from it. What's probably happening in your function is: You press shift-w, your -isEqualTo: returns false because you're comparing a lowercase 'w' and an uppercase 'W', and s...
404,838
<p>I've been programming in C-derived languages for a couple of decades now. Somewhere along the line, I decided that I no longer wanted to write:</p> <pre><code>if (var) // in C if ($var) # in Perl </code></pre> <p>when what I meant was:</p> <pre><code>if (var != 0) if (defined $var and $var ne '') </code></p...
[ { "answer_id": 404841, "author": "gak", "author_id": 11125, "author_profile": "https://Stackoverflow.com/users/11125", "pm_score": 4, "selected": false, "text": "<pre><code>if (var)\n</code></pre>\n\n<p>Less to type, as long as you're sure you're not testing the wrong thing.</p>\n" }, ...
2009/01/01
[ "https://Stackoverflow.com/questions/404838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41861/" ]
I've been programming in C-derived languages for a couple of decades now. Somewhere along the line, I decided that I no longer wanted to write: ``` if (var) // in C if ($var) # in Perl ``` when what I meant was: ``` if (var != 0) if (defined $var and $var ne '') ``` I think part of it is that I have a strong...
I like my `if`s to make sense when read aloud: ``` if (is_it_happening) ... if (number_of_sheep != 0) ... if (pointer_to_something != NULL) ... ```
404,842
<p>I am starting, and loving, TDD, however wondering about the red green light concept. I do understand in theory the importance of ensuring you can fail a test before passing it. In practice, however, I am finding it somewhat a futile practice.</p> <p>I feel I can't properly write a failing or passing test without im...
[ { "answer_id": 404860, "author": "Raminder", "author_id": 25125, "author_profile": "https://Stackoverflow.com/users/25125", "pm_score": 3, "selected": false, "text": "<p>The value of red right lies in its ability to spot false-positives. It has happened with me that no matter what my imp...
2009/01/01
[ "https://Stackoverflow.com/questions/404842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
I am starting, and loving, TDD, however wondering about the red green light concept. I do understand in theory the importance of ensuring you can fail a test before passing it. In practice, however, I am finding it somewhat a futile practice. I feel I can't properly write a failing or passing test without implementing...
Think of it as a kind of specification. You *start* by asking yourself, "what should the code I eventually want be able to do?" So, say you want to write a function that adds natural numbers. How would you know if that worked? Well, you know that 2+2=4, so you can write a test (this is basically python but leaves out a...
404,861
<p>I know:</p> <ul> <li><p>The control points a and d (start and end point of a 2D cubic bezier curve)</p></li> <li><p>The slopes a->b, c->d, and b->c (b,c the other control points)</p></li> <li><p>Where the halfway point of the <a href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve" rel="nofollow noreferrer">Bézier ...
[ { "answer_id": 404953, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>Let's say your slopes are normalized, then for some u,v you have</p>\n\n<pre><code>u * slope(a-&gt;b)+a = b, v * slope(c-&g...
2009/01/01
[ "https://Stackoverflow.com/questions/404861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I know: * The control points a and d (start and end point of a 2D cubic bezier curve) * The slopes a->b, c->d, and b->c (b,c the other control points) * Where the halfway point of the [Bézier curve](http://en.wikipedia.org/wiki/B%C3%A9zier_curve) is. Now, given this information, what is the formula for the positions ...
I know this question is old, but there is no correct or complete answer provided, so I thought I'd chime in with a solution. Note that David's calculations contain several errors and his solution is incomplete even if these errors are corrected. First, define vectors `T0`, `T1` and `T2` using the three slopes: ``` T0...
404,877
<p>How to create a java.awt.Image from image data? Image data is not pure RGB pixel data but encoded in jpeg/png format.</p> <p>JavaME has a simple api Image.createImage(...) for doing this. </p> <pre><code>public static Image createImage(byte[] imageData, int imageOffset, ...
[ { "answer_id": 404885, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 3, "selected": true, "text": "<pre><code>import java.awt.*;\n\nToolkit toolkit = Toolkit.getDefaultToolkit();\n\nImage image = toolkit.createImag...
2009/01/01
[ "https://Stackoverflow.com/questions/404877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to create a java.awt.Image from image data? Image data is not pure RGB pixel data but encoded in jpeg/png format. JavaME has a simple api Image.createImage(...) for doing this. ``` public static Image createImage(byte[] imageData, int imageOffset, i...
``` import java.awt.*; Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.createImage(imageData,imageOffset,imageLength); ```
404,879
<p>I'm working on the development of a C++ API which uses custom-designed plugins to interface with different database engines using their APIs and specific SQL syntax.</p> <p>Currently, I'm attempting to find a way of inserting BLOBs, but since <code>NULL</code> is the terminating character in C/C++, the BLOB beco...
[ { "answer_id": 404925, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 1, "selected": false, "text": "<p>You want to precompile the statement <code>sqlite_prepare_v2()</code>, and then bind the blob in using <code>sqli...
2009/01/01
[ "https://Stackoverflow.com/questions/404879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36145/" ]
I'm working on the development of a C++ API which uses custom-designed plugins to interface with different database engines using their APIs and specific SQL syntax. Currently, I'm attempting to find a way of inserting BLOBs, but since `NULL` is the terminating character in C/C++, the BLOB becomes truncated when co...
You'll want to use this function with a prepared statement. ``` int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); ``` In C/C++, the standard way of dealing with NULLs in strings is to either store the beginning of the string and a length, or store a pointer to the beginning of a string a...
404,886
<p>Is there any better alternative for doing string formatting in VC6, with syntax checking before substitution?</p>
[ { "answer_id": 404916, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 4, "selected": true, "text": "<p><code>CString</code> offers the <code>Format</code> method for <code>printf</code>-style formatting, but this isn't type-sa...
2009/01/01
[ "https://Stackoverflow.com/questions/404886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
Is there any better alternative for doing string formatting in VC6, with syntax checking before substitution?
`CString` offers the `Format` method for `printf`-style formatting, but this isn't type-safe. For type-safe string formatting you could either use `std::stringstream` / `std::wstringstream` or the [Boost Format](http://www.boost.org/doc/libs/1_37_0/libs/format/index.html) library, although these both work with the C++...
404,887
<p>I'm sorry, but this is beginning to feel like kicking myself in the head. I'm completely baffled by RSpec. Have watched video after video, read tutorial after tutorial, and still I'm just stuck on square one. </p> <p>=== here is what I'm working with</p> <p><strong><a href="http://github.com/fudgestudios/bort/tr...
[ { "answer_id": 405090, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 2, "selected": false, "text": "<p>EDIT: you shouldn't expect Bid.count to increment when using a mock object. Mantra I forgot: caffeine before code.</p>\n\n<...
2009/01/01
[ "https://Stackoverflow.com/questions/404887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33287/" ]
I'm sorry, but this is beginning to feel like kicking myself in the head. I'm completely baffled by RSpec. Have watched video after video, read tutorial after tutorial, and still I'm just stuck on square one. === here is what I'm working with **<http://github.com/fudgestudios/bort/tree/master>** === Errors ``` F ...
You've got a couple of things backwards in before(:each). Seeing as the example is specifying that the post should increase the count by 1, you're dealing with real records and there is no reason for stubbing anything at all. Also, at this point, since there is only one example, there is no reason to have a before bloc...
404,891
<p>I have two pages of jQuery, Page1 and Page2, and I'm able to get input in Page1.</p> <p>The <code>somval=1000$</code>.</p> <p>The page 1 user enters the somevalue. I have stored the value:</p> <pre><code>var val = somval; </code></pre> <p>Now in the second page, I need to get the result of somvalue in page 1. Of...
[ { "answer_id": 404894, "author": "gak", "author_id": 11125, "author_profile": "https://Stackoverflow.com/users/11125", "pm_score": 5, "selected": true, "text": "<p>You can redirect the user to the next page with the data in a query string, then in the second page you can parse the URL.</...
2009/01/01
[ "https://Stackoverflow.com/questions/404891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I have two pages of jQuery, Page1 and Page2, and I'm able to get input in Page1. The `somval=1000$`. The page 1 user enters the somevalue. I have stored the value: ``` var val = somval; ``` Now in the second page, I need to get the result of somvalue in page 1. Of course two pages using My1.js My2.js respectively....
You can redirect the user to the next page with the data in a query string, then in the second page you can parse the URL. To redirect the user you can do this: ``` window.location = 'page2.html?somval=' + somval; ``` Then in the second page you can use a function to parse the URL query string: ``` var qsParm = ne...
404,899
<p>I found the following rather strange. Then again, I have mostly used closures in dynamic languages which shouldn't be suspectable to the same "bug". The following makes the compiler unhappy:</p> <pre><code>VoidFunction t = delegate { int i = 0; }; int i = 1; </code></pre> <p>It says:</p> <blockquote> <p>A loca...
[ { "answer_id": 404907, "author": "Arjan Einbu", "author_id": 19594, "author_profile": "https://Stackoverflow.com/users/19594", "pm_score": 4, "selected": true, "text": "<p>It has to be that way to allow anonymous methods (and lambdas) to use local variables and parameters scoped in the c...
2009/01/01
[ "https://Stackoverflow.com/questions/404899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
I found the following rather strange. Then again, I have mostly used closures in dynamic languages which shouldn't be suspectable to the same "bug". The following makes the compiler unhappy: ``` VoidFunction t = delegate { int i = 0; }; int i = 1; ``` It says: > > A local variable named 'i' cannot be > declared ...
It has to be that way to allow anonymous methods (and lambdas) to use local variables and parameters scoped in the containing method. The workarounds are to either use different names for the variable, or create an ordinary method.
404,905
<p>I currently have an anchor tag that, when clicked, appends another anchor tag to the DOM. This is all done via jQuery. I know what the "id" attribute of the anchor tag to be added will be. However, when I try the following code, it fails to handle the newly added anchor tag's click event:</p> <p>$("#id").click(fu...
[ { "answer_id": 404915, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 2, "selected": false, "text": "<p>Are you attaching the click event before the element is added to the DOM? in that case it won't work. You need to...
2009/01/01
[ "https://Stackoverflow.com/questions/404905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I currently have an anchor tag that, when clicked, appends another anchor tag to the DOM. This is all done via jQuery. I know what the "id" attribute of the anchor tag to be added will be. However, when I try the following code, it fails to handle the newly added anchor tag's click event: $("#id").click(function() { ...
The problem that you have is that when you have the code `$('#Element').click(function(){...});`, it will only ever run the code on elements that were present when that code was ran in the first place, if you are using the latest version of jQuery, you should use this code to make it work: ``` //This makes sure that a...
404,941
<p>I want to be able to pass an "array" of values to my stored procedure, instead of calling "Add value" procedure serially.</p> <p>Can anyone suggest a way to do it? am I missing something here?</p> <p>Edit: I will be using PostgreSQL / MySQL, I haven't decided yet.</p>
[ { "answer_id": 404952, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "<p>You didn't indicate, but if you are referring to SQL server, <a href=\"http://vyaskn.tripod.com/passing_arrays_to_s...
2009/01/01
[ "https://Stackoverflow.com/questions/404941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41391/" ]
I want to be able to pass an "array" of values to my stored procedure, instead of calling "Add value" procedure serially. Can anyone suggest a way to do it? am I missing something here? Edit: I will be using PostgreSQL / MySQL, I haven't decided yet.
As Chris pointed, in PostgreSQL it's no problem - any base type (like int, text) has it's own array subtype, and you can also create custom types including composite ones. For example: ``` CREATE TYPE test as ( n int4, m int4 ); ``` Now you can easily create array of test: ``` select ARRAY[ row(1,2)::te...
404,957
<p>Using iPhone CALayer, I want a rotation animation for my spirit layer, but I also want a callback for the animation end, hot to do that? </p> <p>I think maybe I should use CABasicAnimation, but I don't know how to do rotation using CABasicAnimation, any idea?</p> <p>Thanks</p>
[ { "answer_id": 405395, "author": "Kendall Helmstetter Gelner", "author_id": 6330, "author_profile": "https://Stackoverflow.com/users/6330", "pm_score": 4, "selected": true, "text": "<p>If you set a delegate for a CAAnimation, you can add the callback method:</p>\n\n<pre><code>- (void)ani...
2009/01/01
[ "https://Stackoverflow.com/questions/404957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47936/" ]
Using iPhone CALayer, I want a rotation animation for my spirit layer, but I also want a callback for the animation end, hot to do that? I think maybe I should use CABasicAnimation, but I don't know how to do rotation using CABasicAnimation, any idea? Thanks
If you set a delegate for a CAAnimation, you can add the callback method: ``` - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag ``` That gets called when the animation is complete. Look for examples of rotating animations via a CGAffineTransform transformation matrix, as per this link: <http:...
404,975
<p>Using java, minus the exception handling, it is as simple as </p> <pre><code>FileOutputStream ostream = new FileOutputStream("\\\\host\\share"); PrintStream printStream = new PrintStream(ostream); printStream.print("HELLO PRINTER"); printStream.close(); ostream.close(); </code></pre>
[ { "answer_id": 405272, "author": "nakajima", "author_id": 39589, "author_profile": "https://Stackoverflow.com/users/39589", "pm_score": 1, "selected": false, "text": "<p>While I've never tried to print from Ruby, and while I don't have a Windows machine available to test on, it would see...
2009/01/01
[ "https://Stackoverflow.com/questions/404975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12417/" ]
Using java, minus the exception handling, it is as simple as ``` FileOutputStream ostream = new FileOutputStream("\\\\host\\share"); PrintStream printStream = new PrintStream(ostream); printStream.print("HELLO PRINTER"); printStream.close(); ostream.close(); ```
``` File.open("\\\\host\\share") do |f| f.print("HELLO PRINTER#{12.chr}") end ```
404,989
<p>I'm getting a "FormatException: Input string was not in a correct format" error that I don't understand.</p> <p>I'm using the following lines to write a string to a text file:</p> <pre><code>using (StreamWriter sw = new StreamWriter(myfilename, false, System.Text.Encoding.GetEncoding(enc))) { sw.Write(mystrin...
[ { "answer_id": 404994, "author": "Øyvind Skaar", "author_id": 49194, "author_profile": "https://Stackoverflow.com/users/49194", "pm_score": 5, "selected": true, "text": "<p>The overload you are using takes the format as the first parameter, and objects to inject after that.</p>\n\n<p>You...
2009/01/01
[ "https://Stackoverflow.com/questions/404989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
I'm getting a "FormatException: Input string was not in a correct format" error that I don't understand. I'm using the following lines to write a string to a text file: ``` using (StreamWriter sw = new StreamWriter(myfilename, false, System.Text.Encoding.GetEncoding(enc))) { sw.Write(mystring, Environment.NewLine...
The overload you are using takes the format as the first parameter, and objects to inject after that. You can do either of the following: ``` sw.Write(mystring + Environment.NewLine); ``` or ``` sw.Write("{0}{1}", mystring, Environment.NewLine); ```
404,995
<p>My question is how to check if a microphone and a speaker are from the same sound card on Windows platform. If they are from different cards, then the logic to handling timing will be different. I'm using both DSound and WMME API.</p>
[ { "answer_id": 409000, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 1, "selected": false, "text": "<p>WMI does give some information about sound cards. What I haven't been able to find out yet is whether its giving enough. ...
2009/01/01
[ "https://Stackoverflow.com/questions/404995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47681/" ]
My question is how to check if a microphone and a speaker are from the same sound card on Windows platform. If they are from different cards, then the logic to handling timing will be different. I'm using both DSound and WMME API.
WMI does give some information about sound cards. What I haven't been able to find out yet is whether its giving enough. Using "[WMI Code Creator](http://www.microsoft.com/downloads/details.aspx?familyid=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=en)" the following script lists everything that the [Win32\_SoundDe...
405,039
<p>Is there any way how to set <code>std::setw</code> manipulator (or its function <code>width</code>) permanently? Look at this:</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;algorithm&gt; #include &lt;iterator&gt; int main( void ) { int array[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256...
[ { "answer_id": 405068, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 5, "selected": true, "text": "<p>Well, it's not possible. No way to make it call <code>.width</code> each time again. But you can use boos...
2009/01/01
[ "https://Stackoverflow.com/questions/405039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21009/" ]
Is there any way how to set `std::setw` manipulator (or its function `width`) permanently? Look at this: ``` #include <iostream> #include <iomanip> #include <algorithm> #include <iterator> int main( void ) { int array[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256 }; std::cout.fill( '0' ); std::cout.flags( std::ios::he...
Well, it's not possible. No way to make it call `.width` each time again. But you can use boost, of course: ``` #include <boost/function_output_iterator.hpp> #include <boost/lambda/lambda.hpp> #include <algorithm> #include <iostream> #include <iomanip> int main() { using namespace boost::lambda; int a[] = { 1...
405,043
<pre><code>Response.Redirect(string.Format("myprofile.aspx?uid={0}&amp;result=saved#main",user.UserID)); </code></pre> <p>said code translates to</p> <p><strong>IE7</strong> - <code>myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&amp;result=saved</code></p> <p><strong>FF</strong>- <code>myprofile.aspx?uid=93...
[ { "answer_id": 405136, "author": "Daniel Crenna", "author_id": 18440, "author_profile": "https://Stackoverflow.com/users/18440", "pm_score": 1, "selected": false, "text": "<p>Maybe it is a regression issue from IE6?</p>\n\n<p>Did you try <a href=\"http://blogs.vertigo.com/personal/tompha...
2009/01/01
[ "https://Stackoverflow.com/questions/405043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2763/" ]
``` Response.Redirect(string.Format("myprofile.aspx?uid={0}&result=saved#main",user.UserID)); ``` said code translates to **IE7** - `myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved` **FF**- `myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved#main` why does IE7 drop my anchor?...
It would be quite the hack, but if IE isn't behaving, you could do this. pass a param as well, e.g. ``` uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved&hash=main#main ``` Then on your page (before the body close tag, or as an onload event), only for IE, extract the parameter if present and set the hash manual...
405,047
<p>I'm looking for an Objective-C way of sorting characters in a string, as per the answer to <a href="https://stackoverflow.com/questions/401834/how-to-elegantly-compute-the-anagram-signature-of-a-word-in-ruby">this</a> question.</p> <p>Ideally a function that takes an NSString and returns the sorted equivalent. </p>...
[ { "answer_id": 405162, "author": "sprintf", "author_id": 50712, "author_profile": "https://Stackoverflow.com/users/50712", "pm_score": 4, "selected": true, "text": "<pre><code>int char_compare(const char* a, const char* b) {\n if(*a &lt; *b) {\n return -1;\n } else if(*a &gt...
2009/01/01
[ "https://Stackoverflow.com/questions/405047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42404/" ]
I'm looking for an Objective-C way of sorting characters in a string, as per the answer to [this](https://stackoverflow.com/questions/401834/how-to-elegantly-compute-the-anagram-signature-of-a-word-in-ruby) question. Ideally a function that takes an NSString and returns the sorted equivalent. Additionally I'd like t...
``` int char_compare(const char* a, const char* b) { if(*a < *b) { return -1; } else if(*a > *b) { return 1; } else { return 0; } } NSString *sort_str(NSString *unsorted) { int len = [unsorted length] + 1; char *cstr = malloc(len); [unsorted getCString:cstr maxLength...
405,058
<p>I have the following file:</p> <pre><code>abcde kwakwa &lt;0x1A&gt; line3 linllll </code></pre> <p>Where <code>&lt;0x1A&gt;</code> represents a byte with the hex value of 0x1A. When attempting to read this file in Python as:</p> <pre><code>for line in open('t.txt'): print line, </code></pre> <p>It only reads...
[ { "answer_id": 405061, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 6, "selected": true, "text": "<p>0x1A is Ctrl-Z, and DOS historically used that as an end-of-file marker. For example, try using a command prompt...
2009/01/01
[ "https://Stackoverflow.com/questions/405058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I have the following file: ``` abcde kwakwa <0x1A> line3 linllll ``` Where `<0x1A>` represents a byte with the hex value of 0x1A. When attempting to read this file in Python as: ``` for line in open('t.txt'): print line, ``` It only reads the first two lines, and exits the loop. The solution seems to be to o...
0x1A is Ctrl-Z, and DOS historically used that as an end-of-file marker. For example, try using a command prompt, and "type"ing your file. It will only display the content up the Ctrl-Z. Python uses the Windows CRT function \_wfopen, which implements the "Ctrl-Z is EOF" semantics.
405,060
<p>Something like <code>.//div[@id='foo\d+]</code> to capture div tags with <code>id='foo123'</code>.</p> <p>I'm using .NET, if that matters.</p>
[ { "answer_id": 405081, "author": "Cristian Vat", "author_id": 20109, "author_profile": "https://Stackoverflow.com/users/20109", "pm_score": 5, "selected": false, "text": "<p>XPath 2.0 has some functions which support regular expressions: <code>matches()</code>, <code>replace()</code>, <c...
2009/01/01
[ "https://Stackoverflow.com/questions/405060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
Something like `.//div[@id='foo\d+]` to capture div tags with `id='foo123'`. I'm using .NET, if that matters.
As other answers have noted, **[XPath 1.0](http://www.w3.org/TR/xpath) does not support regular expressions**. **Nonetheless, you have the following options**: * **Use an XPath 1.0 expression** (note the [**`starts-with()`**](http://www.w3.org/TR/xpath#function-starts-with) and [**`translate()`**](http://www.w3.org/T...