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
342,122
<p>What are the best practices for naming ant targets? </p> <p>For example, what would you expect the target "test" to run? All unit tests? All functional tests? Both?</p> <p>What are the standard names used for running different types of tests (unit/functional/all)? Are there standards for target names to deploy ...
[ { "answer_id": 342155, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 1, "selected": false, "text": "<p>I think this is completely a point of personal preference, but I would use</p>\n\n<ul>\n<li><code>test</code> - for unit t...
2008/12/04
[ "https://Stackoverflow.com/questions/342122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6180/" ]
What are the best practices for naming ant targets? For example, what would you expect the target "test" to run? All unit tests? All functional tests? Both? What are the standard names used for running different types of tests (unit/functional/all)? Are there standards for target names to deploy software in J2SE? in...
See the [**"Naming Conventions"** section](http://wiki.apache.org/ant/TheElementsOfAntStyle#Naming_conventions) on this page : [The Elements of Ant Style](http://wiki.apache.org/ant/TheElementsOfAntStyle) > > The following targets are common to many builds. Always avoid changing > the behavior of a well-known target...
342,130
<p>Here's a minimal batch file, <code>demo.bat</code>, to illustrate my problem:</p> <pre><code>@ECHO off set /p foo=Enter foo: echo. echo you typed "%foo%" sqlcmd -? set /p bar=Enter bar: echo. echo you typed "%bar%" </code></pre> <p>I have an input file <code>foo.txt</code> that looks like so:</p> <pre> foo_val...
[ { "answer_id": 342223, "author": "Atif Aziz", "author_id": 6682, "author_profile": "https://Stackoverflow.com/users/6682", "pm_score": 2, "selected": false, "text": "<p>After some research, the following files don't appear to be unnecessary because they represent test assemblies for NUni...
2008/12/04
[ "https://Stackoverflow.com/questions/342130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7674/" ]
Here's a minimal batch file, `demo.bat`, to illustrate my problem: ``` @ECHO off set /p foo=Enter foo: echo. echo you typed "%foo%" sqlcmd -? set /p bar=Enter bar: echo. echo you typed "%bar%" ``` I have an input file `foo.txt` that looks like so: ``` foo_value bar_value ``` I run my batch file as `demo.bat <...
I can successfully run tests with only the following 6 NUnit files present: * nunit.core.dll * nunit.core.interfaces.dll * nunit.framework.dll * nunit.util.dll * nunit.console-runner.dll * nunit-console.exe
342,140
<p>I would like to keep a static counter in a garbage collected class and increment it using Interlocked::Increment. What's the C++/CLI syntax to do this?</p> <p>I've been trying variations on the following, but no luck so far:</p> <pre><code>ref class Foo { static __int64 _counter; __int64 Next() { ...
[ { "answer_id": 342283, "author": "McKenzieG1", "author_id": 3776, "author_profile": "https://Stackoverflow.com/users/3776", "pm_score": 4, "selected": true, "text": "<p>You need to use a <a href=\"http://msdn.microsoft.com/en-us/library/8903062a(VS.80).aspx\" rel=\"noreferrer\">tracking ...
2008/12/04
[ "https://Stackoverflow.com/questions/342140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
I would like to keep a static counter in a garbage collected class and increment it using Interlocked::Increment. What's the C++/CLI syntax to do this? I've been trying variations on the following, but no luck so far: ``` ref class Foo { static __int64 _counter; __int64 Next() { return System::Threadi...
You need to use a [tracking reference](http://msdn.microsoft.com/en-us/library/8903062a(VS.80).aspx) to your `_int64` value, using the % tracking reference notation: ``` ref class Bar { static __int64 _counter; __int64 Next() { __int64 %trackRefCounter = _counter; return System::Threading:...
342,147
<p>I recently ran up against a wall doing some bash shell programming where an associative array would have solved my problems. I googled about features of the KornShell (ksh) and learned that it supports associative arrays, so I installed Cygwin's pdksh (Public Domain KornShell).</p> <p>However, when trying to creat...
[ { "answer_id": 342207, "author": "Alastair", "author_id": 31038, "author_profile": "https://Stackoverflow.com/users/31038", "pm_score": 0, "selected": false, "text": "<p>Why not just use bash? It might not have explicit associative arrays, but you can <a href=\"http://linuxshellaccount.b...
2008/12/04
[ "https://Stackoverflow.com/questions/342147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34806/" ]
I recently ran up against a wall doing some bash shell programming where an associative array would have solved my problems. I googled about features of the KornShell (ksh) and learned that it supports associative arrays, so I installed Cygwin's pdksh (Public Domain KornShell). However, when trying to create an associ...
Take a look at ksh93, it supports associative arrays and is a much more complete/correct implementation of ksh. See: [kornshell.com](http://kornshell.com/)
342,149
<p>I'm trying to make an XML questions editor in flash. Basically I load in the XML into a Tree component - XML like so:</p> <pre><code>&lt;questions&gt; &lt;question id="1" type="radio" text="This is question 1" isBranch="true"&gt; &lt;option id="1.1" correct="false" text="This is option 1" /&gt; &lt;option id="1...
[ { "answer_id": 342207, "author": "Alastair", "author_id": 31038, "author_profile": "https://Stackoverflow.com/users/31038", "pm_score": 0, "selected": false, "text": "<p>Why not just use bash? It might not have explicit associative arrays, but you can <a href=\"http://linuxshellaccount.b...
2008/12/04
[ "https://Stackoverflow.com/questions/342149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to make an XML questions editor in flash. Basically I load in the XML into a Tree component - XML like so: ``` <questions> <question id="1" type="radio" text="This is question 1" isBranch="true"> <option id="1.1" correct="false" text="This is option 1" /> <option id="1.2" correct="false" text="This is o...
Take a look at ksh93, it supports associative arrays and is a much more complete/correct implementation of ksh. See: [kornshell.com](http://kornshell.com/)
342,151
<p>I'm trying to perform a once-through read of a large file (~4GB) using Java 5.0 x64 (on Windows XP).</p> <p>Initially the file read rate is very fast, but gradually the throughput slows down substantially, and my machine seems very unresponsive as time goes on.</p> <p>I've used ProcessExplorer to monitor the File ...
[ { "answer_id": 342172, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>I very much doubt that you're <em>really</em> getting 500MB per second from your disk. Chances are the data is cached...
2008/12/04
[ "https://Stackoverflow.com/questions/342151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to perform a once-through read of a large file (~4GB) using Java 5.0 x64 (on Windows XP). Initially the file read rate is very fast, but gradually the throughput slows down substantially, and my machine seems very unresponsive as time goes on. I've used ProcessExplorer to monitor the File I/O statistics, a...
I very much doubt that you're *really* getting 500MB per second from your disk. Chances are the data is cached by the operating system - and that the 20MB per second is what happens when it *really* hits the disk. This will quite possibly be visible in the disk section of the Vista Resource Manager - and a low-tech wa...
342,152
<p>I was working with a new C++ developer a while back when he asked the question: "Why can't variable names start with numbers?"</p> <p>I couldn't come up with an answer except that some numbers can have text in them (123456L, 123456U) and that wouldn't be possible if the compilers were thinking everything with some ...
[ { "answer_id": 342176, "author": "Pyrolistical", "author_id": 21838, "author_profile": "https://Stackoverflow.com/users/21838", "pm_score": 7, "selected": false, "text": "<p>Well think about this:</p>\n\n<pre><code>int 2d = 42;\ndouble a = 2d;\n</code></pre>\n\n<p>What is a? 2.0? or 42...
2008/12/04
[ "https://Stackoverflow.com/questions/342152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34183/" ]
I was working with a new C++ developer a while back when he asked the question: "Why can't variable names start with numbers?" I couldn't come up with an answer except that some numbers can have text in them (123456L, 123456U) and that wouldn't be possible if the compilers were thinking everything with some amount of ...
Because then a string of digits would be a valid identifier as well as a valid number. ``` int 17 = 497; int 42 = 6 * 9; String 1111 = "Totally text"; ```
342,167
<p>The function below is logging the "0", "z" and the "1" ok... but its not capturing the "Z" (shift-z)... any help would be appreciated...</p> <pre><code>__declspec(dllexport) LRESULT CALLBACK HookProc (UINT nCode, WPARAM wParam, LPARAM lParam) { if ((nCode == HC_ACTION) &amp;&amp; (wParam == WM_KEYUP)) { ...
[ { "answer_id": 342213, "author": "arul", "author_id": 15409, "author_profile": "https://Stackoverflow.com/users/15409", "pm_score": 3, "selected": false, "text": "<p>There's no virtual key code for Z.\nTry something like this:</p>\n\n<pre><code> case 90:\n if(G...
2008/12/04
[ "https://Stackoverflow.com/questions/342167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37109/" ]
The function below is logging the "0", "z" and the "1" ok... but its not capturing the "Z" (shift-z)... any help would be appreciated... ``` __declspec(dllexport) LRESULT CALLBACK HookProc (UINT nCode, WPARAM wParam, LPARAM lParam) { if ((nCode == HC_ACTION) && (wParam == WM_KEYUP)) { // This Struct ge...
The keyboard does not send *characters*. It sends *keys*. Whether you're typing *z* or *Z*, you're still pressing the same key, and that key has the same VK code both times. You should also get notification when the Shift key is pressed or released. You can use those notifications to translate the keystrokes into char...
342,171
<p>I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same ...
[ { "answer_id": 342372, "author": "Rob", "author_id": 9236, "author_profile": "https://Stackoverflow.com/users/9236", "pm_score": 2, "selected": true, "text": "<p>Turn off window redrawing when filling the combos. e.g.:</p>\n\n<pre><code>m_wndCombo.SetRedraw(FALSE);\n// Fill combo here\n....
2008/12/04
[ "https://Stackoverflow.com/questions/342171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6701/" ]
I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same data?
Turn off window redrawing when filling the combos. e.g.: ``` m_wndCombo.SetRedraw(FALSE); // Fill combo here ... m_wndCombo.SetRedraw(TRUE); m_wndCombo.Invalidate(); ``` This might help.
342,189
<p>I've written a fairly simple java application that allows you to drag your mouse and based on the length of the mouse drag you did, it will shoot a ball in that direction, bouncing off walls as it goes.</p> <p>Here is a quick screenshot:<br> <a href="http://img222.imageshack.us/img222/3179/ballbouncemf9.png">alt te...
[ { "answer_id": 342205, "author": "Bill K", "author_id": 12943, "author_profile": "https://Stackoverflow.com/users/12943", "pm_score": 5, "selected": true, "text": "<p>What you have to do is constantly subtract a small constant (something that represents your 9.8 m/s) from your yVector. ...
2008/12/04
[ "https://Stackoverflow.com/questions/342189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've written a fairly simple java application that allows you to drag your mouse and based on the length of the mouse drag you did, it will shoot a ball in that direction, bouncing off walls as it goes. Here is a quick screenshot: [alt text http://img222.imageshack.us/img222/3179/ballbouncemf9.png](http://img222.im...
What you have to do is constantly subtract a small constant (something that represents your 9.8 m/s) from your yVector. When the ball is going down (yVector is already negative), this would make it go faster. When it's going up (yVector is positive) it would slow it down. This would not account for friction, so the th...
342,218
<p>What techniques are available for sending an email via a webpage or a form on a webpage? </p> <p>I've got some background idea that you POST the form data to a script but I've don't really know what a cgi script is (I'd love to learn if this is the suggested method!) or what the current practice is.</p> <p>This is...
[ { "answer_id": 342222, "author": "Michael Kniskern", "author_id": 26327, "author_profile": "https://Stackoverflow.com/users/26327", "pm_score": 0, "selected": false, "text": "<p>If you are using the ASP.NET 2.0, you can use the System.Net.Mail namespace.\n<a href=\"http://www.systemnetma...
2008/12/04
[ "https://Stackoverflow.com/questions/342218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40443/" ]
What techniques are available for sending an email via a webpage or a form on a webpage? I've got some background idea that you POST the form data to a script but I've don't really know what a cgi script is (I'd love to learn if this is the suggested method!) or what the current practice is. This is just to provide ...
When you submit a form, the data in that form gets sent to the server-side script. For example, in PHP you access that data with the `$_POST` array, the `<input name="">` becomes the arrays index.. For example.. ``` // <form action="mailer.php">[..]<input name="subject" [..]><input name="content" [..]></form> echo("Th...
342,219
<p>I am trying to select a record out of the table1 by joining table2 and using table2 columns in the WHERE statement. Col1 and Col2 in table1 can be stored in col1 of table2. I need to join col1 of table2 with either the value of col1 or col2 in table1</p> <p>here is the sql statement I created so (pseudo):</p> <p...
[ { "answer_id": 342241, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "<p>That should be fine. Another way to write the same condition is as follows:</p>\n\n<pre><code>... JOIN table2 t2 on...
2008/12/04
[ "https://Stackoverflow.com/questions/342219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
I am trying to select a record out of the table1 by joining table2 and using table2 columns in the WHERE statement. Col1 and Col2 in table1 can be stored in col1 of table2. I need to join col1 of table2 with either the value of col1 or col2 in table1 here is the sql statement I created so (pseudo): ``` SELECT t1.C...
That should be fine. Another way to write the same condition is as follows: ``` ... JOIN table2 t2 on t2.Col1 IN (t1.Col1, t1.Col2) ``` It shouldn't matter which way you do it in this case. Do what you find more readable.
342,250
<p>I need to read the value of a property from a file in an Ant script and strip off the first few characters. The property in question is</p> <pre><code>path=file:C:/tmp/templates </code></pre> <p>This property is store in a file that I can access within the ant script via</p> <pre><code>&lt;property file="${web.in...
[ { "answer_id": 342274, "author": "Dan Dyer", "author_id": 5171, "author_profile": "https://Stackoverflow.com/users/5171", "pm_score": 3, "selected": true, "text": "<p>I used the <a href=\"http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html\" rel=\"nofollow noreferrer\">prop...
2008/12/04
[ "https://Stackoverflow.com/questions/342250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I need to read the value of a property from a file in an Ant script and strip off the first few characters. The property in question is ``` path=file:C:/tmp/templates ``` This property is store in a file that I can access within the ant script via ``` <property file="${web.inf.dir}/config.properties"/> ``` I have...
I used the [propertyregex task](http://ant-contrib.sourceforge.net/tasks/tasks/propertyregex.html) from [Ant Contrib](http://ant-contrib.sourceforge.net/) to do something similar.
342,263
<p>When I try to run the following code (from the REPL) in Clojure:</p> <pre><code>(dotimes [i 5] (.start (Thread. (fn [] (Thread/sleep (rand 1000)) (println (format "Finished %d on %s" i (Thread/currentThread))))))) </code></pre> <p>I get the following error:</p> <pre><code>java.lang.Exception:...
[ { "answer_id": 342454, "author": "Brian Carper", "author_id": 23070, "author_profile": "https://Stackoverflow.com/users/23070", "pm_score": 4, "selected": true, "text": "<p>Your code works for me using the latest SVN (1144).</p>\n\n<pre><code>user&gt; (dotimes [i 5] (.start (Thread. (fn ...
2008/12/04
[ "https://Stackoverflow.com/questions/342263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7648/" ]
When I try to run the following code (from the REPL) in Clojure: ``` (dotimes [i 5] (.start (Thread. (fn [] (Thread/sleep (rand 1000)) (println (format "Finished %d on %s" i (Thread/currentThread))))))) ``` I get the following error: ``` java.lang.Exception: Unable to resolve symbol: i in this ...
Your code works for me using the latest SVN (1144). ``` user> (dotimes [i 5] (.start (Thread. (fn [] (Thread/sleep (rand 1000)) (println (format "Finished %d on %s" i (Thread/currentThread))))))) Finished 0 on Thread[Thread-16,5,main] Finished 4 on Thread[Thread-20,5,main] Finished 3 on Thread[Thread-19,5,main] Finis...
342,268
<p>I am using the following method to browse for a file:</p> <pre><code> OpenFileDialog.ShowDialog() PictureNameTextEdit.Text = OpenFileDialog.FileName </code></pre> <p>Is there a way get ONLY the file name?</p> <p>The <strong>FileName</strong> method returns the entire path and file name.</p> <p>i.e. I want...
[ { "answer_id": 342272, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx\" rel=\"noreferrer\"><code>Path....
2008/12/04
[ "https://Stackoverflow.com/questions/342268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4964/" ]
I am using the following method to browse for a file: ``` OpenFileDialog.ShowDialog() PictureNameTextEdit.Text = OpenFileDialog.FileName ``` Is there a way get ONLY the file name? The **FileName** method returns the entire path and file name. i.e. I want Foo.txt instead of C:\SomeDirectory\Foo.txt
Use [`Path.GetFileName(fullPath)`](http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx) to get just the filename part, like this: ``` OpenFileDialog.ShowDialog() PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName) ```
342,270
<p>I have a large set of XML files of a propriatary schema -the XML files define binary communication protocol (message structure).</p> <p>I'd like to leverage Google's protocol buffers technology. </p> <p>I am using existing code to load the XML files into an object model (in memory). I'd like to generate a .proto ...
[ { "answer_id": 342272, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx\" rel=\"noreferrer\"><code>Path....
2008/12/04
[ "https://Stackoverflow.com/questions/342270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38265/" ]
I have a large set of XML files of a propriatary schema -the XML files define binary communication protocol (message structure). I'd like to leverage Google's protocol buffers technology. I am using existing code to load the XML files into an object model (in memory). I'd like to generate a .proto file from that ob...
Use [`Path.GetFileName(fullPath)`](http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx) to get just the filename part, like this: ``` OpenFileDialog.ShowDialog() PictureNameTextEdit.Text = System.IO.Path.GetFileName(OpenFileDialog.FileName) ```
342,281
<p>I have been tasked with creating a program that will generate an amortization schedule. I have only done a bit of research so far, but I need to calculate out payments, interest per payment and principal per payment. Can any one point me in the right direction to figure this out? While I will be writing this in RPG,...
[ { "answer_id": 342302, "author": "Brian", "author_id": 16457, "author_profile": "https://Stackoverflow.com/users/16457", "pm_score": 2, "selected": false, "text": "<p>There are plenty of sites that offer these formulas. One is below:\n<a href=\"http://www.math4finance.com/financial-form...
2008/12/04
[ "https://Stackoverflow.com/questions/342281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2535/" ]
I have been tasked with creating a program that will generate an amortization schedule. I have only done a bit of research so far, but I need to calculate out payments, interest per payment and principal per payment. Can any one point me in the right direction to figure this out? While I will be writing this in RPG, I ...
Here is what I ended up creating. I have posted the whole test program. It is written in RPG, but should be easily be figured out for any other languages. ``` H ActGrp(*caller) BndDir('MODULES') DftActGrp(*no) //********************************************************************* // Program . . . . . AMORT ...
342,285
<p>I have a table in a SQL 2005 database that contains a column defined as a xml datatype. I'm trying to write stored proc that queries the xml and returns a resultset from a select statement. I've seen examples of returning scalar values or xml but not how to return a resultset.</p> <p>Am I going to have to use ope...
[ { "answer_id": 342316, "author": "GalacticCowboy", "author_id": 29638, "author_profile": "https://Stackoverflow.com/users/29638", "pm_score": 2, "selected": false, "text": "<p>The xml data type has its own set of methods that you can use to deal with the data in the column. In this case...
2008/12/04
[ "https://Stackoverflow.com/questions/342285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27714/" ]
I have a table in a SQL 2005 database that contains a column defined as a xml datatype. I'm trying to write stored proc that queries the xml and returns a resultset from a select statement. I've seen examples of returning scalar values or xml but not how to return a resultset. Am I going to have to use openxml or is t...
The xml data type has its own set of methods that you can use to deal with the data in the column. In this case you'd probably use something like this: ``` select xmlColumnName.value('XpathExpression', 'outputSqlType') from dataTable ``` For example, ``` select xmlColumnName.value('/root/node[@name="myname"]', 'va...
342,290
<p>I'm looking to inspect SQL statements in Java/jdbc code to ensure that the SQL to be executed is of acceptable quality. Neither PMD not Findbugs appears to have JDBC or sql rules. I could use p6spy to log the SQL and look at that way, but this is manual. </p> <p>I'm wondering if the strategy of of using PMD/Findbu...
[ { "answer_id": 342321, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": true, "text": "<p>This is a tricky problem. Comparison operators like <code>=</code> and <code>IN()</code> are some cases, but there'...
2008/12/04
[ "https://Stackoverflow.com/questions/342290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13753/" ]
I'm looking to inspect SQL statements in Java/jdbc code to ensure that the SQL to be executed is of acceptable quality. Neither PMD not Findbugs appears to have JDBC or sql rules. I could use p6spy to log the SQL and look at that way, but this is manual. I'm wondering if the strategy of of using PMD/Findbugs/etc to c...
This is a tricky problem. Comparison operators like `=` and `IN()` are some cases, but there's also: `!= <> < <= > >= LIKE`. How do you spot cases of interpolating application variables as literals in expressions? ``` String sql = "SELECT *, " + someJavaVar + " AS constant_column FROM mytable"; ``` You could search...
342,320
<p>I have a very complicated .NET application that contains cut/copy/paste functionality. I want to enable/disable cut/copy/paste buttons depending on the selected control/content. The app has many user controls. What is the best way to achieve this?</p> <p>Thanks</p>
[ { "answer_id": 342336, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 0, "selected": false, "text": "<p>One approach:</p>\n\n<p>Add a delegate to the appropriate event for each control you wish to monitor. </p>\n\n<p>e.g...
2008/12/04
[ "https://Stackoverflow.com/questions/342320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a very complicated .NET application that contains cut/copy/paste functionality. I want to enable/disable cut/copy/paste buttons depending on the selected control/content. The app has many user controls. What is the best way to achieve this? Thanks
Are you talking about catching the focus of the control or about a design pattern in which to do this? I would probably register each control that is to be enabled/disabled with the control that it's dependent on. Then when the dependent control gets selected/focused, spin through the controls and enable/disable each ...
342,325
<p>This case is going to sound complicated, but it's not that bad. The javascript at the end of this code <em>seems</em> to be sound.</p> <p>EDIT: Here's the page running on a live server. The first example doesn't alternate between open and closed because I ripped out a lot of code in order to narrow the example down...
[ { "answer_id": 343161, "author": "Sergiu Damian", "author_id": 41345, "author_profile": "https://Stackoverflow.com/users/41345", "pm_score": 4, "selected": true, "text": "<p>I don't have time to read your entire code, but please pay attention to the following: you may be copying a HTML c...
2008/12/04
[ "https://Stackoverflow.com/questions/342325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12382/" ]
This case is going to sound complicated, but it's not that bad. The javascript at the end of this code *seems* to be sound. EDIT: Here's the page running on a live server. The first example doesn't alternate between open and closed because I ripped out a lot of code in order to narrow the example down as much as I cou...
I don't have time to read your entire code, but please pay attention to the following: you may be copying a HTML chunk and creating a clone of it in your code. This way, you actually get two textboxes with the same Id, although you see only one of them. At postback, the browser concatenates the values as a comma-separa...
342,330
<p><em>Existing</em> code is using an <code>asp:repeater</code> to build an HTML table. (emphasis on the existing design). This is some partial pseudo-code to generate the table:</p> <pre><code>&lt;asp:repeater OnItemDataBound="ItemDataBound" ... &gt; &lt;headertemplate&gt; &lt;table&gt; &lt;thead&g...
[ { "answer_id": 342343, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": true, "text": "<p>Place two ASP:Placeholder controls in your item template. In the codebehind, on the ItemDataBound event, determine which s...
2008/12/04
[ "https://Stackoverflow.com/questions/342330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
*Existing* code is using an `asp:repeater` to build an HTML table. (emphasis on the existing design). This is some partial pseudo-code to generate the table: ``` <asp:repeater OnItemDataBound="ItemDataBound" ... > <headertemplate> <table> <thead> <tr> <td>Date</td> ...
Place two ASP:Placeholder controls in your item template. In the codebehind, on the ItemDataBound event, determine which style you want to show, and hide one placeholder.
342,333
<p>I see the following code in the attribute_fu plugin:</p> <pre><code>module AttributeFu module Associations #:nodoc: def self.included(base) #:nodoc: ...
[ { "answer_id": 342341, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 0, "selected": false, "text": "<p>In that case, <code>self</code> does not mean the anObject, it's more a sugar construct.</p>\n\n<pre><code>class &lt;&lt; s...
2008/12/04
[ "https://Stackoverflow.com/questions/342333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
I see the following code in the attribute\_fu plugin: ``` module AttributeFu module Associations #:nodoc: def self.included(base) #:nodoc: ...
``` # init.rb ActiveRecord::Base.class_eval { include AttributeFu::Associations } module AttributeFu module Associations def self.included(base) # base == ActiveRecord::Base (the class) base.class_eval do # class_eval makes self == ActiveRecord::Base, and makes def d...
342,371
<p>Linux 2.6.18-92.el5, ruby 1.8.7, Rails 2.2.2, mysql gem 2.7</p> <p>I installed the MySQL binary distribution under /usr/local, then installed the mysql gem like this:</p> <pre><code>gem install mysql --no-rdoc --no-ri \ -- --with-mysql-include=/usr/local/mysql/include \ --with-mysql-lib=/usr/local/mysql/lib \ ...
[ { "answer_id": 342385, "author": "pho79", "author_id": 43397, "author_profile": "https://Stackoverflow.com/users/43397", "pm_score": 1, "selected": false, "text": "<p>Possibly it had something to do with the prefix you used when installing mysql?\n--with-mysql-lib=/usr/local/mysql/lib</p...
2008/12/04
[ "https://Stackoverflow.com/questions/342371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
Linux 2.6.18-92.el5, ruby 1.8.7, Rails 2.2.2, mysql gem 2.7 I installed the MySQL binary distribution under /usr/local, then installed the mysql gem like this: ``` gem install mysql --no-rdoc --no-ri \ -- --with-mysql-include=/usr/local/mysql/include \ --with-mysql-lib=/usr/local/mysql/lib \ --with-mysql-config...
I had issues as well (on Mac OS X), and was just as frustrated that `gem install mysql` wasn't as simple as it used to be. The short-sighted answer is that the mysql gem needs to build native extensions, and to do that, it needs some path information (specific to your system) about MySQL libraries. The most reliable w...
342,381
<p>I have a table which has roughly 10 cells, 4 different types. I subclassed UITextViewCell because I wanted to have an IBOutlet to a label and to a UITextField. Not sure if that was the best way of handling it, but it works thus far. Next, I had a cell for gender, so I figured instead of subclassing UITableViewCell, ...
[ { "answer_id": 342566, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 0, "selected": false, "text": "<p>You could always just add the control to your subclass but have it hidden. Then, depending on the row, set the cell's...
2008/12/04
[ "https://Stackoverflow.com/questions/342381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
I have a table which has roughly 10 cells, 4 different types. I subclassed UITextViewCell because I wanted to have an IBOutlet to a label and to a UITextField. Not sure if that was the best way of handling it, but it works thus far. Next, I had a cell for gender, so I figured instead of subclassing UITableViewCell, I t...
I'd actually go for subclassing. Subclassing is cheap. The cells have different types, and what you're doing now is iterating through all the subviews and checking each view for membership of a class - this is slow! A subclass will clean up your code and make it faster at the same time. Don't try to shoe-horn too many ...
342,398
<p>We have created a VSTO addin for Outlook Meetings.</p> <p>As part of this we trap on the <code>SendEvent</code> of the message on the <code>FormRegionShowing</code> event:</p> <pre><code>_apptEvents.Send += new Microsoft.Office.Interop.Outlook.ItemEvents_SendEventHandler(_apptEvents_Send); </code></pre> <p>The me...
[ { "answer_id": 342400, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 0, "selected": false, "text": "<p>I don't know about the problems, but it's <a href=\"http://unicode.org/cgi-bin/GetUnihanData.pl?codepoint=9996\" ...
2008/12/04
[ "https://Stackoverflow.com/questions/342398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have created a VSTO addin for Outlook Meetings. As part of this we trap on the `SendEvent` of the message on the `FormRegionShowing` event: ``` _apptEvents.Send += new Microsoft.Office.Interop.Outlook.ItemEvents_SendEventHandler(_apptEvents_Send); ``` The method `_apptEvents_Send` then tests on a couple of prope...
Have you verified that the value that gets stored in the database is actually U+003f (question mark)? There are all sorts of conventions for how to display characters that don't exist in the chosen font, and displaying them as ?' is fairly common. So most likely, the character gets stored correctly, and for whatever r...
342,409
<p>I have binary data in an unsigned char variable. I need to convert them to PEM base64 in c. I looked in openssl library but i could not find any function. Does any body have any idea?</p>
[ { "answer_id": 342415, "author": "stesch", "author_id": 41860, "author_profile": "https://Stackoverflow.com/users/41860", "pm_score": 4, "selected": false, "text": "<p>glib has functions for base64 encoding: <a href=\"https://developer.gnome.org/glib/stable/glib-Base64-Encoding.html\" re...
2008/12/04
[ "https://Stackoverflow.com/questions/342409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have binary data in an unsigned char variable. I need to convert them to PEM base64 in c. I looked in openssl library but i could not find any function. Does any body have any idea?
Here's the one I'm using: ``` #include <stdint.h> #include <stdlib.h> static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', ...
342,411
<p>I want some of the items to be bold depending on a property of an object i'm putting into the listbox.</p> <p>I think you can do it with changing templates but can't seem to find an example.</p> <p>Thanks!</p>
[ { "answer_id": 342460, "author": "a_hardin", "author_id": 1497, "author_profile": "https://Stackoverflow.com/users/1497", "pm_score": 3, "selected": false, "text": "<p>You can do this using DataTriggers. For a simple example of using a DataTrigger you can check out <a href=\"http://mani...
2008/12/04
[ "https://Stackoverflow.com/questions/342411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want some of the items to be bold depending on a property of an object i'm putting into the listbox. I think you can do it with changing templates but can't seem to find an example. Thanks!
You can do it more simply than that if you use a converter (IntToFontWeightConverter, for example). Set up an item template: ``` <DataTemplate x:Key="BoldTemplate"> <TextBlock FontWeight="{Binding Path=Position, Converter={StaticResource IntToFontWeightConverter}}" Text="{Binding Path=Name}" ...
342,434
<p>I'm developing a Django app, and I'm trying to use Python's logging module for error/trace logging. Ideally I'd like to have different loggers configured for different areas of the site. So far I've got all of this working, but one thing has me scratching my head.</p> <p>I have the root logger going to sys.stderr...
[ { "answer_id": 342517, "author": "Sergey Golovchenko", "author_id": 26592, "author_profile": "https://Stackoverflow.com/users/26592", "pm_score": 1, "selected": false, "text": "<p>Why using python logger instead of django-logging? Give it a try it might just solve your problem. </p>\n\n<...
2008/12/04
[ "https://Stackoverflow.com/questions/342434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33775/" ]
I'm developing a Django app, and I'm trying to use Python's logging module for error/trace logging. Ideally I'd like to have different loggers configured for different areas of the site. So far I've got all of this working, but one thing has me scratching my head. I have the root logger going to sys.stderr, and I have...
Allow me to answer my own question. The underlying problem here is that settings.py gets imported twice, or maybe even more (See [here](http://www.mail-archive.com/django-users@googlegroups.com/msg39059.html)). (I still don't understand why this is. Maybe some Django expert could explain that to me.) This seems to be t...
342,435
<p>Given an instance <code>x</code> of <code>Callable&lt;T&gt;</code>, how can I run <code>x</code> in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a <code>Process</code> from a <code>Callable</code>? Is there a standard <code>Executor</c...
[ { "answer_id": 342450, "author": "Yoni", "author_id": 36071, "author_profile": "https://Stackoverflow.com/users/36071", "pm_score": 0, "selected": false, "text": "<p>Have a look at ProcessBuilder class, it gives you the option to capture the stdout and stderr of the process that it launc...
2008/12/04
[ "https://Stackoverflow.com/questions/342435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
Given an instance `x` of `Callable<T>`, how can I run `x` in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a `Process` from a `Callable`? Is there a standard `Executor` that gives control over input and output? [UPDATE] It's not important...
More generally: > > Given an instance x of Callable utilizing global variables A and B, how can I run x concurrently such that x sees custom values for A and B, rather than the "original" values of A and B? > > > And the best answer is, don't use global variables. Dependency inject things like that. Extend Callab...
342,437
<p>Which method makes the most sense for importing a module in python that is version specific? My use case is that I'm writing code that will be deployed into a python 2.3 environment and in a few months be upgraded to python 2.5. This:</p> <pre><code>if sys.version_info[:2] &gt;= (2, 5): from string import Templ...
[ { "answer_id": 342465, "author": "Jason Baker", "author_id": 2147, "author_profile": "https://Stackoverflow.com/users/2147", "pm_score": 2, "selected": false, "text": "<p>I would probably argue that the second one would be preferable. Sometimes, you can install a module from a newer ver...
2008/12/04
[ "https://Stackoverflow.com/questions/342437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33786/" ]
Which method makes the most sense for importing a module in python that is version specific? My use case is that I'm writing code that will be deployed into a python 2.3 environment and in a few months be upgraded to python 2.5. This: ``` if sys.version_info[:2] >= (2, 5): from string import Template else: fro...
Always the second way - you never know what different Python installations will have installed. `Template` is a specific case where it matters less, but when you test for the capability instead of the versioning you're always more robust. That's how I make [Testoob](http://www.testoob.org) support Python 2.2 - 2.6: I ...
342,438
<p>I have many requires and includes and i was wondering if there's something that can help me look at the whole of php code when a webpage is loaded. the reason i'm asking is that after fiddling with some code i cannot put any php code anymore as it will not be "sensed" by the compiler. like if i put anything inside t...
[ { "answer_id": 342463, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 3, "selected": true, "text": "<p>Not entirely sure what you are after...</p>\n\n<p>The get_included_files function can allow you to view a list of all ...
2008/12/04
[ "https://Stackoverflow.com/questions/342438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419730/" ]
I have many requires and includes and i was wondering if there's something that can help me look at the whole of php code when a webpage is loaded. the reason i'm asking is that after fiddling with some code i cannot put any php code anymore as it will not be "sensed" by the compiler. like if i put anything inside the ...
Not entirely sure what you are after... The get\_included\_files function can allow you to view a list of all of the files php has loaded at that point. You may also find using grep or the "find in files" function in your editor (if it has one) can help you track down something in the code that you know is there any ...
342,455
<p>I'm developing a script that involves creating an email contact and forwarding mail to that contact. Last part of the script is to automatically send a test email to the address to make sure the forwarding works.</p> <p>So I use the following code:</p> <pre><code>[void] [Reflection.Assembly]::LoadWithPartialName("...
[ { "answer_id": 342547, "author": "Don Jones", "author_id": 40405, "author_profile": "https://Stackoverflow.com/users/40405", "pm_score": 0, "selected": false, "text": "<p>If you change your mind about using Outlook, look at the PowerShell Community Extensions (free) on CodePlex. They off...
2008/12/04
[ "https://Stackoverflow.com/questions/342455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/456628/" ]
I'm developing a script that involves creating an email contact and forwarding mail to that contact. Last part of the script is to automatically send a test email to the address to make sure the forwarding works. So I use the following code: ``` [void] [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Core...
I was having similar issues where some of the COM objects do not seem to populate fully (seems to have something to do with the corporate Outlook setup - perhaps anti-virus measures?). However, if you comment out the `$msg.Recipients.Add("me@example.com")` line and added `$msg.Display()` you can add the recipients and ...
342,468
<p>I've been benchmarking the performance of a framework I'm writing in Perl and I'm getting a 50% decrease in requests per second over our existing codebase (some hit is understandable, because we're going from procedural spaghetti code to an OOP MVC framework).</p> <p>The application is running under mod_perl, and I...
[ { "answer_id": 342482, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 4, "selected": true, "text": "<p>Assuming your applications don't change the config at all, move it into a begin block:</p>\n\n<pre><code># this code goes a...
2008/12/04
[ "https://Stackoverflow.com/questions/342468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3404/" ]
I've been benchmarking the performance of a framework I'm writing in Perl and I'm getting a 50% decrease in requests per second over our existing codebase (some hit is understandable, because we're going from procedural spaghetti code to an OOP MVC framework). The application is running under mod\_perl, and I've added...
Assuming your applications don't change the config at all, move it into a begin block: ``` # this code goes at file scope my $config; BEGIN { $config = { Config::General->new( ... )->getall } } # when creating a new instance $self->config( $config ); ``` And make sure all your modules are compiled in startup.pl...
342,509
<p>Is it possible to read the data in the php $_SESSION array in the .htaccess file in Apache? So say I have the following:</p> <pre><code>$_SESSION['foo'] = 'bar'; </code></pre> <p>could I then in .htaccess do something like:</p> <pre><code>RewriteRule bla.png folder/{the php session var foo}/file.png </code></pre>...
[ { "answer_id": 342533, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 4, "selected": true, "text": "<p>I'm not aware that its possible.</p>\n\n<p>But I can think of a few workarounds involving rewriting to a PHP script.</...
2008/12/05
[ "https://Stackoverflow.com/questions/342509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35197/" ]
Is it possible to read the data in the php $\_SESSION array in the .htaccess file in Apache? So say I have the following: ``` $_SESSION['foo'] = 'bar'; ``` could I then in .htaccess do something like: ``` RewriteRule bla.png folder/{the php session var foo}/file.png ``` Is that possible? I already have a working...
I'm not aware that its possible. But I can think of a few workarounds involving rewriting to a PHP script.
342,529
<p>Anybody ever had the error "Installation of the "Microsoft Expression Web 2" product has reported the following error: -2147024873.. " when trying to install Microsoft Expression Web 2 or Microsoft Expression Studio? This is the error I'm getting, but I can't figure out what the problem is. I have no beta or RC or...
[ { "answer_id": 342534, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 2, "selected": false, "text": "<p><code>System.Exception</code> implements <code>ISerializable</code> and it is the base class for all exceptions, so...
2008/12/05
[ "https://Stackoverflow.com/questions/342529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
Anybody ever had the error "Installation of the "Microsoft Expression Web 2" product has reported the following error: -2147024873.. " when trying to install Microsoft Expression Web 2 or Microsoft Expression Studio? This is the error I'm getting, but I can't figure out what the problem is. I have no beta or RC or pre ...
Yes and no. As Jeff and others have pointed out, the all exception classes should and almost always are serializable. If you run across a particular exception class that is not serializable, it is quite possibly a bug. But when considering serializability you need to consider both the immediate class and all types wh...
342,532
<p>I'm trying to animate a block level element using jQuery. The page loads with the element styled with <code>display: none</code>. Id like it to <code>slideDown</code> whilst transparent and then <code>fadeIn</code> the content using the callback, however <code>slideDown</code> appears to set the visibility to full b...
[ { "answer_id": 342569, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 0, "selected": false, "text": "<p>How about:</p>\n\n<pre><code>$('#hiddenElement').css(\"opacity\", 0).slideDown().animate({opacity:1})\n</code></pre>\n" ...
2008/12/05
[ "https://Stackoverflow.com/questions/342532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/199/" ]
I'm trying to animate a block level element using jQuery. The page loads with the element styled with `display: none`. Id like it to `slideDown` whilst transparent and then `fadeIn` the content using the callback, however `slideDown` appears to set the visibility to full before `fadeIn` is called, resulting in the cont...
a few probable issues with your code: are you setting the content to hide as well in the beginning? are you calling `fadeIn` during the `slideDown` callback? here's some example HTML/code that will `fadeIn` after the `slideDown` ``` $('div').hide(); // make sure you hide both container/content $('#container').slideD...
342,543
<p>I'm using .net's PrintPreviewDialog and whenever it's generating a preview, it locks up my GUI in the background and makes it look like it has crashed until the preview is finished. Seeing how the .net's page progress window that pops up isn't a dialog, the back ground can be selected which then comes to the front i...
[ { "answer_id": 342560, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 1, "selected": false, "text": "<p>You should probably call those methods in a different thread if they take so long.\nInvestigate the use of <a href=\"htt...
2008/12/05
[ "https://Stackoverflow.com/questions/342543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24571/" ]
I'm using .net's PrintPreviewDialog and whenever it's generating a preview, it locks up my GUI in the background and makes it look like it has crashed until the preview is finished. Seeing how the .net's page progress window that pops up isn't a dialog, the back ground can be selected which then comes to the front in a...
the ShowDialog method creates a modal window, it blocks the main thread. the Show method creates a nonmodal window, it doesn't block the main thread. When you call > > this.printDocument.Print(); > > > it again does its work in the main thread. To do that in a background thread, you could try something like (o...
342,546
<p>What would be the fastest way, to merge 2 XML files, so I would locate a node in first one, empty it, take all children from the same tag (same node) in second XML and put it in the first one.</p>
[ { "answer_id": 342564, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 0, "selected": false, "text": "<p>Check out this article on MSDN: <a href=\"http://support.microsoft.com/kb/311530\" rel=\"nofollow noreferrer\">Arti...
2008/12/05
[ "https://Stackoverflow.com/questions/342546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24839/" ]
What would be the fastest way, to merge 2 XML files, so I would locate a node in first one, empty it, take all children from the same tag (same node) in second XML and put it in the first one.
You can load both files into two `XElement` objects, locate the target nodes in both objects and do the switch. Here is a sample: ``` var nodes1 = XDocument.Parse(file1).Element("test").Element("nodes"); var nodes2 = XDocument.Parse(file2).Element("test").Element("nodes"); nodes1.Nodes().Remove(); nodes1.Add(nodes2....
342,554
<p>Is it possible to create an HTML email signature for <strong>Outlook 2003</strong> or above that doesn't reference external images?</p> <p>That is, using those special "cid" reference but embed the image itself in the signature and not on the file system or network.</p> <p>This is for an web application that gener...
[ { "answer_id": 342587, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 0, "selected": false, "text": "<p>If the image is small enough, then you might be able to do something with a <a href=\"http://en.wikipedia.org/wiki/D...
2008/12/05
[ "https://Stackoverflow.com/questions/342554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19377/" ]
Is it possible to create an HTML email signature for **Outlook 2003** or above that doesn't reference external images? That is, using those special "cid" reference but embed the image itself in the signature and not on the file system or network. This is for an web application that generates a "standard" email signat...
If you reference the image using a `file:///` URI Outlook will automatically change it into a `cid:` URI and add the image as an attachment on insertion. BTW: What has this got to do with programming? **EDIT**: OK, considering your update to the question: I'm afraid this isn't possible. It's not a limitation specific...
342,556
<p>I am experimenting with the new multiprocessing module in Python 2.6. I am creating several processes each with its own multiprocessor.JoinableQueue instance. Each process spawns one or more worker threads (subclasses of threading.Thread) which share the JoinableQueue instance (passed in through each Thread's <cod...
[ { "answer_id": 342586, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 2, "selected": false, "text": "<p>You should pass Queue objects as target's arguments.</p>\n\n<p>Example from <a href=\"http://docs.python.org/library/multipro...
2008/12/05
[ "https://Stackoverflow.com/questions/342556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43233/" ]
I am experimenting with the new multiprocessing module in Python 2.6. I am creating several processes each with its own multiprocessor.JoinableQueue instance. Each process spawns one or more worker threads (subclasses of threading.Thread) which share the JoinableQueue instance (passed in through each Thread's `__init__...
You should pass Queue objects as target's arguments. Example from [multiprocessing's documentation](http://docs.python.org/library/multiprocessing.html): ``` from multiprocessing import Process, Queue def f(q): q.put([42, None, 'hello']) if __name__ == '__main__': q = Queue() p = Process(target=f, ar...
342,577
<p>If I have an NSString with a text file in it, how do I get an NSArray of NSString with each NSString containing a line of the file.</p> <p>In 10.5 I did this:</p> <pre><code>NSArray* lines = [str componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]; </code></pre> <p>But that doesn't work in...
[ { "answer_id": 342594, "author": "John Safranek", "author_id": 30524, "author_profile": "https://Stackoverflow.com/users/30524", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_C...
2008/12/05
[ "https://Stackoverflow.com/questions/342577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39138/" ]
If I have an NSString with a text file in it, how do I get an NSArray of NSString with each NSString containing a line of the file. In 10.5 I did this: ``` NSArray* lines = [str componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]; ``` But that doesn't work in 10.4, and my program needs to wo...
The following code is straight from [Apple's documentation regarding paragraphs and line breaks](http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/stringsParagraphBreaks.html): ``` unsigned length = [string length]; unsigned paraStart = 0, paraEnd = 0, contentsEnd = 0; NSMutableArray *array = ...
342,578
<p>How can the OpenFileDialog View Menu be set to Detail View?</p>
[ { "answer_id": 342611, "author": "DaEagle", "author_id": 43024, "author_profile": "https://Stackoverflow.com/users/43024", "pm_score": 0, "selected": false, "text": "<p>Quick google search reveals this:</p>\n\n<p><a href=\"http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3843682&a...
2008/12/05
[ "https://Stackoverflow.com/questions/342578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4964/" ]
How can the OpenFileDialog View Menu be set to Detail View?
someone did it [here](http://www.codeproject.com/KB/dialog/OpenFileDialogEx.aspx), with the win32 api ``` DefaultViewMode: This property lets you choose which view the OpenFileDialog should start in; by default, it opens using the “Details view”. Here you can specify a different default view like Icons, List, Thumb...
342,590
<p>Has anyone implemented sorting a list of domain names?</p> <p>I have seen some applications sort them as flat strings, but the problem is that you end up scattering all the related hosts in a domain:</p> <p>a.me.com a.you.com b.me.com b.you.com</p> <p>So, the basic logic I came up with reverse the order of the la...
[ { "answer_id": 342637, "author": "Bala", "author_id": 42551, "author_profile": "https://Stackoverflow.com/users/42551", "pm_score": 0, "selected": false, "text": "<p>You could split the domain names into individual fields and do successive sorts. You can create a domain name object to ha...
2008/12/05
[ "https://Stackoverflow.com/questions/342590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2910/" ]
Has anyone implemented sorting a list of domain names? I have seen some applications sort them as flat strings, but the problem is that you end up scattering all the related hosts in a domain: a.me.com a.you.com b.me.com b.you.com So, the basic logic I came up with reverse the order of the labels, then sort. FQDNs ...
I don't know about Java and Javascript in particular, but many languages provide some sort of array data structure that can be lexicographically sorted. So, like you said, convert "a.example.com" into {"com", "example", "a"}, and just let the default sorting rules run. A lexicographical sort will then do exactly what y...
342,596
<p>I have a very simple problem and a solution that will work, but I'm looking for a simpler one.</p> <p>I'd like to prevent rows from being added to a database when multiple values equal existing values. For example, if a2=a1 AND b2=b1 then the data gets rejected. If only a2=a1 or only b2=b1 it is allowed. Basical...
[ { "answer_id": 342607, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 4, "selected": true, "text": "<p>Create a unique index for the columns that you want to be unique.</p>\n\n<p>Eg:</p>\n\n<pre><code>CREATE UNIQUE INDEX ind...
2008/12/05
[ "https://Stackoverflow.com/questions/342596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30098/" ]
I have a very simple problem and a solution that will work, but I'm looking for a simpler one. I'd like to prevent rows from being added to a database when multiple values equal existing values. For example, if a2=a1 AND b2=b1 then the data gets rejected. If only a2=a1 or only b2=b1 it is allowed. Basically I want it ...
Create a unique index for the columns that you want to be unique. Eg: ``` CREATE UNIQUE INDEX index_name ON table(col1, col2); ``` See the MySQL [Create index manual](http://dev.mysql.com/doc/refman/5.0/en/create-index.html).
342,609
<p>I'm writing what will be an intranet application, and one of its features is roughly analogous to content voting - not unlike what SO, Amazon, and many other sites do.</p> <p>Assuming each votable piece of content has a unique ID, and each user (they're authenticated) has a unique ID, the easiest way would seem to ...
[ { "answer_id": 342621, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 4, "selected": true, "text": "<p>Personally as long as you have good indexes in place, you are going about it the right way. Depending on your u...
2008/12/05
[ "https://Stackoverflow.com/questions/342609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40405/" ]
I'm writing what will be an intranet application, and one of its features is roughly analogous to content voting - not unlike what SO, Amazon, and many other sites do. Assuming each votable piece of content has a unique ID, and each user (they're authenticated) has a unique ID, the easiest way would seem to be to have...
Personally as long as you have good indexes in place, you are going about it the right way. Depending on your usage, for performance you might try to avoid hitting the votes table by storing secondary count information, but overall if you must track WHO has voted something, you need to do it in the way you have listed....
342,613
<p>How do you manage your database connections in your ASP.Net application?</p> <p>My understanding tells me the "best" way is to open a connection, make a query, close the connection - and do that multiple times because connection pooling makes the cost negligable.</p> <p>The problem comes when I have a DAL where ea...
[ { "answer_id": 342636, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 2, "selected": true, "text": "<p>I was reading somewhere and I don't remember where that Microsoft was going to address that when you have two connecti...
2008/12/05
[ "https://Stackoverflow.com/questions/342613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42975/" ]
How do you manage your database connections in your ASP.Net application? My understanding tells me the "best" way is to open a connection, make a query, close the connection - and do that multiple times because connection pooling makes the cost negligable. The problem comes when I have a DAL where each method looks a...
I was reading somewhere and I don't remember where that Microsoft was going to address that when you have two connections to the same DB that they would not escalate to DTC which would make this problem go away. Until then what we did was to develop our TransactionScope, our DALs would then ask the TS for a new conne...
342,619
<p>I've been using the Rome API to parse data from an XML feed pretty successfully so for, but have run in to a bit of a snag. </p> <p>Given the following snippet of XML:</p> <p>&lt;entry&gt;<br> &lt;id&gt;uniqueId&lt;/id&gt;<br> &lt;updated&gt;2008-11-05T01:32:35Z&lt;/updated&gt;<br> &lt;mm:status xmlns:mm=...
[ { "answer_id": 345375, "author": "digitalsanctum", "author_id": 22436, "author_profile": "https://Stackoverflow.com/users/22436", "pm_score": 0, "selected": false, "text": "<p>If you're not already using it, <a href=\"http://wiki.java.net/bin/view/Javawsxml/RomeChangesLog##RomeV10RC1\" r...
2008/12/05
[ "https://Stackoverflow.com/questions/342619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been using the Rome API to parse data from an XML feed pretty successfully so for, but have run in to a bit of a snag. Given the following snippet of XML: <entry> <id>uniqueId</id> <updated>2008-11-05T01:32:35Z</updated> <mm:status xmlns:mm="<http://contentprovider.com&quot>; available="true"/> <tit...
Here is the raw classes from our code without much explanation (but it is late here!). This parses elements: ``` import com.sun.syndication.io.ModuleGenerator; import com.sun.syndication.io.impl.DateParser; import com.sun.syndication.feed.module.Module; import java.util.Collections; import java.util.Set; import java...
342,632
<p>Any idea why the following code doesn't print the amount of characters in the input? I've taken this straight from the K&amp;R book. Learning C at the moment and this is really confusing, looks to me like I'm never reaching EOF. If that's the case then why would this be used as an example?</p> <pre><code>#include &...
[ { "answer_id": 342639, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 1, "selected": false, "text": "<p>This code reads characters from the standard input. When you run this program normally, standard input comes from the ...
2008/12/05
[ "https://Stackoverflow.com/questions/342632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Any idea why the following code doesn't print the amount of characters in the input? I've taken this straight from the K&R book. Learning C at the moment and this is really confusing, looks to me like I'm never reaching EOF. If that's the case then why would this be used as an example? ``` #include <stdio.h> main() {...
The program looks correct, your problem is that you have to send `EOF` (end-of-file) to the command line after your input since the standard input is treated as a file. I think in a linux terminal you can press Ctrl+D to send `EOF`... I'm not sure how to do it in other OS's. To test this program you might want to chang...
342,638
<p>I'm coming from a .net background and want to know the accepted way of creating a method that returns a boolean and modifies a string that was passed in via parameter. I understand Strings are immutable in Java so the below snippet will always produce an empty string. I am constrained to return boolean only. Excepti...
[ { "answer_id": 342648, "author": "Michael Borgwardt", "author_id": 16883, "author_profile": "https://Stackoverflow.com/users/16883", "pm_score": 4, "selected": true, "text": "<p>Use a java.lang.StringBuilder - basically a mutable String. However, it would be safer and more \"Java style\"...
2008/12/05
[ "https://Stackoverflow.com/questions/342638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4458/" ]
I'm coming from a .net background and want to know the accepted way of creating a method that returns a boolean and modifies a string that was passed in via parameter. I understand Strings are immutable in Java so the below snippet will always produce an empty string. I am constrained to return boolean only. Exceptions...
Use a java.lang.StringBuilder - basically a mutable String. However, it would be safer and more "Java style" to return the modified String.
342,655
<p>I have a strange encounter when creating a GridView using <code>SELECT..WHERE..&lt;field&gt; IN (value1, val2...)</code>.</p> <p>In the "Configure datasource" tab, if i hard code the values <code>SELECT .... WHERE field1 in ('AAA', 'BBB', 'CCC')</code>, the system works well.</p> <p>However, if I define a new para...
[ { "answer_id": 342663, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 1, "selected": false, "text": "<p>Take a look at the answer to this question (which is very similar to yours)</p>\n\n<p><a href=\"https://stackov...
2008/12/05
[ "https://Stackoverflow.com/questions/342655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a strange encounter when creating a GridView using `SELECT..WHERE..<field> IN (value1, val2...)`. In the "Configure datasource" tab, if i hard code the values `SELECT .... WHERE field1 in ('AAA', 'BBB', 'CCC')`, the system works well. However, if I define a new parameter and pass in a concatenated string of va...
This works. Not sure how efficient it is though. ``` CREATE PROCEDURE [dbo].[get_bars_in_foo] @bars varchar(255) AS BEGIN DECLARE @query AS varchar(MAX) SET @query = 'SELECT * FROM [foo] WHERE bar IN (' + @bars + ')' exec(@query) END -- exec [get_bars_in_foo] '1,2,3,4' ```
342,665
<p>We are using verisign's time stamp service currently, but every so often the time stamp server becomes unavailable - mostly due to our ISP failing.</p> <p>We now timestamp everything we build, even simple dev builds as we had a lot of trouble with Vista not running the unsigned/unstamped files properly.</p> <p>Can...
[ { "answer_id": 342663, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 1, "selected": false, "text": "<p>Take a look at the answer to this question (which is very similar to yours)</p>\n\n<p><a href=\"https://stackov...
2008/12/05
[ "https://Stackoverflow.com/questions/342665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37558/" ]
We are using verisign's time stamp service currently, but every so often the time stamp server becomes unavailable - mostly due to our ISP failing. We now timestamp everything we build, even simple dev builds as we had a lot of trouble with Vista not running the unsigned/unstamped files properly. Can we setup a time ...
This works. Not sure how efficient it is though. ``` CREATE PROCEDURE [dbo].[get_bars_in_foo] @bars varchar(255) AS BEGIN DECLARE @query AS varchar(MAX) SET @query = 'SELECT * FROM [foo] WHERE bar IN (' + @bars + ')' exec(@query) END -- exec [get_bars_in_foo] '1,2,3,4' ```
342,675
<p>I've got a number of WebService methods that all include some very boilerplate code of wrapping the actual work in a try/catch/finally and performing the same tasks in the catch/finally. So as a way to encapsulate all of the shared catch/finally stuff I wrote a simple generic.</p> <p>This works and really eliminate...
[ { "answer_id": 342685, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>I would agree that this feels a bit clunky to accomplish, however, I am not right away seeing the \"pefect\" wa...
2008/12/05
[ "https://Stackoverflow.com/questions/342675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43406/" ]
I've got a number of WebService methods that all include some very boilerplate code of wrapping the actual work in a try/catch/finally and performing the same tasks in the catch/finally. So as a way to encapsulate all of the shared catch/finally stuff I wrote a simple generic. This works and really eliminates a bunch ...
I would change ``` public static T2 ExceptionHandler<T1, T2>(RestfulServiceRequest<T1, T2> serviceCall, T1 req) ``` to ``` public static T2 Invoke<T1, T2>( this T1 req, RestfulServiceRequest<T1, T2> serviceCall) ``` This will change the call to ``` public class Initialization :IInitialization { public Appli...
342,687
<h2>Context</h2> <ul> <li>Take a look at Wordle: <a href="http://www.wordle.net/" rel="noreferrer">http://www.wordle.net/</a></li> <li>It's much better looking than any other word cloud generators I've seen</li> <li>Note: the source is not available - read the FAQ: <a href="http://www.wordle.net/faq#code" rel="norefer...
[ { "answer_id": 390383, "author": "Wavel", "author_id": 13413, "author_profile": "https://Stackoverflow.com/users/13413", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://code.google.com/apis/visualization/documentation/gallery.html\" rel=\"noreferrer\">http://code.google.co...
2008/12/05
[ "https://Stackoverflow.com/questions/342687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13477/" ]
Context ------- * Take a look at Wordle: <http://www.wordle.net/> * It's much better looking than any other word cloud generators I've seen * Note: the source is not available - read the FAQ: <http://www.wordle.net/faq#code> My Questions ------------ * Is there an algorithm available that does what Wordle does? * If...
I'm the creator of Wordle. Here's how Wordle actually works: Count the words, throw away boring words, and sort by the count, descending. Keep the top N words for some N. Assign each word a font size proportional to its count. Generate a Java2D Shape for each word, using the Java2D API. Each word "wants" to be somewh...
342,777
<p>I'm working on a Zend Framework (1.7) project with a structure loosely based on the structure of the quickstart application - front controller, action controllers, views &amp; models that use Zend_Db_Table to get to the database. One of my main models relies on some expensive joins to pull up its primary listing, s...
[ { "answer_id": 342912, "author": "rg88", "author_id": 11252, "author_profile": "https://Stackoverflow.com/users/11252", "pm_score": 0, "selected": false, "text": "<p>Well, I can't give you an answer to your concerns with using DbSelect but I did come across this bit of code (in the comme...
2008/12/05
[ "https://Stackoverflow.com/questions/342777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39413/" ]
I'm working on a Zend Framework (1.7) project with a structure loosely based on the structure of the quickstart application - front controller, action controllers, views & models that use Zend\_Db\_Table to get to the database. One of my main models relies on some expensive joins to pull up its primary listing, so I'm ...
You can provide an interface on your models that accepts `$current_page` and `$per_page` parameters and returns the current page's data set as well as a paginator object. This way all your pagination code is contained within the model and you are free to use the Db adapters without feeling like you've broken the conce...
342,829
<p>OK I'm redoing this since I messed it up. :) here's the xaml.</p> <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ucWaitIndicator.Window1" x:Name="Window" Title="Window1" Width="640" Heigh...
[ { "answer_id": 342879, "author": "Scott Weinstein", "author_id": 25201, "author_profile": "https://Stackoverflow.com/users/25201", "pm_score": 1, "selected": false, "text": "<p>You don't yet have anything to start or stop. You need a storyboard.\nStart with this <a href=\"http://msdn.mic...
2008/12/05
[ "https://Stackoverflow.com/questions/342829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22451/" ]
OK I'm redoing this since I messed it up. :) here's the xaml. ``` <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ucWaitIndicator.Window1" x:Name="Window" Title="Window1" Width="640" Height="480"> <Win...
Do you want to do this in XAML or in the c# code behind? Both methods can give you some great flexibility with your animations. Here is the XAML storyboard solution, let me know if you want a pure c# version. ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windo...
342,839
<p>As I stated in <a href="https://stackoverflow.com/questions/341192/segmentation-fault-using-sdl-with-c-trying-to-blit-images">this question</a>, I am using SDL for a small game I'm developing. Now I am having problems with SDL_DisplayFormatAlpha. I am trying to create a surface with an alpha channel from a PNG ima...
[ { "answer_id": 342869, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 2, "selected": true, "text": "<p>IMG_Load should handle transparent PNG's automatically, as the end of your post notes. What is the actual exception/e...
2008/12/05
[ "https://Stackoverflow.com/questions/342839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
As I stated in [this question](https://stackoverflow.com/questions/341192/segmentation-fault-using-sdl-with-c-trying-to-blit-images), I am using SDL for a small game I'm developing. Now I am having problems with SDL\_DisplayFormatAlpha. I am trying to create a surface with an alpha channel from a PNG image. It was work...
IMG\_Load should handle transparent PNG's automatically, as the end of your post notes. What is the actual exception/error being thrown? Your stack trace doesn't show that.
342,843
<p>I want to calculate what is $x percentage of a $total. $x could be 15%, 20%, etc, and $total could be 1000, 2000, etc. So I'd want the 15% of 1000, for example.</p> <p>What is the formula for calculating this? (I know this isn't <em>exactly</em> a coding question but I'm coding this feature and need help!</p>
[ { "answer_id": 342848, "author": "Airsource Ltd", "author_id": 18017, "author_profile": "https://Stackoverflow.com/users/18017", "pm_score": 2, "selected": false, "text": "<p>Given X and Y, X% of Y is X * Y/100. If using integer arithmetic, make sure you do (X * Y)/100, not (X / 100) * Y...
2008/12/05
[ "https://Stackoverflow.com/questions/342843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to calculate what is $x percentage of a $total. $x could be 15%, 20%, etc, and $total could be 1000, 2000, etc. So I'd want the 15% of 1000, for example. What is the formula for calculating this? (I know this isn't *exactly* a coding question but I'm coding this feature and need help!
``` (actual / available) * 100 = percent // start actual / available = percent / 100 actual = (percent / 100) * available // finish ``` E.g. 15% of 1000 ``` actual = (15 / 100) * 1000 actual = 0.15 * 1000 actual = 150 ```
342,844
<p>I'm designing an html email for a Holiday Art Market. The request is simply for graphic design, make it pretty-put the date/time etc., but I'm wondering if I can also implement an RSVP form in the email: Are you coming, yes or no? Can this be done in an email, or do I need to redirect to a website? If it can be done...
[ { "answer_id": 342858, "author": "Jim OHalloran", "author_id": 38458, "author_profile": "https://Stackoverflow.com/users/38458", "pm_score": 1, "selected": false, "text": "<p>Last time I tried it (back in about 2001) it worked fine. Just make sure the action= attribute of the form tag c...
2008/12/05
[ "https://Stackoverflow.com/questions/342844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39781/" ]
I'm designing an html email for a Holiday Art Market. The request is simply for graphic design, make it pretty-put the date/time etc., but I'm wondering if I can also implement an RSVP form in the email: Are you coming, yes or no? Can this be done in an email, or do I need to redirect to a website? If it can be done, h...
simplest solution - if all you need is a yes or no answer - is to embed two links, one for yes and one for no, with identifying information already in the querystring parameters of the links, e.g. ``` http://www.yourdomain.com/rsvp.aspx?by=email@receiver.com&response=no http://www.yourdomain.com/rsvp.aspx?by=email@re...
342,862
<p>I've been trying to refactor a "bit" of code that I'd previously developed. Basically, the project was my response to not knowing how to use XSLT effectively, so I developed an XML transformation system in PHP. The program reads through the tags of an XML file and does something along these lines to convert it to HT...
[ { "answer_id": 342877, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>caveat: i don't know PHP, but I can <a href=\"http://us3.php.net/manual/en/functions.variable-functions.php\" rel=...
2008/12/05
[ "https://Stackoverflow.com/questions/342862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I've been trying to refactor a "bit" of code that I'd previously developed. Basically, the project was my response to not knowing how to use XSLT effectively, so I developed an XML transformation system in PHP. The program reads through the tags of an XML file and does something along these lines to convert it to HTML:...
caveat: i don't know PHP, but I can [google](http://us3.php.net/manual/en/functions.variable-functions.php) and i like function pointers better than huge switch statements, so if you can't just use XSLT... ...one option would be to adopt a naming convention for your 'worker' functions that incorporated the html node's...
342,933
<p>I'd like to put in an UIButton in the center of the navigation bar. Based on the document, it appears I need to set title view, and make sure the leftBarButtonItem is nil. But it is not work for me. Here is the code.</p> <pre><code>UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setTitle:@"L...
[ { "answer_id": 342952, "author": "August", "author_id": 30966, "author_profile": "https://Stackoverflow.com/users/30966", "pm_score": 3, "selected": false, "text": "<p>The view of the navigationItem is set, by default, to nil.</p>\n\n<p>You need to use</p>\n\n<pre><code>self.navigationIt...
2008/12/05
[ "https://Stackoverflow.com/questions/342933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32096/" ]
I'd like to put in an UIButton in the center of the navigation bar. Based on the document, it appears I need to set title view, and make sure the leftBarButtonItem is nil. But it is not work for me. Here is the code. ``` UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn setTitle:@"List" forState:...
If you examine your button, you'll find that by using the convenience method to initialize it you are left with a 0x0 button that is positioned at 0,0 within the bounds of the view it is being added to. Before doing this, you must define the contents of the `frame` property of the button. See the code below: ``` UIBut...
342,946
<p>We have an application that is built upon ADO.NET. We follow some simple best practices that allow us to make use of the connection pool. For example, a block of code that is using a database might look something like this:</p> <blockquote> <pre><code>using( DbConnection dbConnection = GetDatabaseConnection() ) {...
[ { "answer_id": 342951, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 0, "selected": false, "text": "<p>You can try setting \"Max Pool Size\" higher. Also you may want to try explicitly calling \"Close\" on the connectio...
2008/12/05
[ "https://Stackoverflow.com/questions/342946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25228/" ]
We have an application that is built upon ADO.NET. We follow some simple best practices that allow us to make use of the connection pool. For example, a block of code that is using a database might look something like this: > > > ``` > using( DbConnection dbConnection = GetDatabaseConnection() ) { > doWork();...
From the MSDN (<http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx>): *When a SqlConnection object is requested, it is obtained from the pool if a usable connection is available. To be usable, a connection must be unused, **have a matching transaction context or be unassociated with any transaction context**, and h...
342,954
<p>A bit of a neophyte haskell question, but I came across this example in Haskell's <a href="http://www.haskell.org/haskellwiki/99_questions/1_to_10" rel="noreferrer">tutorial examples</a>. For "find the last element of a list" there are some obvious versions, like </p> <pre><code>last' [x] = x last' (_:xs) = last' ...
[ { "answer_id": 343036, "author": "Chris Conway", "author_id": 1412, "author_profile": "https://Stackoverflow.com/users/1412", "pm_score": 6, "selected": true, "text": "<p>The definition of <code>const</code> is</p>\n\n<pre><code>const x = \\_ -&gt; x\n</code></pre>\n\n<p>Hence, <code>(co...
2008/12/05
[ "https://Stackoverflow.com/questions/342954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19479/" ]
A bit of a neophyte haskell question, but I came across this example in Haskell's [tutorial examples](http://www.haskell.org/haskellwiki/99_questions/1_to_10). For "find the last element of a list" there are some obvious versions, like ``` last' [x] = x last' (_:xs) = last' xs ``` But I can't make sense of an alter...
The definition of `const` is ``` const x = \_ -> x ``` Hence, `(const id)` is a function which takes one argument and always returns `id` and ``` const id 1 2 = (\_ -> id) 1 2 = id 2 = 2 ``` The definition of `foldr1` is ``` foldr1 f [x] = x foldr1 f (x:xs) = f x (foldr1 f xs) ``` If ...
342,964
<p>Suppose I have this interface</p> <pre><code>public interface IFoo { ///&lt;summary&gt; /// Foo method ///&lt;/summary&gt; void Foo(); ///&lt;summary&gt; /// Bar method ///&lt;/summary&gt; void Bar(); ///&lt;summary&gt; /// Situation normal ///&lt;/summary&gt; void ...
[ { "answer_id": 342968, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://www.roland-weigelt.de/ghostdoc/\" rel=\"nofollow noreferrer\">GhostDoc</a> does exactly that. For ...
2008/12/05
[ "https://Stackoverflow.com/questions/342964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18731/" ]
Suppose I have this interface ``` public interface IFoo { ///<summary> /// Foo method ///</summary> void Foo(); ///<summary> /// Bar method ///</summary> void Bar(); ///<summary> /// Situation normal ///</summary> void Snafu(); } ``` And this class ``` public class ...
[GhostDoc](http://www.roland-weigelt.de/ghostdoc/) does exactly that. For methods which aren't inherited, it tries to create a description out of the name. `FlingThing()` becomes `"Flings the Thing"`
342,966
<p>How do I group search results returned by Lucene by fields (similar to SQL Server's)?</p>
[ { "answer_id": 342975, "author": "gcrain", "author_id": 18582, "author_profile": "https://Stackoverflow.com/users/18582", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://issues.apache.org/jira/browse/LUCENE-1421\" rel=\"nofollow noreferrer\">https://issues.apache.org/jira...
2008/12/05
[ "https://Stackoverflow.com/questions/342966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43478/" ]
How do I group search results returned by Lucene by fields (similar to SQL Server's)?
Lucene 3.4 now supports faceted search. At indexing you specify something supplementary and at search time you search by query and by groups. for next 3 docs, that you index with these groups ``` doc1: monday, 1pm, 3min doc2: monday, 1pm, 4min doc3: monday, 2pm, 3min ``` you can search only for the first...
342,969
<p>Case in point: </p> <p>I'm a on mac with bash v3.2.17, I'm using git installed via macports with the bash_completion variant.</p> <p>When I type <code>git checkout m&lt;tab&gt;</code>. for example, I get it completed to <code>master</code>.</p> <p>However, I've got an alias to <code>git checkout</code>, <code>gco...
[ { "answer_id": 343013, "author": "Chris Lloyd", "author_id": 42413, "author_profile": "https://Stackoverflow.com/users/42413", "pm_score": 4, "selected": false, "text": "<p>In <code>git-completion.bash</code> there is a line:</p>\n\n<pre><code>complete -o default -o nospace -F _git git\n...
2008/12/05
[ "https://Stackoverflow.com/questions/342969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
Case in point: I'm a on mac with bash v3.2.17, I'm using git installed via macports with the bash\_completion variant. When I type `git checkout m<tab>`. for example, I get it completed to `master`. However, I've got an alias to `git checkout`, `gco`. When I type `gco m<tab>`, I don't get the branch name autocomple...
As stated in the comments above, ``` complete -o default -o nospace -F _git_checkout gco ``` will no longer work. However, there's a `__git_complete` function in git-completion.bash which can be used to set up completion for aliases like so: ``` __git_complete gco _git_checkout ```
342,973
<p>We use Perl for GUI test automation. It has been very successful. We have written a very lightweight DSL kind of language for GUI testing. The DSL is very similar to a object model.</p> <p>For example, we have an Application object at the root. Each property sheet in the application is a View object. Each page unde...
[ { "answer_id": 343026, "author": "derobert", "author_id": 27727, "author_profile": "https://Stackoverflow.com/users/27727", "pm_score": 2, "selected": false, "text": "<p>Method calls in perl5 use <code>-&gt;</code> not <code>.</code>, so it'll look like <code>App-&gt;View2-&gt;Page2-&gt;...
2008/12/05
[ "https://Stackoverflow.com/questions/342973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43056/" ]
We use Perl for GUI test automation. It has been very successful. We have written a very lightweight DSL kind of language for GUI testing. The DSL is very similar to a object model. For example, we have an Application object at the root. Each property sheet in the application is a View object. Each page under the page...
You can do almost anything in Perl. But you have to do some *strange* stuff to get Perl to perform with syntax that is just not Perl. * To handle exactly what you have there, you would have to a lot of *advanced* tricks, which are by definition not that maintainable. You would have to: + [overload](http://perldoc.p...
342,990
<p>How can I create an instance of the Java console inside of a GUI panel?</p>
[ { "answer_id": 343007, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 6, "selected": false, "text": "<p>Here's a functioning class. You can install an instance of this into the system out and err using:</p>\n<pre><code>...
2008/12/05
[ "https://Stackoverflow.com/questions/342990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I create an instance of the Java console inside of a GUI panel?
Here's a functioning class. You can install an instance of this into the system out and err using: ``` PrintStream con=new PrintStream(new TextAreaOutputStream(...)); System.setOut(con); System.setErr(con); ``` **Updated 2014-02-19**: To use EventQueue.invokeLater() to avoid GUI threading issues which can crop up ve...
343,014
<p>I have a custom error page set up for my application:</p> <pre><code>&lt;customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx" /&gt; </code></pre> <p>In Global.asax, Application_Error(), the following code works to get the exception details:</p> <pre><code> Exception ex = Server.GetLastError(); i...
[ { "answer_id": 343042, "author": "nailitdown", "author_id": 40934, "author_profile": "https://Stackoverflow.com/users/40934", "pm_score": 5, "selected": false, "text": "<p>OK, I found this post:\n<a href=\"http://msdn.microsoft.com/en-us/library/aa479319.aspx\" rel=\"nofollow noreferrer\...
2008/12/05
[ "https://Stackoverflow.com/questions/343014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40934/" ]
I have a custom error page set up for my application: ``` <customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx" /> ``` In Global.asax, Application\_Error(), the following code works to get the exception details: ``` Exception ex = Server.GetLastError(); if (ex != null) { if (ex.GetBas...
Looking more closely at my web.config set up, one of the comments in [this post is very helpful](http://msdn.microsoft.com/en-us/library/vstudio/h0hfz6fc(v=vs.100).aspx) > > in asp.net 3.5 sp1 there is a new parameter redirectMode > > > So we can amend `customErrors` to add this parameter: ``` <customErrors mode...
343,025
<p>I am Need of Formula to Accurately Calculate Bandwith for 1 Gig Nic Card. What i am doing is send Layer 2 Packets @ 1Gbps but my software is showing 6oo Mbps.</p> <p>The whole experiment is Back to Back. No switch No Router.</p> <p>Here is what i did.</p> <pre><code>// LinkSpeed = 1Gb UINT nBandwidth = LinkSpe...
[ { "answer_id": 343132, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 2, "selected": true, "text": "<p>In ethernet, you also have to take into account the <a href=\"http://en.wikipedia.org/wiki/Interframe_gap\" rel=\"nofollow n...
2008/12/05
[ "https://Stackoverflow.com/questions/343025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38038/" ]
I am Need of Formula to Accurately Calculate Bandwith for 1 Gig Nic Card. What i am doing is send Layer 2 Packets @ 1Gbps but my software is showing 6oo Mbps. The whole experiment is Back to Back. No switch No Router. Here is what i did. ``` // LinkSpeed = 1Gb UINT nBandwidth = LinkSpeed/100;//Mbps nBandwidth = ...
In ethernet, you also have to take into account the [interframe gap](http://en.wikipedia.org/wiki/Interframe_gap), which is at minimum, 96 quantum time, that is, the quantum time being the time to send a bit, which is, 1ns in GigaEthernet (1 second / 1,000,000,000). Also, if you get a collision, there will be [backoff...
343,039
<p>I need to retrieve the browser and OS through php coding.</p> <p>I had used <code>$_SERVER['HTTP_USER_AGENT']</code>, but its shows the following </p> <pre><code>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; IEMB3) </code></pre> <p>How can I separate the browser and OS ...
[ { "answer_id": 343055, "author": "daniels", "author_id": 9789, "author_profile": "https://Stackoverflow.com/users/9789", "pm_score": 0, "selected": false, "text": "<p>Grab a copy of <a href=\"http://browsers.garykeith.com/\" rel=\"nofollow noreferrer\">browscap.ini</a> compare $_SERVER['...
2008/12/05
[ "https://Stackoverflow.com/questions/343039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38172/" ]
I need to retrieve the browser and OS through php coding. I had used `$_SERVER['HTTP_USER_AGENT']`, but its shows the following ``` Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; IEMB3) ``` How can I separate the browser and OS from the above received value? Please guide...
You could use the [Google code Browscap class](http://code.google.com/p/phpbrowscap/). It essentially does the same thing as PHP's get\_browser(), but you don't have to worry about keeping your browscap.ini up to date. This worked for me: ``` require('Browscap.php'); $browscap = new Browscap('/path/to/cache'); var_du...
343,078
<p>If have created a custom role within SqlServer which I added to the db__denydatareader and db__denydatawriter roles. I think went through the db and granted exec permission to all neccersary stored procedures. </p> <p>Everything works fine, calling those sps will run fine. The one exception is a stored procedure wh...
[ { "answer_id": 343090, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 0, "selected": false, "text": "<p>Use using the following statement for that . It worked for me.</p>\n\n<p>sp_addlinkedserver [ @server= ] 'server' [ , ...
2008/12/05
[ "https://Stackoverflow.com/questions/343078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6084/" ]
If have created a custom role within SqlServer which I added to the db\_\_denydatareader and db\_\_denydatawriter roles. I think went through the db and granted exec permission to all neccersary stored procedures. Everything works fine, calling those sps will run fine. The one exception is a stored procedure which ex...
You can create a new user just for your stored procedure that uses execute\_sql, grant him the requires rights and then add to the procedure definition WITH EXECUTE AS 'MyUser'. [See MSDN.](http://msdn.microsoft.com/en-us/library/ms188354.aspx)
343,088
<p>I am writing an Objective-C application which communicates with a USB device. The application writes certain data to the device continuously and displays the status of the write operation in a textView, which is an object of NSTextView. I call the <code>-[NSTextView insertText:]</code> method in the loop when I get ...
[ { "answer_id": 343135, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 2, "selected": false, "text": "<p>Mac OS X does not flush changes to views to the screen immediately, to avoid the flicker and tearing that's common in ...
2008/12/05
[ "https://Stackoverflow.com/questions/343088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39270/" ]
I am writing an Objective-C application which communicates with a USB device. The application writes certain data to the device continuously and displays the status of the write operation in a textView, which is an object of NSTextView. I call the `-[NSTextView insertText:]` method in the loop when I get the write oper...
Mac OS X does not flush changes to views to the screen immediately, to avoid the flicker and tearing that's common in such situations. This means you can't just sit in a loop and perform blocking operations while you update a view; if you do this, neither the view nor anything else in your application's human interface...
343,101
<p>Let me start off by saying that I know there is probably a much simpler way to do this. But this is what i have and yes hopefully I can make some improvements and/or simplifications at the end.</p> <p><strong>Goal as of this moment</strong></p> <p>To double space the output stored in the <code>$tmp</code> variable...
[ { "answer_id": 343592, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 1, "selected": false, "text": "<p>The following awk script will double space the output and number the lines:</p>\n\n<pre><code>awk ' { print NF \"...
2008/12/05
[ "https://Stackoverflow.com/questions/343101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40120/" ]
Let me start off by saying that I know there is probably a much simpler way to do this. But this is what i have and yes hopefully I can make some improvements and/or simplifications at the end. **Goal as of this moment** To double space the output stored in the `$tmp` variable below and individually number each line....
The following awk script will double space the output and number the lines: ``` awk ' { print NF " " $0; print ""; }' ``` Your problem is to assign this to a variable: ``` ( echo a; echo b) | awk ' { print NR " " $0; print ""; }' ``` gives: ``` 1 a 2 b ``` but ``` tmp=$(( echo a; echo b) | awk ' { print NR "...
343,115
<p>I'm trying to find a way to make a list of everything between <code>&lt;a&gt;</code> and <code>&lt;/a&gt;</code> tags. So I have a list of links and I want to get the names of the links (not where the links go, but what they're called on the page). Would be really helpful to me.</p> <p>Currently I have this:</p> <...
[ { "answer_id": 343130, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 0, "selected": false, "text": "<p>Regex, the black magic, again :)</p>\n\n<p>I found one <a href=\"https://stackoverflow.com/questions/331426/common-regul...
2008/12/05
[ "https://Stackoverflow.com/questions/343115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43510/" ]
I'm trying to find a way to make a list of everything between `<a>` and `</a>` tags. So I have a list of links and I want to get the names of the links (not where the links go, but what they're called on the page). Would be really helpful to me. Currently I have this: ``` $lines = preg_split("/\r?\n|\r/", $content); ...
The standard disclaimer applies: Parsing HTML with regular expressions is not ideal. Success depends on the well-formedness of the input on a character-by-character level. If you cannot guarantee this, the regex will fail to do the Right Thing at some point. Having said that: ``` <a\b[^>]*>(.*?)</a> // match group ...
343,138
<p>I'm running a project on a Postgres database and need to retrieve the comments on columns within the DB to be used as table headings and such. I have seen that there are a couple of built in functions (<a href="http://www.postgresql.org/docs/9.1/static/catalog-pg-description.html" rel="noreferrer">pg_description</a>...
[ { "answer_id": 343143, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Ok, so i worked it out to degree...</p>\n\n<p>select col_description(table id, column number)...</p>\n\n<p>ie: select col_d...
2008/12/05
[ "https://Stackoverflow.com/questions/343138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm running a project on a Postgres database and need to retrieve the comments on columns within the DB to be used as table headings and such. I have seen that there are a couple of built in functions ([pg\_description](http://www.postgresql.org/docs/9.1/static/catalog-pg-description.html) and [col\_description](http:/...
``` select c.table_schema, c.table_name, c.column_name, pgd.description from pg_catalog.pg_statio_all_tables as st inner join pg_catalog.pg_description pgd on ( pgd.objoid = st.relid ) inner join information_schema.columns c on ( pgd.objsubid = c.ordinal_position and c.table_schema = st.sc...
343,145
<p>I've created two functions to load expanded views of a month in the archive section of my blog when it's link is clicked:</p> <pre><code>// Load open view of a month in the Archive section function loadMonth(date) { // Remove other open month removeMonth(); // Hide opening month's link // Define variabl...
[ { "answer_id": 343155, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<p>You should be fine with:</p>\n\n<pre><code>openMonth.id = \"openMonth\";\n</code></pre>\n\n<p><code>getElementById()</c...
2008/12/05
[ "https://Stackoverflow.com/questions/343145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29297/" ]
I've created two functions to load expanded views of a month in the archive section of my blog when it's link is clicked: ``` // Load open view of a month in the Archive section function loadMonth(date) { // Remove other open month removeMonth(); // Hide opening month's link // Define variable to hold mont...
To answer your main question: `document.getElementById` **does** work with dynamically added elements. In your sample code you are creating the openMonth div and setting its innerHTML. Then in the remove tag you are doing this: ``` var month = openMonth.getElementsByTagName("span")[0].innerHTML; ``` `openMonth.getE...
343,164
<p><code>IntToStr()</code> function returns string which is Unicode now. I want to convert to <code>AnsiString</code>. Can I use <code>AnsiString(IntToStr(I))</code> safely?</p>
[ { "answer_id": 343168, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 3, "selected": false, "text": "<p>Sure. Or you can use <code>IntToAnsiString</code> (written by <a href=\"http://www.bobswart.nl/Weblog/Blog.aspx?RootId=5:298...
2008/12/05
[ "https://Stackoverflow.com/questions/343164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42065/" ]
`IntToStr()` function returns string which is Unicode now. I want to convert to `AnsiString`. Can I use `AnsiString(IntToStr(I))` safely?
Sure. Or you can use `IntToAnsiString` (written by [Dr. Bob](http://www.bobswart.nl/Weblog/Blog.aspx?RootId=5:2984 "Unicode tip #8 - Integer and Float To AnsiString")): ``` function IntToAnsiStr(X: Integer; Width: Integer = 0): AnsiString; begin Str(X: Width, Result); end; ```
343,182
<p>Can anyone help me to convert a C# .NET program to PowerShell cmdlet? I am very new to this area. Please help me to get out of this checkpoint!</p> <p>Regards,</p> <p>Arun</p>
[ { "answer_id": 343199, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 4, "selected": false, "text": "<p>Add a reference to <em>System.Management.Automation</em>, create a class that inherits from <em>Cmdlet</em> an...
2008/12/05
[ "https://Stackoverflow.com/questions/343182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/201406/" ]
Can anyone help me to convert a C# .NET program to PowerShell cmdlet? I am very new to this area. Please help me to get out of this checkpoint! Regards, Arun
Add a reference to *System.Management.Automation*, create a class that inherits from *Cmdlet* and override the *ProcessRecord* method: ``` [Cmdlet(VerbsCommon.Get, "Double")] public class GetDouble : Cmdlet { [Parameter] public int SomeInput { get; set; } protected override void ProcessRecord() { ...
343,200
<p>I need to extract the icon from a windows shortcut (.lnk) file (or find the icon file, if it's just pointed to by the shortcut).</p> <p>I'm not asking about extracting icons from exe's, dll's, etc. The shortcut in question is created when I run a installation program. And the icon displayed by the shortcut is not...
[ { "answer_id": 343208, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<p>This thread provides interesting informations about the <a href=\"http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=14072...
2008/12/05
[ "https://Stackoverflow.com/questions/343200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to extract the icon from a windows shortcut (.lnk) file (or find the icon file, if it's just pointed to by the shortcut). I'm not asking about extracting icons from exe's, dll's, etc. The shortcut in question is created when I run a installation program. And the icon displayed by the shortcut is not contained i...
This thread provides interesting informations about the [data contained in a .lnk file](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1407242&SiteID=1) The [sSHGetFileInfoss](http://www.codeproject.com/KB/shell/systemiconsimagelist.aspx?display=PrintAll) function should be able to extract the icon file. Docum...
343,204
<p>I've been working on getting a 2.5 module ported to 3.0, mostly for my own education, when I've gotten stuck. The class "Builder" has as its init:</p> <pre><code>def __init__(self, **options): self._verifyOptions(options) self._options = options self._initDigest() self._initBuildNames() self._me...
[ { "answer_id": 343228, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I havent tried 3.0 yet. But there is now a bigger distinction between a sequence of bytes and strings. The latter hold unic...
2008/12/05
[ "https://Stackoverflow.com/questions/343204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39851/" ]
I've been working on getting a 2.5 module ported to 3.0, mostly for my own education, when I've gotten stuck. The class "Builder" has as its init: ``` def __init__(self, **options): self._verifyOptions(options) self._options = options self._initDigest() self._initBuildNames() self._methods = [] ``...
I'm guessing that this line: ``` digester.update(self._options.get('code')) ``` should become: ``` digester.update(self._options.get('code').encode("utf-8")) ``` The actual desired encoding could be different in your case, but UTF-8 will work in all cases.
343,219
<p>I am doing something like this:</p> <pre><code>#include &lt;signal.h&gt; class myClass { public: void myFunction () { signal(SIGIO,myHandler); } void myHandler (int signum) { /** * Handling code */ } } </code></pre> <p>I am working on Ubuntu, using gcc. ...
[ { "answer_id": 343253, "author": "Jørn Jensen", "author_id": 34585, "author_profile": "https://Stackoverflow.com/users/34585", "pm_score": 4, "selected": false, "text": "<p>To pass a pointer to a method, it must be a static method and you must specify the class name.</p>\n\n<p>Try this:<...
2008/12/05
[ "https://Stackoverflow.com/questions/343219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366094/" ]
I am doing something like this: ``` #include <signal.h> class myClass { public: void myFunction () { signal(SIGIO,myHandler); } void myHandler (int signum) { /** * Handling code */ } } ``` I am working on Ubuntu, using gcc. But it won't compile. It is co...
The second parameter of signal should be a pointer to a function accepting an int and returning void. What you're passing to signal is a pointer to a *member* function accepting an int and returning void (its type being `void (myClass::*)(int)`). I can see three possibilities to overcome this issue: 1 - Your method `m...
343,271
<p>I have a simple program print barcodes. The label format is in a preloaded form. The value the barcode is passed by a parameter as follow.</p> <pre><code>^XA ^XFR:FORM.ZPL ^FN999^FDH654321+Y0001+OABC+^FS ^PQ2,0,1,N </code></pre> <p>And it print two barcodes</p> <pre><code>H654321+Y0001+OABC+ H654321+Y0001+OABC+ <...
[ { "answer_id": 343319, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": false, "text": "<p>Ripped from a ZPL II manual:</p>\n<blockquote>\n<p>^AF^SN 0001, 1, Y^FS</p>\n<p>Define serialized field, starting value of...
2008/12/05
[ "https://Stackoverflow.com/questions/343271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40214/" ]
I have a simple program print barcodes. The label format is in a preloaded form. The value the barcode is passed by a parameter as follow. ``` ^XA ^XFR:FORM.ZPL ^FN999^FDH654321+Y0001+OABC+^FS ^PQ2,0,1,N ``` And it print two barcodes ``` H654321+Y0001+OABC+ H654321+Y0001+OABC+ ``` What I want is the middle part a...
It was a no go. And end up generate the sequence in the application, not in the printer.
343,275
<p>I'm using ganymede but I can't find the option to change mirror for the update sites. Is there a way to change this? </p>
[ { "answer_id": 343296, "author": "Pablo Herrero", "author_id": 366094, "author_profile": "https://Stackoverflow.com/users/366094", "pm_score": -1, "selected": false, "text": "<p>If i am not mistaken, in \"Help->Software Updates\" you can manage all the eclipse repositories...</p>\n" },...
2008/12/05
[ "https://Stackoverflow.com/questions/343275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300/" ]
I'm using ganymede but I can't find the option to change mirror for the update sites. Is there a way to change this?
The all notion of **mirrors** is [no more a first class citizen](http://tronprog.blogspot.com/2008/07/eclipse-ganymede.html) of eclipse Ganymede update mechanism, but rather a simple property of a repositories (for [metadata or artifact](http://wiki.eclipse.org/Equinox/p2/Concepts)). You may still force a mirror for a...
343,277
<p>I'm working on a canvas app embedded in a page. I have it so you can zoom into the drawing with the mousewheel but unfortunately this scrolls the page as it is part of an article.</p> <p>Is it possible to prevent mousewheel scrolling on the window when I'm mousewheeling on a dom element?!</p>
[ { "answer_id": 343303, "author": "Sergey Ilinsky", "author_id": 23815, "author_profile": "https://Stackoverflow.com/users/23815", "pm_score": 3, "selected": false, "text": "<p>Attach an event handler for mousewheel (Not Gecko) / DOMMouseScroll (Not IE) and prevent its default action (tha...
2008/12/05
[ "https://Stackoverflow.com/questions/343277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm working on a canvas app embedded in a page. I have it so you can zoom into the drawing with the mousewheel but unfortunately this scrolls the page as it is part of an article. Is it possible to prevent mousewheel scrolling on the window when I'm mousewheeling on a dom element?!
Attach an event handler for mousewheel (Not Gecko) / DOMMouseScroll (Not IE) and prevent its default action (that is to scroll content): ``` if (element.addEventListener) element.addEventListener("DOMMouseScroll", function(event) { event.preventDefault(); }, false); else element.attachEvent("mouse...
343,282
<p>In the following, I'd like to alter the CSS such that the <code>right-sibling</code> is <em>truly</em> centered in the <code>container</code> div. (Edit: without using absolute positioning). </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type='text/css'&gt; #container { width: 500px; ...
[ { "answer_id": 343289, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "<p>You can change the <code>float: left;</code> on <code>#left-sibling</code> to <code>position: absolute;</code>.\nThis will...
2008/12/05
[ "https://Stackoverflow.com/questions/343282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
In the following, I'd like to alter the CSS such that the `right-sibling` is *truly* centered in the `container` div. (Edit: without using absolute positioning). ``` <html> <head> <style type='text/css'> #container { width: 500px; } #left-sibling { float: left; } #r...
A trick I just used to get this to work is to have padding on the left of the container and we can encourage the left-sibling to sit inside this space by giving it an equal but negative margin. To complete the picture we also put padding on the right of the container of an equal size to the width of the left-sibling. ...
343,356
<p>I'm developing a web application that is targeted at IE and during testing would like to log in as a number of different users and test their interactions with each other.</p> <p>At present I have to log in and out to switch users; Opening another window just overrides the cookies/session.</p> <p>Is there any way ...
[ { "answer_id": 343360, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": true, "text": "<p>How about running it as a different user?</p>\n\n<p>For instance,</p>\n\n<pre><code>runas /user:domain\\account iexp...
2008/12/05
[ "https://Stackoverflow.com/questions/343356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24525/" ]
I'm developing a web application that is targeted at IE and during testing would like to log in as a number of different users and test their interactions with each other. At present I have to log in and out to switch users; Opening another window just overrides the cookies/session. Is there any way to get IE to run ...
How about running it as a different user? For instance, ``` runas /user:domain\account iexplore.exe ```
343,362
<p>I have a web application (ASP.net 2.0) that has a database (SQL Server) at the background. I'm considering ways how to handle database concurrency if two users insert the same data to the same table at the same time. Are there any way to handle this case? Thanks in advance.</p> <p>Jimmy</p>
[ { "answer_id": 343382, "author": "James Anderson", "author_id": 38207, "author_profile": "https://Stackoverflow.com/users/38207", "pm_score": 1, "selected": false, "text": "<p>All you need is:</p>\n\n<pre>\nBEGIN TRANSACTION;\nINSERT XXXXXX INTO TABLE1 ......\nINSERT YYYYY INTO TABLE2 ....
2008/12/05
[ "https://Stackoverflow.com/questions/343362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a web application (ASP.net 2.0) that has a database (SQL Server) at the background. I'm considering ways how to handle database concurrency if two users insert the same data to the same table at the same time. Are there any way to handle this case? Thanks in advance. Jimmy
To prevent the same data being INSERTed at the same time, use a unique index on the columns that you want to be unique. The first `INSERT` will succeed, handle the error for the losing `INSERT` appropriately. To prevent 2+ users from modifying the same (existing) record at the same time, use optimistic concurrency <ht...
343,366
<p>If I am storing the Subversion user names and passwords for repository access in a text file in the <code>conf</code> folder, what is the maximum length of the passwords I can use? That is to say, how long can the secrets in the following file be?</p> <pre><code>[users] harry = harryssecret sally = sallyssecret </c...
[ { "answer_id": 343441, "author": "alexandrul", "author_id": 19756, "author_profile": "https://Stackoverflow.com/users/19756", "pm_score": 3, "selected": true, "text": "<p>If you are using <code>svnserve</code>, it seems to be no limit defined (at least I couldn't find any mention of it)....
2008/12/05
[ "https://Stackoverflow.com/questions/343366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39722/" ]
If I am storing the Subversion user names and passwords for repository access in a text file in the `conf` folder, what is the maximum length of the passwords I can use? That is to say, how long can the secrets in the following file be? ``` [users] harry = harryssecret sally = sallyssecret ```
If you are using `svnserve`, it seems to be no limit defined (at least I couldn't find any mention of it). From [svn book](http://svnbook.red-bean.com/): > > The svnserve server, by default, knows only how to send a CRAM-MD5 authentication challenge. In essence, the server sends a small amount of data to the client. ...
343,383
<p>I have this code:</p> <pre><code>if (file.exists()) { Document doc = builder.parse(file); NodeList list = doc.getElementsByTagName("property"); System.out.println("XML Elements: "); for (int ii = 0; ii &lt; list.getLength(); ii++) { </code></pre> <p>line 2 gives following exception</p> <pre> E:\workspace\...
[ { "answer_id": 343411, "author": "brabster", "author_id": 2362, "author_profile": "https://Stackoverflow.com/users/2362", "pm_score": 3, "selected": false, "text": "<p>Parhaps the DocumentBuilder is unsuccessfully trying to access a DTD via a network socket for your XML document?</p>\n\n...
2008/12/05
[ "https://Stackoverflow.com/questions/343383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have this code: ``` if (file.exists()) { Document doc = builder.parse(file); NodeList list = doc.getElementsByTagName("property"); System.out.println("XML Elements: "); for (int ii = 0; ii < list.getLength(); ii++) { ``` line 2 gives following exception ``` E:\workspace\test\testDomain\src\com\test\ins\n...
Parhaps the DocumentBuilder is unsuccessfully trying to access a DTD via a network socket for your XML document? If there are DTD references in the XML document, try editing them out to prove the cause. If that fixes your problem, I think you can use an EntityResolver for a more permanent solution, but I've not done ...
343,396
<p>When we run a update query we get prompt saying that 'these many records are going to be updated. do you want to continue' is it possible to capture the value in the prompt message to a variable i.e the number of records going to be updated.</p>
[ { "answer_id": 343752, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 4, "selected": true, "text": "<p>If you run the query from code, you can use the records affected property:</p>\n\n<pre><code>Dim db As Database\nSet db=...
2008/12/05
[ "https://Stackoverflow.com/questions/343396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
When we run a update query we get prompt saying that 'these many records are going to be updated. do you want to continue' is it possible to capture the value in the prompt message to a variable i.e the number of records going to be updated.
If you run the query from code, you can use the records affected property: ``` Dim db As Database Set db=CurrentDB db.Execute "Some SQL here" db.RecordsAffected ``` If you use a transaction, you can rollback.
343,402
<p>I'm currently busy implementing a filter of sorts for which I need to generate an INNER JOIN clausse for every "tag" to filter on.</p> <p>The problem is that after a whole bunch of SQL, I have a table that contains all the information I need to make my selection, but I need it again for every generated INNER JOIN</...
[ { "answer_id": 347300, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 6, "selected": false, "text": "<p>Right, the MySQL <a href=\"http://dev.mysql.com/doc/refman/5.0/en/temporary-table-problems.html\" rel=\"noreferrer\...
2008/12/05
[ "https://Stackoverflow.com/questions/343402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18565/" ]
I'm currently busy implementing a filter of sorts for which I need to generate an INNER JOIN clausse for every "tag" to filter on. The problem is that after a whole bunch of SQL, I have a table that contains all the information I need to make my selection, but I need it again for every generated INNER JOIN This basic...
If switching to MariaDB (a fork of MySQL) is feasible -- this annoyance is fixed there as of version 10.2.1: <https://jira.mariadb.org/browse/MDEV-5535>.
343,422
<p>How can i make the inner table to overlap the parent div with 5 px while resizing?</p> <p>my current solution:</p> <pre><code>&lt;div id="crop"&gt; &lt;table style="width:105%; height:105%;"&gt; //table cells &lt;/table&gt; &lt;/div&gt; </code></pre> <p>problem is that it gets smaller when resizing... ...
[ { "answer_id": 343498, "author": "chriscena", "author_id": 32671, "author_profile": "https://Stackoverflow.com/users/32671", "pm_score": 0, "selected": false, "text": "<p>Have you tried the following:</p>\n\n<pre><code>table {\nposition: relative;\ntop: 5px;\nleft: 5px;\nmargin-top: -5px...
2008/12/05
[ "https://Stackoverflow.com/questions/343422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can i make the inner table to overlap the parent div with 5 px while resizing? my current solution: ``` <div id="crop"> <table style="width:105%; height:105%;"> //table cells </table> </div> ``` problem is that it gets smaller when resizing... how can I make it constantly overlap with 5px;
The folling seems to work nicely in FF3, Chrome and IE7. Though using expressions in CSS styles for IE is not ideal. You should see that when rendered, the blue "outer" div is displayed within the "inner" div. The "inner" div will be red for browsers other than IE where it will be green instead. Also note, in this ex...
343,435
<h3>ANSWER:</h3> <p>If you ever see these lines and are mistified like I was, here's what they mean.</p> <p><code>Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException))</code></p> <p><code>EventDispatchTread.run() line: not available [local variables unavailable]</code></p> <p>It's not that the variables...
[ { "answer_id": 343459, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 1, "selected": false, "text": "<p>Any method call on a null object will raise a null pointer exception.</p>\n\n<p>In your code, <i>rules, name or display</i>...
2008/12/05
[ "https://Stackoverflow.com/questions/343435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
### ANSWER: If you ever see these lines and are mistified like I was, here's what they mean. `Thread[AWT-EventQueue-0] (Suspended (exception NullPointerException))` `EventDispatchTread.run() line: not available [local variables unavailable]` It's not that the variables are unavailable because they are lurking behin...
Welcome to the complexity of writing GUI code. When you run a Swing program, a background thread called the Event Dispatch Thread is created. When the user clicks on a JButton, for example, JButton creates and fires an event using this Event Dispatch Thread. Hence the name: it's the thread that dispatches events! You...
343,457
<p>--Edit with more bgnd information--</p> <p>A (black box) COM object returns me a string. A 2nd COM object expects this same string as byte[] as input and returns a byte[] with the processed data. This will be fed to a browser as downloadable, non-human-readable file that will be loaded in a client side stand-alone ...
[ { "answer_id": 343477, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>I think you are missing the point of BinarySerialization.</p>\n\n<p>For starters, what Type is formulaXml? </p>\n\n<p>Bi...
2008/12/05
[ "https://Stackoverflow.com/questions/343457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
--Edit with more bgnd information-- A (black box) COM object returns me a string. A 2nd COM object expects this same string as byte[] as input and returns a byte[] with the processed data. This will be fed to a browser as downloadable, non-human-readable file that will be loaded in a client side stand-alone applicatio...
Okay, with your updated information: your 2nd COM object expects binary data, but you want to create that binary data from a string. Does it treat it as plain binary data? My guess is that something is going to reverse this process on the client side. If it's eventually going to want to reconstruct the data as a strin...
343,466
<p>Does dot net have an interface like IEnumerable with a count property? I know about interfaces such as IList and ICollection which do offer a Count property but it seems like these interfaces were designed for mutable data structures first and use as a read only interface seems like an afterthought - the presence of...
[ { "answer_id": 343469, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>IList can return IsReadOnly as true, which marks the collection as readonly. Other than that I'm afraid I don't kn...
2008/12/05
[ "https://Stackoverflow.com/questions/343466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39648/" ]
Does dot net have an interface like IEnumerable with a count property? I know about interfaces such as IList and ICollection which do offer a Count property but it seems like these interfaces were designed for mutable data structures first and use as a read only interface seems like an afterthought - the presence of an...
The key difference between the ICollection family and the IEnumerable family is the absence of certainty as to the count of items present (quite often the items will be generated/loaded/hydrated as needed) - in some cases, an Enumerable may not ever finish generating results, which is why the Count is missing. Derivin...
343,468
<p>To do DataBinding of the <code>Document</code> in a WPF <code>RichtextBox</code>, I saw 2 solutions so far, which are to derive from the <code>RichtextBox</code> and add a <code>DependencyProperty</code>, and also the solution with a "proxy".</p> <p>Neither the first or the second are satisfactory. Does somebody kn...
[ { "answer_id": 343888, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 3, "selected": false, "text": "<p>Create a UserControl which has a RichTextBox named RTB. Now add the following dependency property:</p>\n\n<pre><code> p...
2008/12/05
[ "https://Stackoverflow.com/questions/343468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41407/" ]
To do DataBinding of the `Document` in a WPF `RichtextBox`, I saw 2 solutions so far, which are to derive from the `RichtextBox` and add a `DependencyProperty`, and also the solution with a "proxy". Neither the first or the second are satisfactory. Does somebody know another solution, or instead, a commercial RTF cont...
There is a much easier way! You can easily create an attached `DocumentXaml` (or `DocumentRTF`) property which will allow you to bind the `RichTextBox`'s document. It is used like this, where `Autobiography` is a string property in your data model: ``` <TextBox Text="{Binding FirstName}" /> <TextBox Text="{Binding La...
343,476
<p>I'm using the Win32 <code>CreateProcess</code> function to perform a call to an external executable. The executable returns a string.</p> <p>Is there a way I can capture and interrogate the returned string after calling the executable? Failing that, I might have to write out the string to a file in the executable...
[ { "answer_id": 343482, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>How does the executable <em>return a string</em>? The most I know an executable can return is just a number, the e...
2008/12/05
[ "https://Stackoverflow.com/questions/343476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7703/" ]
I'm using the Win32 `CreateProcess` function to perform a call to an external executable. The executable returns a string. Is there a way I can capture and interrogate the returned string after calling the executable? Failing that, I might have to write out the string to a file in the executable and read that in the c...
[Jedi Code Library](http://sourceforge.net/projects/jcl/ "Jedi Code Library") contains function CreateDOSProcessRedirected which runs a process and provides it with input and output file. You can put required input (if any) into the input file and read process output (if any) from the output file (after the process has...
343,479
<p>I am wondering what is the best way to use workspaces in visual studio. We have 150+ webservices that are all part of the same team project $/MyTeamProject without being related at all. The reason for them all being part of the same team project as they are all maintained by the same group of people within our organ...
[ { "answer_id": 343659, "author": "Liam", "author_id": 28594, "author_profile": "https://Stackoverflow.com/users/28594", "pm_score": 0, "selected": false, "text": "<p>If you have one workspace per webservice then you will get 150*#releases workspaces. This will get really hard to manage f...
2008/12/05
[ "https://Stackoverflow.com/questions/343479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32313/" ]
I am wondering what is the best way to use workspaces in visual studio. We have 150+ webservices that are all part of the same team project $/MyTeamProject without being related at all. The reason for them all being part of the same team project as they are all maintained by the same group of people within our organiza...
You said that the webservices was not related at all. I then assume that they are released separately. I can't see any reason to use multiple workspaces in your scenario. I suggest that you remove the mapping from the top level project "MyTeamProject". Then you have flexibility to map the subfolders to whatever local ...
343,491
<p>Here's some code I saw once. Can you see what's wrong with it?</p> <p>[updated]</p> <pre><code>public class ResourceManager1 { private final String mutex = ""; Object resource = null; public Object getResource() { synchronized (mutex) { if (resource == null) ...
[ { "answer_id": 343504, "author": "Marko", "author_id": 31141, "author_profile": "https://Stackoverflow.com/users/31141", "pm_score": 0, "selected": false, "text": "<p>mutex is not final and resource is not private.</p>\n\n<p>Besides, you need a getResource method that returns resource, b...
2008/12/05
[ "https://Stackoverflow.com/questions/343491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17641/" ]
Here's some code I saw once. Can you see what's wrong with it? [updated] ``` public class ResourceManager1 { private final String mutex = ""; Object resource = null; public Object getResource() { synchronized (mutex) { if (resource == null) { re...
Never synchronize on strings, particularly string literals which are interned. You've basically just got a single lock. In general, never synchronize on any reference that might be visible outside your class (including "this") *unless* the purpose of the external visibility is precisely for locking purposes. I usually...