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
132,318
<p>I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8.</p> <p>Can the data be decoded correctly or is it lost in transcoding?</p> <p>What tools could I use?</p> <p>Here is a sample of what I have:</p>...
[ { "answer_id": 132327, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 3, "selected": false, "text": "<p>With vim from command line:</p>\n\n<pre><code>vim -c \"set encoding=utf8\" -c \"set fileencoding=utf8\" -c \"wq\"...
2008/09/25
[ "https://Stackoverflow.com/questions/132318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18333/" ]
I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could I use? Here is a sample of what I have: ``` ç é ``` I can tell...
EDIT: A simple possibility to eliminate before getting into more complicated solutions: have you tried setting the character set to utf8 in the text editor in which you're reading the file? This could just be a case of somebody sending you a utf8 file that you're reading in an editor set to say cp1252. Just taking th...
132,319
<p>I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle. For small sets of objects (~100) the naive approach of simply storing them in a list, and iterating through it, is relativ...
[ { "answer_id": 132325, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://openmap.bbn.com/doc/api/com/bbn/openmap/util/quadtree/QuadTree.html\" rel=\"nofollow noreferrer\...
2008/09/25
[ "https://Stackoverflow.com/questions/132319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22070/" ]
I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle. For small sets of objects (~100) the naive approach of simply storing them in a list, and iterating through it, is relatively...
[Quadtrees](http://en.wikipedia.org/wiki/Quadtree) seem to solve the specific problem I asked. [Kd-Trees](http://en.wikipedia.org/wiki/Kd-tree) are a more general form, for any number of dimensions, rather than just two. [R-Trees](http://en.wikipedia.org/wiki/R-tree) may also be useful if the objects being stored hav...
132,323
<p>When iterating over elements of a vector it is preferred to use iterators instead of an index (see <a href="https://stackoverflow.com/questions/131241/why-use-iterators-instead-of-array-indices">Why use iterators instead of array indices?</a>). </p> <pre><code>std::vector&lt;T&gt; vec; std::vector&lt;T&gt;::iterato...
[ { "answer_id": 132336, "author": "QBziZ", "author_id": 11572, "author_profile": "https://Stackoverflow.com/users/11572", "pm_score": 3, "selected": false, "text": "<p>Using std::distance is a bit more generic since it works for all iterators, not just random access iterators. And it shou...
2008/09/25
[ "https://Stackoverflow.com/questions/132323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19863/" ]
When iterating over elements of a vector it is preferred to use iterators instead of an index (see [Why use iterators instead of array indices?](https://stackoverflow.com/questions/131241/why-use-iterators-instead-of-array-indices)). ``` std::vector<T> vec; std::vector<T>::iterator it; for ( it = vec.begin(); it != v...
If you're planning on using exclusively a vector, you may want to switch back to the indexed loop, since it conveys your intent more clearly than iterator-loop. However, if evolution of your program in the future may lead to a change of container, you should stick to the iterators and use std::distance, which is guaran...
132,326
<p>My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set</p> <pre><code>_moHttpClient.setHttpConnectionFactoryTimeout(30000); </code></pre> <p>it looks almost like my timeout is not being picked up. Is there anywhere else I need to s...
[ { "answer_id": 132335, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 3, "selected": false, "text": "<pre><code> HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams();\n cmparams.setSoTimeout(10000);...
2008/09/25
[ "https://Stackoverflow.com/questions/132326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set ``` _moHttpClient.setHttpConnectionFactoryTimeout(30000); ``` it looks almost like my timeout is not being picked up. Is there anywhere else I need to set a timeout to ensure thi...
``` HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams(); cmparams.setSoTimeout(10000); cmparams.setTcpNoDelay(true); HttpConnectionManager manager = new SimpleHttpConnectionManager(); manager.setParams(cmparams); params = new HttpClientParams(); params.setSoTimeout(5000)...
132,329
<p>Are there any good examples (websites or books) around of how to build a full text search engine in F#? </p>
[ { "answer_id": 132335, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 3, "selected": false, "text": "<pre><code> HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams();\n cmparams.setSoTimeout(10000);...
2008/09/25
[ "https://Stackoverflow.com/questions/132329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264/" ]
Are there any good examples (websites or books) around of how to build a full text search engine in F#?
``` HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams(); cmparams.setSoTimeout(10000); cmparams.setTcpNoDelay(true); HttpConnectionManager manager = new SimpleHttpConnectionManager(); manager.setParams(cmparams); params = new HttpClientParams(); params.setSoTimeout(5000)...
132,353
<p>Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint ?</p> <pre><code>class Class1&lt;I,T&gt; where I : Interface1, Class2 : I </code></pre> <p>I'm trying to do it like this:</p> <pre><code>class Class1&lt;I extends Interface1, T extends I &amp; Cl...
[ { "answer_id": 132334, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 4, "selected": false, "text": "<p>My rule is that <strong>if it's too slow to do what I want, then it's too big</strong>, and your data probably needs to...
2008/09/25
[ "https://Stackoverflow.com/questions/132353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
Is there a way to define a generic constraint in Java which would be analogous to the following C# generic constratint ? ``` class Class1<I,T> where I : Interface1, Class2 : I ``` I'm trying to do it like this: ``` class Class1<I extends Interface1, T extends I & Class2> ``` But the compiler complains about the "...
My rule is that **if it's too slow to do what I want, then it's too big**, and your data probably needs to be moved to some other format... database or such. Traversing XML nodes or using XPath can be a dog.
132,358
<p>In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information.</p> <p>My question is, which is the best way to read this information and "import it" into the string stream? A problem with this ...
[ { "answer_id": 132394, "author": "Luc Touraille", "author_id": 20984, "author_profile": "https://Stackoverflow.com/users/20984", "pm_score": 7, "selected": true, "text": "<p><code>std::ifstream</code> has a method <code>rdbuf()</code>, that returns a pointer to a <code>filebuf</code>. Yo...
2008/09/25
[ "https://Stackoverflow.com/questions/132358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20317/" ]
In order to improve performance reading from a file, I'm trying to read the entire content of a big (several MB) file into memory and then use a istringstream to access the information. My question is, which is the best way to read this information and "import it" into the string stream? A problem with this approach (...
`std::ifstream` has a method `rdbuf()`, that returns a pointer to a `filebuf`. You can then "push" this `filebuf` into your `stringstream`: ``` #include <fstream> #include <sstream> int main() { std::ifstream file( "myFile" ); if ( file ) { std::stringstream buffer; buffer << file.rdbuf(...
132,384
<p>I need to do some command lines through a browser. What I need to do in a command-line would be:</p> <pre><code>$login &lt;login name&gt; &lt;password&gt; $passwd &lt;old password&gt; &lt;new password&gt; &lt;retype new password&gt; </code></pre> <p>So, how can I do this using the <a href="http://www.php.net/manua...
[ { "answer_id": 132401, "author": "Ludvig A. Norin", "author_id": 16909, "author_profile": "https://Stackoverflow.com/users/16909", "pm_score": 0, "selected": false, "text": "<p>DNS based load balancing should take you a long way. <a href=\"http://content.websitegear.com/article/load_bala...
2008/09/25
[ "https://Stackoverflow.com/questions/132384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
I need to do some command lines through a browser. What I need to do in a command-line would be: ``` $login <login name> <password> $passwd <old password> <new password> <retype new password> ``` So, how can I do this using the [`proc_open`](http://www.php.net/manual/en/function.proc-open.php) function? Or should I ...
We use [Cisco Local Directors](http://en.wikipedia.org/wiki/Cisco_LocalDirector), and they seem to handle it fine. I haven't played with pure software solutions for load balancing, but [balance](http://sourceforge.net/projects/balance/) might work fine. I've only used it for purely 1:1 port forwarding. The advantage ...
132,409
<p>I have a web application that uses <a href="https://javaee.github.io/jaxb-v2/" rel="nofollow noreferrer">JAXB 2</a>. When deployed on an <a href="https://www.oracle.com/technetwork/middleware/ias/overview/index.html" rel="nofollow noreferrer">Oracle 10g Application Server</a>, I get errors as soon as I try to marsh...
[ { "answer_id": 132421, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 0, "selected": false, "text": "<p>Use a different JVM than your Oracle instance and make sure that their libraries are not in your classpath.</p>\n" ...
2008/09/25
[ "https://Stackoverflow.com/questions/132409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/998/" ]
I have a web application that uses [JAXB 2](https://javaee.github.io/jaxb-v2/). When deployed on an [Oracle 10g Application Server](https://www.oracle.com/technetwork/middleware/ias/overview/index.html), I get errors as soon as I try to marshal an XML file. It turns out that Oracle includes [JAXB 1](https://github.com/...
I assume you use the former BEA Weblogic Server? You can add a weblogic.xml file to your WEB-INF, looking like this: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd"> <weblog...
132,445
<p>Consider the following code:</p> <pre><code>void Handler(object o, EventArgs e) { // I swear o is a string string s = (string)o; // 1 //-OR- string s = o as string; // 2 // -OR- string s = o.ToString(); // 3 } </code></pre> <p>What is the difference between the three types of casting (okay, the 3...
[ { "answer_id": 132464, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 3, "selected": false, "text": "<p>'as' is based on 'is', which is a keyword that checks at runtime if the object is polimorphycally compatible (basic...
2008/09/25
[ "https://Stackoverflow.com/questions/132445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6621/" ]
Consider the following code: ``` void Handler(object o, EventArgs e) { // I swear o is a string string s = (string)o; // 1 //-OR- string s = o as string; // 2 // -OR- string s = o.ToString(); // 3 } ``` What is the difference between the three types of casting (okay, the 3rd one is not a casting, b...
``` string s = (string)o; // 1 ``` Throws [InvalidCastException](https://msdn.microsoft.com/en-us/library/system.invalidcastexception) if `o` is not a `string`. Otherwise, assigns `o` to `s`, even if `o` is `null`. ``` string s = o as string; // 2 ``` Assigns `null` to `s` if `o` is not a `string` or if `o` is `nu...
132,449
<p>I'm running a strange problem sending emails. I'm getting this exception:</p> <pre><code>ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `...
[ { "answer_id": 133082, "author": "Dave Nolan", "author_id": 9474, "author_profile": "https://Stackoverflow.com/users/9474", "pm_score": 0, "selected": false, "text": "<p>Check that email_class is set correctly: <a href=\"http://seattlerb.rubyforge.org/ar_mailer/classes/ActionMailer/ARMai...
2008/09/25
[ "https://Stackoverflow.com/questions/132449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22083/" ]
I'm running a strange problem sending emails. I'm getting this exception: ``` ArgumentError (wrong number of arguments (1 for 0)): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:642:in `new' /usr/lib/...
The problem is with the model that ar\_mailer is using to store the message. You can see in the backtrace that the exception is coming from ActiveRecord::Base.create when it calls initialize. Normally an ActiveRecord constructor takes an argument, but in this case it looks like your model doesn't. ar\_mailer should be ...
132,478
<p>I need to perform Diffs between Java strings. I would like to be able to rebuild a string using the original string and diff versions. Has anyone done this in Java? What library do you use?</p> <pre><code>String a1; // This can be a long text String a2; // ej. above text with spelling corrections String a3; // ej. ...
[ { "answer_id": 132484, "author": "Paul Whelan", "author_id": 3050, "author_profile": "https://Stackoverflow.com/users/3050", "pm_score": 5, "selected": false, "text": "<p>Apache Commons has String diff</p>\n\n<p>org.apache.commons.lang.StringUtils</p>\n\n<pre><code>StringUtils.difference...
2008/09/25
[ "https://Stackoverflow.com/questions/132478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I need to perform Diffs between Java strings. I would like to be able to rebuild a string using the original string and diff versions. Has anyone done this in Java? What library do you use? ``` String a1; // This can be a long text String a2; // ej. above text with spelling corrections String a3; // ej. above text wit...
This library seems to do the trick: [google-diff-match-patch](https://github.com/google/diff-match-patch). It can create a patch string from differences and allow to reapply the patch. **edit**: Another solution might be to <https://code.google.com/p/java-diff-utils/>
132,488
<p>I want a regex which can match conditional comments in a HTML source page so I can remove only those. I want to preserve the regular comments.</p> <p>I would also like to avoid using the .*? notation if possible. </p> <p>The text is </p> <pre><code>foo &lt;!--[if IE]&gt; &lt;style type="text/css"&gt; ul.menu u...
[ { "answer_id": 132499, "author": "Thomas Wouters", "author_id": 17624, "author_profile": "https://Stackoverflow.com/users/17624", "pm_score": 0, "selected": false, "text": "<p>Don't use a regular expression for this. You will get confused about comments containing opening tags and what n...
2008/09/25
[ "https://Stackoverflow.com/questions/132488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448/" ]
I want a regex which can match conditional comments in a HTML source page so I can remove only those. I want to preserve the regular comments. I would also like to avoid using the .\*? notation if possible. The text is ``` foo <!--[if IE]> <style type="text/css"> ul.menu ul li{ font-size: 10px; font-wei...
``` >>> from BeautifulSoup import BeautifulSoup, Comment >>> html = '<html><!--[if IE]> bloo blee<![endif]--></html>' >>> soup = BeautifulSoup(html) >>> comments = soup.findAll(text=lambda text:isinstance(text, Comment) and text.find('if') != -1) #This is one line, of course >>> [comment.extract() for c...
132,501
<p>How to sort list of values using only one variable?</p> <p>EDIT: according to @Igor's comment, I retitled the question.</p>
[ { "answer_id": 132506, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "<p>You dont, it is already sorted. (as the question is vague, I shall assume variable is a synonym for an object) </p>\n" ...
2008/09/25
[ "https://Stackoverflow.com/questions/132501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4235/" ]
How to sort list of values using only one variable? EDIT: according to @Igor's comment, I retitled the question.
A solution in C: ---------------- ``` #include <stdio.h> int main() { int list[]={4,7,2,4,1,10,3}; int n; // the one int variable startsort: for (n=0; n< sizeof(list)/sizeof(int)-1; ++n) if (list[n] > list[n+1]) { list[n] ^= list[n+1]; list[n+1] ^= list[n]; ...
132,504
<p>In <code>Eclipse PDT</code>, <code>Ctrl-Shift-F</code> reformats code. However, it doesn't modify comments at all. Is there some way to reformat ragged multi-line comments to 80 characters per line (or whatever)?</p> <p>i.e. convert</p> <pre><code>// We took a breezy excursion and // gathered Jonquils from the ...
[ { "answer_id": 132662, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 2, "selected": false, "text": "<p>You probably need to configure the Java formatter to include comments.</p>\n\n<p>Preferences -> Java -> Code Style -> F...
2008/09/25
[ "https://Stackoverflow.com/questions/132504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11543/" ]
In `Eclipse PDT`, `Ctrl-Shift-F` reformats code. However, it doesn't modify comments at all. Is there some way to reformat ragged multi-line comments to 80 characters per line (or whatever)? i.e. convert ``` // We took a breezy excursion and // gathered Jonquils from the river slopes. Sweet Marjoram grew // in lux...
You probably need to configure the Java formatter to include comments. Preferences -> Java -> Code Style -> Formatter -> Edit... -> Comments Make sure that "Enable XXX comment formatting" is enabled.
132,507
<p>I'm creating a UI that allows the user the select a date range, and tick or un-tick the days of the week that apply within the date range.</p> <p>The date range controls are <code>DateTimePickers</code>, and the Days of the Week are <code>CheckBoxes</code></p> <p>Here's a mock-up of the UI:</p> <p><code>From Date...
[ { "answer_id": 132541, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 2, "selected": false, "text": "<p>Looping through wouldn't be your only option - you could perform <a href=\"http://msdn.microsoft.com/en-us/library/8...
2008/09/25
[ "https://Stackoverflow.com/questions/132507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
I'm creating a UI that allows the user the select a date range, and tick or un-tick the days of the week that apply within the date range. The date range controls are `DateTimePickers`, and the Days of the Week are `CheckBoxes` Here's a mock-up of the UI: `From Date: (dtpDateFrom)` `To Date: (dtpDateTo)` `[y] Mo...
Here's how I would approach it: * Find day of week (dow) of first and last date * Move first day forward to same dow as last. Store number of days moved that are to be included * Calculate number of weeks between first and last * Calculate number of included days in a week \* number of weeks + included days moved As ...
132,566
<p>Despite my most convincing cries to the contrary, I was recently forced to implement a horizontal drop-down navigation system, so I opted for the friendliest one I could find - <a href="http://www.htmldog.com/articles/suckerfish/dropdowns/" rel="nofollow noreferrer">Son of Suckerfish</a>.</p> <p>I tested in various...
[ { "answer_id": 132601, "author": "Anthony Main", "author_id": 258, "author_profile": "https://Stackoverflow.com/users/258", "pm_score": 0, "selected": false, "text": "<p>For testing why not download the Vista IE7 VPC image from MS themselves?</p>\n\n<p><a href=\"http://www.microsoft.com/...
2008/09/25
[ "https://Stackoverflow.com/questions/132566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
Despite my most convincing cries to the contrary, I was recently forced to implement a horizontal drop-down navigation system, so I opted for the friendliest one I could find - [Son of Suckerfish](http://www.htmldog.com/articles/suckerfish/dropdowns/). I tested in various browsers on my machine and all appeared to be ...
This is a problem that occurs in IE7 when another part of the page has focus (ie, you clicked somewhere and then mouse-over the menu). It seems to be an issue with the :hover pseudo-class. Adding a hasLayout trigger to the :hover style should fix the problem. ``` #nav li:hover { position: static; } ``` There are...
132,590
<p>I've been writing a little application that will let people upload &amp; download files to me. I've added a web service to this applciation to provide the upload/download functionality that way but I'm not too sure on how well my implementation is going to cope with large files.</p> <p>At the moment the definition...
[ { "answer_id": 132603, "author": "Guvante", "author_id": 16800, "author_profile": "https://Stackoverflow.com/users/16800", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://stackoverflow.com/q/132618/16800\">Stephen Denne</a> has a Metro implementation that satisfies your re...
2008/09/25
[ "https://Stackoverflow.com/questions/132590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1900/" ]
I've been writing a little application that will let people upload & download files to me. I've added a web service to this applciation to provide the upload/download functionality that way but I'm not too sure on how well my implementation is going to cope with large files. At the moment the definitions of the upload...
[Stephen Denne](https://stackoverflow.com/q/132618/16800) has a Metro implementation that satisfies your requirement. My answer is provided below after a short explination as to why that is the case. Most Web Service implementations that are built using HTTP as the message protocol are REST compliant, in that they onl...
132,592
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/114149/const-correctness-in-c-sharp">&ldquo;const correctness&rdquo; in C#</a> </p> </blockquote> <p>I have programmed C++ for many years but am fairly new to C#. While learning C# I found that the use of the <...
[ { "answer_id": 132603, "author": "Guvante", "author_id": 16800, "author_profile": "https://Stackoverflow.com/users/16800", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://stackoverflow.com/q/132618/16800\">Stephen Denne</a> has a Metro implementation that satisfies your re...
2008/09/25
[ "https://Stackoverflow.com/questions/132592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19863/" ]
> > **Possible Duplicate:** > > [“const correctness” in C#](https://stackoverflow.com/questions/114149/const-correctness-in-c-sharp) > > > I have programmed C++ for many years but am fairly new to C#. While learning C# I found that the use of the [const](http://en.csharp-online.net/const,_static_and_readonly) ...
[Stephen Denne](https://stackoverflow.com/q/132618/16800) has a Metro implementation that satisfies your requirement. My answer is provided below after a short explination as to why that is the case. Most Web Service implementations that are built using HTTP as the message protocol are REST compliant, in that they onl...
132,612
<p>I have found that when I execute the show() method for a contextmenustrip (a right click menu), if the position is outside that of the form it belongs to, it shows up on the taskbar also.</p> <p>I am trying to create a right click menu for when clicking on the notifyicon, but as the menu hovers above the system tra...
[ { "answer_id": 132917, "author": "Grokys", "author_id": 6448, "author_profile": "https://Stackoverflow.com/users/6448", "pm_score": 4, "selected": true, "text": "<p>Try assigning your menu to the ContextMenuStrip property of NotifyIcon rather than showing it in the mouse click handler.</...
2008/09/25
[ "https://Stackoverflow.com/questions/132612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15087/" ]
I have found that when I execute the show() method for a contextmenustrip (a right click menu), if the position is outside that of the form it belongs to, it shows up on the taskbar also. I am trying to create a right click menu for when clicking on the notifyicon, but as the menu hovers above the system tray and not ...
Try assigning your menu to the ContextMenuStrip property of NotifyIcon rather than showing it in the mouse click handler.
132,620
<p>Here's the scenario:</p> <p>You have a Windows server that users remotely connect to via RDP. You want your program (which runs as a service) to know who is currently connected. This may or may not include an interactive console session.</p> <p>Please note that this is the <strong>not</strong> the same as just ret...
[ { "answer_id": 132684, "author": "James", "author_id": 7837, "author_profile": "https://Stackoverflow.com/users/7837", "pm_score": 3, "selected": false, "text": "<p>Ok, one solution to my own question.</p>\n\n<p>You can use WMI to retreive a list of running processes. You can also look a...
2008/09/25
[ "https://Stackoverflow.com/questions/132620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7837/" ]
Here's the scenario: You have a Windows server that users remotely connect to via RDP. You want your program (which runs as a service) to know who is currently connected. This may or may not include an interactive console session. Please note that this is the **not** the same as just retrieving the current interactiv...
Here's my take on the issue: ``` using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace EnumerateRDUsers { class Program { [DllImport("wtsapi32.dll")] static extern IntPtr WTSOpenServer([MarshalAs(UnmanagedType.LPStr)] string pServerName); [DllImport("wtsapi32...
132,643
<p>I have a this aspx-code: (sample)</p> <pre><code>&lt;asp:DropDownList runat="server" ID="ddList1"&gt;&lt;/asp:DropDownList&gt; </code></pre> <p>With this codebehind:</p> <pre><code>List&lt;System.Web.UI.WebControls.ListItem&gt; colors = new List&lt;System.Web.UI.WebControls.ListItem&gt;(); colors.Add(new ListI...
[ { "answer_id": 132658, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": "https://Stackoverflow.com/users/31505", "pm_score": 4, "selected": true, "text": "<p>Because DataBind method binds values only if DataValueField property is set. If you set DataValueField property to ...
2008/09/25
[ "https://Stackoverflow.com/questions/132643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2257/" ]
I have a this aspx-code: (sample) ``` <asp:DropDownList runat="server" ID="ddList1"></asp:DropDownList> ``` With this codebehind: ``` List<System.Web.UI.WebControls.ListItem> colors = new List<System.Web.UI.WebControls.ListItem>(); colors.Add(new ListItem("Select Value", "0")); colors.Add(new ListItem("Red", "1"...
Because DataBind method binds values only if DataValueField property is set. If you set DataValueField property to "Value" before calling DataBind, your values will appear on the markup. UPDATE: You will also need to set DataTextField property to "Text". It is because data binding and adding items manually do not work...
132,649
<p>What is the difference between overflow:hidden and display:none?</p>
[ { "answer_id": 132665, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Overflow:hidden just says if text flows outside of this element the scrollbars don't show. display:none says the element...
2008/09/25
[ "https://Stackoverflow.com/questions/132649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21067/" ]
What is the difference between overflow:hidden and display:none?
Example: ``` .oh { height: 50px; width: 200px; overflow: hidden; } ``` If text in the block with this class is bigger (longer) than what this little box can display, the excess will be just hidden. You will see the start of the text only. `display: none;` will just hide the block. Note you have also `visibil...
132,667
<p>While developing a C++ application, I had to use a third-party library which produced a huge amount of warnings related with a harmless #pragma directive being used.</p> <pre class="lang-none prettyprint-override"><code>../File.hpp:1: warning: ignoring #pragma ident In file included from ../File2.hpp:47, ...
[ { "answer_id": 132730, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 8, "selected": true, "text": "<p>I believe you can compile with </p>\n\n<pre><code>-Wno-unknown-pragmas\n</code></pre>\n\n<p>to suppress these.</p>\n" ...
2008/09/25
[ "https://Stackoverflow.com/questions/132667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20317/" ]
While developing a C++ application, I had to use a third-party library which produced a huge amount of warnings related with a harmless #pragma directive being used. ```none ../File.hpp:1: warning: ignoring #pragma ident In file included from ../File2.hpp:47, from ../File3.hpp:57, fro...
I believe you can compile with ``` -Wno-unknown-pragmas ``` to suppress these.
132,725
<p>I'm new to Delphi, and I've been running some tests to see what object variables and stack variables are initialized to by default:</p> <pre><code>TInstanceVariables = class fBoolean: boolean; // always starts off as false fInteger: integer; // always starts off as zero fObject: TObject; // always starts off ...
[ { "answer_id": 132739, "author": "Martin Liesén", "author_id": 20715, "author_profile": "https://Stackoverflow.com/users/20715", "pm_score": 5, "selected": false, "text": "<p>Class fields are default zero. This is documented so you can rely on it.\nLocal stack varaiables are undefined un...
2008/09/25
[ "https://Stackoverflow.com/questions/132725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11961/" ]
I'm new to Delphi, and I've been running some tests to see what object variables and stack variables are initialized to by default: ``` TInstanceVariables = class fBoolean: boolean; // always starts off as false fInteger: integer; // always starts off as zero fObject: TObject; // always starts off as nil end; `...
Yes, this is the documented behaviour: * Object fields are always initialized to 0, 0.0, '', False, nil or whatever applies. * Global variables are always initialized to 0 etc as well; * Local reference-counted\* variables are always initialized to nil or ''; * Local non reference-counted\* variables are uninitialized...
132,738
<p>I'm a C/C++ developer, and here are a couple of questions that always baffled me.</p> <ul> <li>Is there a big difference between "regular" code and inline code?</li> <li>Which is the main difference?</li> <li>Is inline code simply a "form" of macros?</li> <li>What kind of tradeoff must be done when choosing to inli...
[ { "answer_id": 132749, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 4, "selected": false, "text": "<p>Inline code works like macros in essence but it is actual real code, which can be optimized. Very small functions are ofte...
2008/09/25
[ "https://Stackoverflow.com/questions/132738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20317/" ]
I'm a C/C++ developer, and here are a couple of questions that always baffled me. * Is there a big difference between "regular" code and inline code? * Which is the main difference? * Is inline code simply a "form" of macros? * What kind of tradeoff must be done when choosing to inline your code? Thanks
> > * Is there a big difference between "regular" code and inline code? > > > Yes and no. No, because an inline function or method has exactly the same characteristics as a regular one, most important one being that they are both type safe. And yes, because the assembly code generated by the compiler will be diffe...
132,750
<p>I'm a jQuery novice, so the answer to this may be quite simple:</p> <p>I have an image, and I would like to do several things with it. When a user clicks on a 'Zoom' icon, I'm running the 'imagetool' plugin (<a href="http://code.google.com/p/jquery-imagetool/" rel="nofollow noreferrer">http://code.google.com/p/jque...
[ { "answer_id": 132795, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 1, "selected": false, "text": "<p>You could try abstracting the <strong>productZoom.click()</strong> function to a named function, and then re-bind...
2008/09/25
[ "https://Stackoverflow.com/questions/132750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22113/" ]
I'm a jQuery novice, so the answer to this may be quite simple: I have an image, and I would like to do several things with it. When a user clicks on a 'Zoom' icon, I'm running the 'imagetool' plugin (<http://code.google.com/p/jquery-imagetool/>) to load a larger version of the image. The plugin creates a new div arou...
Wehey! I've sorted it out myself... Turns out if I remove the containing div completely, and then rewrite it with .html, the imagetool plugin recognises it again. Amended code for anyone who's interested: ``` $(document).ready(function(){ // Product Zoom (jQuery) $("#productZoom").click(function() { $('#pr...
132,764
<p>In our CMS, we have a place in which we enable users to play around with their site hierarchy - move pages around, add and remove pages, etc.</p> <p>We use drag &amp; drop to implement moving pages around. </p> <p>Each move has to saved in th DB, and exported to many HTML files. If we do that in every move, it wil...
[ { "answer_id": 132775, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 3, "selected": true, "text": "<p>You should warn the user when he leaves the page with javascript.</p>\n\n<p>From <a href=\"http://www.siafoo.net/article/67\"...
2008/09/25
[ "https://Stackoverflow.com/questions/132764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/278/" ]
In our CMS, we have a place in which we enable users to play around with their site hierarchy - move pages around, add and remove pages, etc. We use drag & drop to implement moving pages around. Each move has to saved in th DB, and exported to many HTML files. If we do that in every move, it will slow down the users...
You should warn the user when he leaves the page with javascript. From <http://www.siafoo.net/article/67>: Modern browsers have an event called window.beforeunload that is fired right when any event occurs that would cause the page to unload. This includes clicking on a link, submitting a form, or closing the tab or ...
132,799
<p>How can you you insert a newline from your batch file output?</p> <p>I want to do something like:</p> <pre class="lang-bat prettyprint-override"><code>echo hello\nworld </code></pre> <p>Which would output:</p> <pre class="lang-bat prettyprint-override"><code>hello world </code></pre>
[ { "answer_id": 132804, "author": "Matt Lacey", "author_id": 1755, "author_profile": "https://Stackoverflow.com/users/1755", "pm_score": 9, "selected": false, "text": "<p>Use:</p>\n<pre><code>echo hello\necho:\necho world\n</code></pre>\n" }, { "answer_id": 132811, "author": "...
2008/09/25
[ "https://Stackoverflow.com/questions/132799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
How can you you insert a newline from your batch file output? I want to do something like: ```bat echo hello\nworld ``` Which would output: ```bat hello world ```
`echo hello & echo.world` This means you could define `& echo.` as a constant for a newline `\n`.
132,857
<p>I have the following layout for my test suite:</p> <p>TestSuite1.cmd:</p> <ol> <li>Run my program</li> <li>Check its return result</li> <li>If the return result is not 0, convert the error to textual output and abort the script. If it succeeds, write out success.</li> </ol> <p>In my single .cmd file, I call my p...
[ { "answer_id": 132880, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 0, "selected": false, "text": "<p>try the command <strong>start</strong>, it spawns a new command prompt and you can send along any commands you want it t...
2008/09/25
[ "https://Stackoverflow.com/questions/132857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
I have the following layout for my test suite: TestSuite1.cmd: 1. Run my program 2. Check its return result 3. If the return result is not 0, convert the error to textual output and abort the script. If it succeeds, write out success. In my single .cmd file, I call my program about 10 times with different input. Th...
Assuming they won't interfere with each other by writing to the same files,etc: test1.cmd ``` :: intercept sub-calls. if "%1"=="test2" then goto :test2 :: start sub-calls. start test1.cmd test2 1 start test1.cmd test2 2 start test1.cmd test2 3 :: wait for sub-calls to complete. :loop1 if not exist test2_1...
132,867
<p>The question I'm really asking is why require does not take the name of the gem. Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!?</p> <p>As an example if I have <code>memcache-client</code> installed then I have to require it using</p> <pre><code>...
[ { "answer_id": 132882, "author": "Vhaerun", "author_id": 11234, "author_profile": "https://Stackoverflow.com/users/11234", "pm_score": 2, "selected": false, "text": "<p>You need to include \"rubygems\" only if you installed the gem using <strong>gem</strong> . Otherwise , the secret inca...
2008/09/25
[ "https://Stackoverflow.com/questions/132867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18751/" ]
The question I'm really asking is why require does not take the name of the gem. Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!? As an example if I have `memcache-client` installed then I have to require it using ``` require 'rubygems' require 'memc...
There is no standard for what the file you need to include is. However there are some commonly followed conventions that you can can follow try and make use of: * Often the file is called the same name as the gem. So `require mygem` will work. * Often the file is the only .rb file in the lib subdirectory of the gem, S...
132,902
<p>I need to move entire tables from one MySQL database to another. I don't have full access to the second one, only phpMyAdmin access. I can only upload (compressed) sql files smaller than 2MB. But the compressed output from a mysqldump of the first database's tables is larger than 10MB.</p> <p>Is there a way to spli...
[ { "answer_id": 132939, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "<p>First dump the schema (it surely fits in 2Mb, no?)</p>\n\n<pre><code>mysqldump -d --all-databases \n</code></pre>\...
2008/09/25
[ "https://Stackoverflow.com/questions/132902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1428/" ]
I need to move entire tables from one MySQL database to another. I don't have full access to the second one, only phpMyAdmin access. I can only upload (compressed) sql files smaller than 2MB. But the compressed output from a mysqldump of the first database's tables is larger than 10MB. Is there a way to split the outp...
First dump the schema (it surely fits in 2Mb, no?) ``` mysqldump -d --all-databases ``` and restore it. Afterwards dump only the data in separate insert statements, so you can split the files and restore them without having to concatenate them on the remote server ``` mysqldump --all-databases --extended-insert=F...
132,955
<p>How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.</p>
[ { "answer_id": 133013, "author": "Bruno De Fraine", "author_id": 6918, "author_profile": "https://Stackoverflow.com/users/6918", "pm_score": 4, "selected": false, "text": "<p>On MacOSX, you have at least the following options:</p>\n\n<ul>\n<li>Recurring iCal alarm with a \"Run Script\" a...
2008/09/25
[ "https://Stackoverflow.com/questions/132955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X.
Just use **launchd**. It is a very powerful launcher system and meanwhile it is the standard launcher system for Mac OS X (current OS X version wouldn't even boot without it). For those who are not familiar with `launchd` (or with OS X in general), it is like a crossbreed between `init`, `cron`, `at`, SysVinit (`init.d...
132,976
<p>I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run.</p> <p>Using:</p> <pre><code>if (!getProject().isExecutionRoot()) { return ; } </code></pre> <p>at the start of the execute() method means my mojo gets executed once, however at the very...
[ { "answer_id": 133016, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": -1, "selected": false, "text": "<p>Normally, this is a matter of configuration. You might have to setup a project just for the mojo and make it dependent o...
2008/09/25
[ "https://Stackoverflow.com/questions/132976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2767300/" ]
I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run. Using: ``` if (!getProject().isExecutionRoot()) { return ; } ``` at the start of the execute() method means my mojo gets executed once, however at the very beginning of the build - before ...
The best solution I have found for this is: ``` /** * The projects in the reactor. * * @parameter expression="${reactorProjects}" * @readonly */ private List reactorProjects; public void execute() throws MojoExecutionException { // only execute this mojo once, on the very last project in the reactor fin...
132,988
<p>My <a href="https://english.stackexchange.com/questions/19967/what-does-google-fu-mean">Google-fu</a> has failed me.</p> <p>In Python, are the following two tests for equality equivalent?</p> <pre><code>n = 5 # Test one. if n == 5: print 'Yay!' # Test two. if n is 5: print 'Yay!' </code></pre> <p>Does th...
[ { "answer_id": 133017, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 6, "selected": false, "text": "<p><code>==</code> determines if the values are equal, while <code>is</code> determines if they are the exact same ob...
2008/09/25
[ "https://Stackoverflow.com/questions/132988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
My [Google-fu](https://english.stackexchange.com/questions/19967/what-does-google-fu-mean) has failed me. In Python, are the following two tests for equality equivalent? ``` n = 5 # Test one. if n == 5: print 'Yay!' # Test two. if n is 5: print 'Yay!' ``` Does this hold true for objects where you would be ...
`is` will return `True` if two variables point to the same object (in memory), `==` if the objects referred to by the variables are equal. ``` >>> a = [1, 2, 3] >>> b = a >>> b is a True >>> b == a True # Make a new copy of list `a` via the slice operator, # and assign it to variable `b` >>> b = a[:] >>> b is a Fa...
133,002
<p>I am using Flex to connect to a Rest service. To access order #32, for instance, I can call the URL <a href="http://[service]/orders/32" rel="nofollow noreferrer">http://[service]/orders/32</a>. The URL <em>must</em> be configured as a destination - since the client will connect to different instances of the service...
[ { "answer_id": 134260, "author": "defmeta", "author_id": 10875, "author_profile": "https://Stackoverflow.com/users/10875", "pm_score": 0, "selected": false, "text": "<p>Here's a simple way to resolve the url to the HTTPService within Flex via the click event's handler.</p>\n\n<p>here's a...
2008/09/25
[ "https://Stackoverflow.com/questions/133002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450527/" ]
I am using Flex to connect to a Rest service. To access order #32, for instance, I can call the URL <http://[service]/orders/32>. The URL *must* be configured as a destination - since the client will connect to different instances of the service. All of this is using the Blaze Proxy, since it involves GET, PUT, DELETE ...
Just so everyone knows, this is how I resolved this issue: I created a custom HTTPProxyAdapter on the server ``` public MyHTTPProxyAdapter extends flex.messaging.services.http.HTTPProxyAdapter { public Object invoke(Message message) { // modify the message - if required process(message); return super.inv...
133,031
<p>I need to add a specific column if it does not exist. I have something like the following, but it always returns false:</p> <pre><code>IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND COLUMN_NAME = 'myColumnName') </code></pre> <p>How ...
[ { "answer_id": 133041, "author": "Leon Tayson", "author_id": 18413, "author_profile": "https://Stackoverflow.com/users/18413", "pm_score": 6, "selected": false, "text": "<p>Try this...</p>\n\n<pre><code>IF NOT EXISTS(\n SELECT TOP 1 1\n FROM INFORMATION_SCHEMA.COLUMNS\n WHERE \n [T...
2008/09/25
[ "https://Stackoverflow.com/questions/133031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631856/" ]
I need to add a specific column if it does not exist. I have something like the following, but it always returns false: ``` IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND COLUMN_NAME = 'myColumnName') ``` How can I check if a column ex...
SQL Server 2005 onwards: ``` IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'columnName' AND Object_ID = Object_ID(N'schemaName.tableName')) BEGIN -- Column Exists END ``` Martin Smith's version is shorter: ``` IF COL_LENGTH('schemaName.tableName', 'columnName') IS NOT NULL BEGIN -- ...
133,051
<p>The CSS rules <code>visibility:hidden</code> and <code>display:none</code> both result in the element not being visible. Are these synonyms?</p>
[ { "answer_id": 133059, "author": "mmaibaum", "author_id": 12213, "author_profile": "https://Stackoverflow.com/users/12213", "pm_score": 7, "selected": false, "text": "<p><code>display:none</code> removes the element from the layout flow.</p>\n\n<p><code>visibility:hidden</code> hides it ...
2008/09/25
[ "https://Stackoverflow.com/questions/133051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14749/" ]
The CSS rules `visibility:hidden` and `display:none` both result in the element not being visible. Are these synonyms?
`display:none` means that the tag in question will not appear on the page at all (although you can still interact with it through the dom). There will be no space allocated for it between the other tags. `visibility:hidden` means that unlike `display:none`, the tag is not visible, but space is allocated for it on the...
133,081
<p>In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what is the most efficient way to get a datetime containing only '2008-09-25'?</p> <p>Duplicated <a href="https://stackoverflow.com/questions/2775/whats-the-best-way-to-remove-the-time-portion-of-a-datetime-value-sql-server">here</a>.</p>
[ { "answer_id": 133101, "author": "George Mastros", "author_id": 1408129, "author_profile": "https://Stackoverflow.com/users/1408129", "pm_score": 5, "selected": false, "text": "<pre><code>Select DateAdd(Day, DateDiff(Day, 0, GetDate()), 0)\n</code></pre>\n\n<p>DateDiff(Day, 0, GetDate())...
2008/09/25
[ "https://Stackoverflow.com/questions/133081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16881/" ]
In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what is the most efficient way to get a datetime containing only '2008-09-25'? Duplicated [here](https://stackoverflow.com/questions/2775/whats-the-best-way-to-remove-the-time-portion-of-a-datetime-value-sql-server).
I must admit I hadn't seen the floor-float conversion shown by Matt before. I had to test this out. I tested a pure select (which will return Date and Time, and is not what we want), the reigning solution here (floor-float), a common 'naive' one mentioned here (stringconvert) and the one mentioned here that I was usi...
133,087
<p>Note: not ASP.NET.</p> <p>I've read about various methods including using SOAPClient (is this part of the standard Windows 2003 install?), ServerXMLHTTP, and building up the XML from scratch and parsing the result manually.</p> <p>Has anyone ever done this? What did you use and would you recommend it?</p>
[ { "answer_id": 133105, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>We use the MS Soap Toolkit version 3 here. Seems to work ok (I only wrote the services).</p>\n" }, { "answer_id...
2008/09/25
[ "https://Stackoverflow.com/questions/133087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
Note: not ASP.NET. I've read about various methods including using SOAPClient (is this part of the standard Windows 2003 install?), ServerXMLHTTP, and building up the XML from scratch and parsing the result manually. Has anyone ever done this? What did you use and would you recommend it?
Well, since the web service talks XML over standard HTTP you could roll your own using the latest XML parser from Microsoft. You should make sure you have the latest versions of MSXML and XML Core Services (see [Microsoft Downloads](http://msdn.microsoft.com/en-us/aa570309.aspx)). ``` <% SoapUrl = "http://www.you...
133,092
<p>I have an XPath expression which provides me a sequence of values like the one below:</p> <p><code>1 2 2 3 4 5 5 6 7</code></p> <p>This is easy to convert to a sequence of unique values <code>1 2 3 4 5 6 7</code> using <code>distinct-values()</code>. However, what I want to extract is the list of duplicate values = ...
[ { "answer_id": 133291, "author": "GerG", "author_id": 17249, "author_profile": "https://Stackoverflow.com/users/17249", "pm_score": 0, "selected": false, "text": "<p>Calculate the difference between your original set and the set of distinct values. This is the set of numbers that occur m...
2008/09/25
[ "https://Stackoverflow.com/questions/133092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an XPath expression which provides me a sequence of values like the one below: `1 2 2 3 4 5 5 6 7` This is easy to convert to a sequence of unique values `1 2 3 4 5 6 7` using `distinct-values()`. However, what I want to extract is the list of duplicate values = `2 5`. I can't think of an easy way to do this. ...
**Use this simple XPath 2.0 expression**: ``` $vSeq[index-of($vSeq,.)[2]] ``` where `$vSeq` is the sequence of values in which we want to find the duplicates. **For explanation of how this "works", see**: **<http://dnovatchev.wordpress.com/2008/11/16/xpath-2-0-gems-find-all-duplicate-values-in-a-sequence-part-2/>*...
133,111
<p>I need to increment a number in a source file from an Ant build script. I can use the <code><a href="http://ant.apache.org/manual/Tasks/replaceregexp.html" rel="nofollow noreferrer">ReplaceRegExp</a></code> task to find the number I want to increment, but how do I then increment that number within the <code>replace<...
[ { "answer_id": 133159, "author": "Yuval F", "author_id": 1702, "author_profile": "https://Stackoverflow.com/users/1702", "pm_score": 3, "selected": true, "text": "<p>You can use something like:</p>\n\n<p><code>&lt;propertyfile file=\"${version-file}\"&gt;\n &lt;entry key=\"revision\" typ...
2008/09/25
[ "https://Stackoverflow.com/questions/133111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270/" ]
I need to increment a number in a source file from an Ant build script. I can use the `[ReplaceRegExp](http://ant.apache.org/manual/Tasks/replaceregexp.html)` task to find the number I want to increment, but how do I then increment that number within the `replace` attribute? Heres what I've got so far: ``` <replacere...
You can use something like: `<propertyfile file="${version-file}"> <entry key="revision" type="string" operation="=" value="${revision}" /> <entry key="build" type="int" operation="+" value="1" />` so the ant task is propertyfile.
133,154
<p>While normally it's good to always choose the right language for the job, it can sometimes be instructive to try and do something in a language which is wildly inappropriate.</p> <ol> <li>It can help you understand the problem better. Maybe you don't <em>have</em> to solve it the way you thought you did.</li> <li>...
[ { "answer_id": 133155, "author": "Cody Hatch", "author_id": 17086, "author_profile": "https://Stackoverflow.com/users/17086", "pm_score": 6, "selected": true, "text": "<p>Turns out, it's not as hard as you might think. The syntax is ugly as hell, but the batch syntax is actually capabl...
2008/09/25
[ "https://Stackoverflow.com/questions/133154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17086/" ]
While normally it's good to always choose the right language for the job, it can sometimes be instructive to try and do something in a language which is wildly inappropriate. 1. It can help you understand the problem better. Maybe you don't *have* to solve it the way you thought you did. 2. It can help you understand ...
Turns out, it's not as hard as you might think. The syntax is ugly as hell, but the batch syntax is actually capable of some surprising things, including recursion, local variables, and some surprisingly sophisticated parsing of strings. Don't get me wrong, it's a terrible language, but to my surprise, it isn't complet...
133,194
<p>I am trying to make an Outlook 2003 add-in using Visual Studio 2008 on Windows XP SP3 and Internet Explorer 7.</p> <p>My add-in is using custom Folder Home Page which displays my custom form, which wraps Outlook View Control.</p> <p>I get COM Exception with 'Exception from HRESULT: 0xXXXXXXXX' description every ti...
[ { "answer_id": 139934, "author": "BKimmel", "author_id": 13776, "author_profile": "https://Stackoverflow.com/users/13776", "pm_score": 1, "selected": false, "text": "<p>Dobri Dan, nency :)<br><br>I don't know if I can really offer a \"silver bullet\" solution given the information here.....
2008/09/25
[ "https://Stackoverflow.com/questions/133194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22062/" ]
I am trying to make an Outlook 2003 add-in using Visual Studio 2008 on Windows XP SP3 and Internet Explorer 7. My add-in is using custom Folder Home Page which displays my custom form, which wraps Outlook View Control. I get COM Exception with 'Exception from HRESULT: 0xXXXXXXXX' description every time when I try to ...
After a while, I finally find out what is the solution: change a name of the external storage to something new. During startup of the addin, it loads the non-default PST file, and changes its name (not the name of the pst file, but the name of the root folder) to "Documents". This is code: ``` session.AddStore("C:\\...
133,204
<p>How do I get a list of the files checked out by users (including the usernames) using P4V or P4? </p> <p>I want to provide a depot location and see a list of any files under that location (including sub folders) that are checked out.</p>
[ { "answer_id": 133222, "author": "Iain", "author_id": 20457, "author_profile": "https://Stackoverflow.com/users/20457", "pm_score": 5, "selected": false, "text": "<p>From the command line:</p>\n\n<pre><code>p4 opened -a //depot/Your/Location/...\n</code></pre>\n\n<p>The ... indicates tha...
2008/09/25
[ "https://Stackoverflow.com/questions/133204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20457/" ]
How do I get a list of the files checked out by users (including the usernames) using P4V or P4? I want to provide a depot location and see a list of any files under that location (including sub folders) that are checked out.
From the command line: ``` p4 opened -a //depot/Your/Location/... ``` The ... indicates that sub folders should be included.
133,214
<p>We need to implement a simple state machine in <strong>C</strong>.<br> Is a standard switch statement the best way to go?<br> We have a current state (state) and a trigger for the transition.</p> <pre><code> switch(state) { case STATE_1: state = DoState1(transition); break; case STATE_2: state = ...
[ { "answer_id": 133228, "author": "jdt141", "author_id": 10774, "author_profile": "https://Stackoverflow.com/users/10774", "pm_score": -1, "selected": false, "text": "<p>Boost has the statechart library. <a href=\"http://www.boost.org/doc/libs/1_36_0/libs/statechart/doc/index.html\" rel=\...
2008/09/25
[ "https://Stackoverflow.com/questions/133214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
We need to implement a simple state machine in **C**. Is a standard switch statement the best way to go? We have a current state (state) and a trigger for the transition. ``` switch(state) { case STATE_1: state = DoState1(transition); break; case STATE_2: state = DoState2(transition); br...
I prefer to use a table driven approach for most state machines: ``` typedef enum { STATE_INITIAL, STATE_FOO, STATE_BAR, NUM_STATES } state_t; typedef struct instance_data instance_data_t; typedef state_t state_func_t( instance_data_t *data ); state_t do_state_initial( instance_data_t *data ); state_t do_state_foo( i...
133,236
<p>I am wanting to store the "state" of some actions the user is performing in a series of different ASP.Net webforms. What are my choices for persisting state, and what are the pros/cons of each solution?</p> <p>I have been using Session objects, and using some helper methods to strongly type the objects:</p> <pre>...
[ { "answer_id": 133258, "author": "mattruma", "author_id": 1768, "author_profile": "https://Stackoverflow.com/users/1768", "pm_score": 3, "selected": false, "text": "<p>As for \"Session being evil\" ... if you were developing in classic ASP I would have to agree, but ASP.NET/IIS does a mu...
2008/09/25
[ "https://Stackoverflow.com/questions/133236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10589/" ]
I am wanting to store the "state" of some actions the user is performing in a series of different ASP.Net webforms. What are my choices for persisting state, and what are the pros/cons of each solution? I have been using Session objects, and using some helper methods to strongly type the objects: ``` public stati...
There is nothing inherently evil with session state. There are a couple of things to keep in mind that might bite you though: 1. If the user presses the browser back button you go back to the previous page but your session state is not reverted. So your CurrentAccount might not be what it originally was on the page. ...
133,243
<p>I want to have a <code>UIScrollView</code> with a set of subviews where each of these subviews has a <code>UITextView</code> with a different text. For this task, I have modified the <code>PageControl</code> example from the apple "iphone dev center" in order to add it a simple <code>UITextView</code> to the view wh...
[ { "answer_id": 156210, "author": "benzado", "author_id": 10947, "author_profile": "https://Stackoverflow.com/users/10947", "pm_score": 2, "selected": false, "text": "<p>I think the problem stems from the fact that <code>UITextView</code> is a subclass of <code>UIScrollView</code>, so you...
2008/09/25
[ "https://Stackoverflow.com/questions/133243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22154/" ]
I want to have a `UIScrollView` with a set of subviews where each of these subviews has a `UITextView` with a different text. For this task, I have modified the `PageControl` example from the apple "iphone dev center" in order to add it a simple `UITextView` to the view which is used to generate the subviews of the scr...
I resolved the problem forcing a "fake" scroll: ``` textView.contentOffset = CGPointMake(0, 1); textView.contentOffset = CGPointMake(0, 0); ```
133,270
<p>I would like to code a little program which visually illustrates the behavior of the <code>volatile</code> keyword. Ideally, it should be a program which performs concurrent access to a non volatile static field and which gets incorrect behavior because of that. </p> <p>Adding the volatile keyword in the same progr...
[ { "answer_id": 133338, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 4, "selected": false, "text": "<p>Yes, it's hardware dependent (you are unlikely to see the problem without multiple processors), but it's also implem...
2008/09/25
[ "https://Stackoverflow.com/questions/133270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
I would like to code a little program which visually illustrates the behavior of the `volatile` keyword. Ideally, it should be a program which performs concurrent access to a non volatile static field and which gets incorrect behavior because of that. Adding the volatile keyword in the same program should fix the pro...
I've achieved a working example! The main idea received from wiki, but with some changes for C#. The wiki article demonstrates this for static field of C++, it is looks like C# always carefully compile requests to static fields... and i make example with non static one: If you run this example in **Release** mode and...
133,281
<p>Has anyone tried the ActiveRecord <a href="http://www.castleproject.org/activerecord/gettingstarted/index.html" rel="nofollow noreferrer">Intro Sample</a> with C# 3.5? I somehow have the feeling that the sample is completely wrong or just out of date. The XML configuration is just plain wrong:</p> <pre><code>&lt;ad...
[ { "answer_id": 133305, "author": "Gilligan", "author_id": 12356, "author_profile": "https://Stackoverflow.com/users/12356", "pm_score": 0, "selected": false, "text": "<p>Delete the \"<code>hibernate.</code>\" part for all configuration entries. Your first example is the correct one.</p>\...
2008/09/25
[ "https://Stackoverflow.com/questions/133281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
Has anyone tried the ActiveRecord [Intro Sample](http://www.castleproject.org/activerecord/gettingstarted/index.html) with C# 3.5? I somehow have the feeling that the sample is completely wrong or just out of date. The XML configuration is just plain wrong: ``` <add key="connection.connection_string" value="xxx" /> `...
(This was too long for a comment post) [@Tigraine] From your comments on my previous answer it looks like the error lies not with the configuration, but with one of your entities. Removing the "hibernate" corrected the configuration so that it geve you the real error, which appears to be that the entity "Post" is not ...
133,310
<p>I have a JavaScript widget which provides standard extension points. One of them is the <code>beforecreate</code> function. It should return <code>false</code> to prevent an item from being created. </p> <p>I've added an Ajax call into this function using jQuery:</p> <pre><code>beforecreate: function (node, target...
[ { "answer_id": 133327, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 11, "selected": true, "text": "<p>From the <a href=\"https://api.jquery.com/jquery.ajax/\" rel=\"noreferrer\">jQuery documentation</a>: you specify...
2008/09/25
[ "https://Stackoverflow.com/questions/133310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313/" ]
I have a JavaScript widget which provides standard extension points. One of them is the `beforecreate` function. It should return `false` to prevent an item from being created. I've added an Ajax call into this function using jQuery: ``` beforecreate: function (node, targetNode, type, to) { jQuery.get('http://exam...
From the [jQuery documentation](https://api.jquery.com/jquery.ajax/): you specify the **asynchronous** option to be **false** to get a synchronous Ajax request. Then your callback can set some data before your mother function proceeds. Here's what your code would look like if changed as suggested: ``` beforecreate: f...
133,313
<p>I'm trying to design some tables to store some data, which has to be converted to different languages later. Can anybody provide some "best practices" or guidelines for this?</p> <p>Thanks</p>
[ { "answer_id": 133333, "author": "HLGEM", "author_id": 9034, "author_profile": "https://Stackoverflow.com/users/9034", "pm_score": 0, "selected": false, "text": "<p>I beleve that more information on what you are doing would be helpful. CAn you give some samples of the data? And what do y...
2008/09/25
[ "https://Stackoverflow.com/questions/133313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22016/" ]
I'm trying to design some tables to store some data, which has to be converted to different languages later. Can anybody provide some "best practices" or guidelines for this? Thanks
Let's say you have a products table that looks like this: ``` Products ---------- id price Products_Translations ---------------------- product_id locale name description ``` Then you just join on product\_id = product.id and where locale='en-US' of course this has an impact on performance, since you now need a jo...
133,325
<p>Is there a way to Minimize an external application that I don't have control over from with-in my Delphi application?</p> <p>for example notepad.exe, except the application I want to minimize will only ever have one instance.</p>
[ { "answer_id": 133348, "author": "Juanma", "author_id": 3730, "author_profile": "https://Stackoverflow.com/users/3730", "pm_score": 2, "selected": false, "text": "<p>I'm not a Delphi expert, but if you can invoke win32 apis, you can use FindWindow and ShowWindow to minimize a window, eve...
2008/09/25
[ "https://Stackoverflow.com/questions/133325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
Is there a way to Minimize an external application that I don't have control over from with-in my Delphi application? for example notepad.exe, except the application I want to minimize will only ever have one instance.
You can use **FindWindow** to find the application handle and **ShowWindow** to minimize it. ``` var Indicador :Integer; begin // Find the window by Classname Indicador := FindWindow(PChar('notepad'), nil); // if finded if (Indicador <> 0) then begin // Minimize ShowWindow(Indicador,SW_MINIMIZE);...
133,335
<p>I installed subclipse in eclipse, but I get an error message "Expected format '3' of repository; found format '5'" when I try to open a repository.</p> <p>Here is the sequence of steps that leads to the error message.</p> <p>Select "Window -> Open Perspective -> SNV Repository Exploring" from the Eclipse main menu...
[ { "answer_id": 133378, "author": "lindelof", "author_id": 1428, "author_profile": "https://Stackoverflow.com/users/1428", "pm_score": 2, "selected": false, "text": "<p>Just guessing here, but make sure your version of the libsvnjavahl libraries are the same as the version of SVN you're u...
2008/09/25
[ "https://Stackoverflow.com/questions/133335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21435/" ]
I installed subclipse in eclipse, but I get an error message "Expected format '3' of repository; found format '5'" when I try to open a repository. Here is the sequence of steps that leads to the error message. Select "Window -> Open Perspective -> SNV Repository Exploring" from the Eclipse main menu. Right click on...
I can't help on your posted problem, but I would recommend trying subversive instead. I made the switch out of frustration with some subclipse bugs and have been much happier. It does take a bit more work to install. [Eclipse Subversive Project](http://www.eclipse.org/subversive/)
133,357
<p>How do I find the name of the namespace or module 'Foo' in the filter below?</p> <pre><code>class ApplicationController &lt; ActionController::Base def get_module_name @module_name = ??? end end class Foo::BarController &lt; ApplicationController before_filter :get_module_name end </code></pre>
[ { "answer_id": 133396, "author": "Daniel Lucraft", "author_id": 11951, "author_profile": "https://Stackoverflow.com/users/11951", "pm_score": 4, "selected": false, "text": "<p>This should do it:</p>\n\n<pre><code> def get_module_name\n @module_name = self.class.to_s.split(\"::\").fir...
2008/09/25
[ "https://Stackoverflow.com/questions/133357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21872/" ]
How do I find the name of the namespace or module 'Foo' in the filter below? ``` class ApplicationController < ActionController::Base def get_module_name @module_name = ??? end end class Foo::BarController < ApplicationController before_filter :get_module_name end ```
None of these solutions consider a constant with multiple parent modules. For instance: ``` A::B::C ``` As of Rails 3.2.x you can simply: ``` "A::B::C".deconstantize #=> "A::B" ``` As of Rails 3.1.x you can: ``` constant_name = "A::B::C" constant_name.gsub( "::#{constant_name.demodulize}", '' ) ``` This is bec...
133,374
<p>When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with:</p> <pre><code>String CRLF = "\r\n"; String sql = "SELECT * " + CRLF + "FROM (" + CRLF + " SELECT (a.Number * 256) + b.Number AS Nu...
[ { "answer_id": 133398, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 5, "selected": true, "text": "<p>it's because you have just opened the data reader and have not completely iterated through it yet. you will need to .Cance...
2008/09/25
[ "https://Stackoverflow.com/questions/133374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with: ``` String CRLF = "\r\n"; String sql = "SELECT * " + CRLF + "FROM (" + CRLF + " SELECT (a.Number * 256) + b.Number AS Number" + CRLF +...
it's because you have just opened the data reader and have not completely iterated through it yet. you will need to .Cancel() your DbCommand object before you attempt to close a data reader that hasn't completed yet (and the DbConnection as well). of course, by .Cancel()-ing your DbCommand, I'm not sure of this but you...
133,379
<p>I'm trying to install a service using InstallUtil.exe but invoked through <code>Process.Start</code>. Here's the code:</p> <pre><code>ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); System.Diagnostics.Process.Start (startInfo); </code></pre> <p>where <code>m_strInstallUtil</code> ...
[ { "answer_id": 133478, "author": "Vijesh VP", "author_id": 22016, "author_profile": "https://Stackoverflow.com/users/22016", "pm_score": 1, "selected": false, "text": "<p>You should use Impersonation to elevate the state.</p>\n\n<pre><code>WindowsIdentity identity = new WindowsIdentity(a...
2008/09/25
[ "https://Stackoverflow.com/questions/133379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1683/" ]
I'm trying to install a service using InstallUtil.exe but invoked through `Process.Start`. Here's the code: ``` ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); System.Diagnostics.Process.Start (startInfo); ``` where `m_strInstallUtil` is the fully qualified path and exe to "InstallU...
You can indicate the new process should be started with elevated permissions by setting the Verb property of your startInfo object to 'runas', as follows: ``` startInfo.Verb = "runas"; ``` This will cause Windows to behave as if the process has been started from Explorer with the "Run as Administrator" menu command....
133,390
<p>I want to use forms authentication in my asp.net mvc site.</p> <p>Can I use an already existing sql db (on a remote server) for it? How do I configure the site to use this db for authentication? Which tables do I need/are used for authentication?</p>
[ { "answer_id": 133432, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 3, "selected": true, "text": "<p>You can. Check <code>aspnet_regsql.exe</code> program parameters in your Windows\\Microsoft.NET\\Framework\\v2.xxx folder, spec...
2008/09/25
[ "https://Stackoverflow.com/questions/133390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9632/" ]
I want to use forms authentication in my asp.net mvc site. Can I use an already existing sql db (on a remote server) for it? How do I configure the site to use this db for authentication? Which tables do I need/are used for authentication?
You can. Check `aspnet_regsql.exe` program parameters in your Windows\Microsoft.NET\Framework\v2.xxx folder, specially `sqlexportonly`. After creating the needed tables, you can configure: create a connection string in the web.config file and then set up the MemberShipProvider to use this connection string: ``` <co...
133,394
<p>I am developing a Joomla component and one of the views needs to render itself as PDF. In the view, I have tried setting the content-type with the following line, but when I see the response, it is text/html anyways.</p> <pre><code>header('Content-type: application/pdf'); </code></pre> <p>If I do this in a regular...
[ { "answer_id": 134827, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 5, "selected": true, "text": "<p>Since version 1.5 Joomla has the JDocument object. Use <a href=\"http://api.joomla.org/Joomla-Framework/Document/JDocume...
2008/09/25
[ "https://Stackoverflow.com/questions/133394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2680/" ]
I am developing a Joomla component and one of the views needs to render itself as PDF. In the view, I have tried setting the content-type with the following line, but when I see the response, it is text/html anyways. ``` header('Content-type: application/pdf'); ``` If I do this in a regular php page, everything work...
Since version 1.5 Joomla has the JDocument object. Use [JDocument::setMimeEncoding()](http://api.joomla.org/Joomla-Framework/Document/JDocument.html#setMimeEncoding) to set the content type. ``` $doc =& JFactory::getDocument(); $doc->setMimeEncoding('application/pdf'); ``` In your special case, a look at [JDocumentP...
133,436
<p>I'm using Java 6, Tomcat 6, and Metro. I use WebService and WebMethod annotations to expose my web service. I would like to obtain information about the request. I tried the following code, but wsCtxt is always null. What step must I take to <em>not</em> get null for the WebServiceContext.</p> <p>In other words: ho...
[ { "answer_id": 133539, "author": "asterite", "author_id": 20459, "author_profile": "https://Stackoverflow.com/users/20459", "pm_score": 1, "selected": false, "text": "<p>Maybe the javax.ws.rs.core.Context annotation is for what you are looking for, instead of Resource?</p>\n" }, { ...
2008/09/25
[ "https://Stackoverflow.com/questions/133436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2959/" ]
I'm using Java 6, Tomcat 6, and Metro. I use WebService and WebMethod annotations to expose my web service. I would like to obtain information about the request. I tried the following code, but wsCtxt is always null. What step must I take to *not* get null for the WebServiceContext. In other words: how can I execute t...
I recommend you either rename your variable from wsCtxt to wsContext or assign the name attribute to the @Resource annotation. The [J2ee tutorial on @Resource](http://java.sun.com/javaee/5/docs/tutorial/doc/bncjk.html) indicates that the name of the variable is used as part of the lookup. I've encountered this same pro...
133,442
<p>Our server application is listening on a port, and after a period of time it no longer accepts incoming connections. (And while I'd love to solve this issue, it's not what I'm asking about here;)</p> <p>The strange this is that when our app stops accepting connections on port 44044, so does IIS (on port 8080). Ki...
[ { "answer_id": 133466, "author": "RichS", "author_id": 6247, "author_profile": "https://Stackoverflow.com/users/6247", "pm_score": 2, "selected": false, "text": "<p>You haven't maxed out the available port handles have you ?<br>\n <code>netstat -a</code></p>\n\n<p>I saw something simi...
2008/09/25
[ "https://Stackoverflow.com/questions/133442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16662/" ]
Our server application is listening on a port, and after a period of time it no longer accepts incoming connections. (And while I'd love to solve this issue, it's not what I'm asking about here;) The strange this is that when our app stops accepting connections on port 44044, so does IIS (on port 8080). Killing our ap...
You may well be starving the stack. It is pretty easy to drain in a high open/close transactions per second environment e.g. webserver serving lots of unpooled requests. This is exhacerbated by the default TIME-WAIT delay - the amount of time that a socket has to be closed before being recycled defaults to 90s (if I ...
133,453
<p>Does IPsec in Windows XP Sp3 support AES-256 encryption?</p> <p><strong>Update:</strong></p> <ol> <li>Windows IPsec FAQ says that it's not supported in Windows XP, but maybe they changed it in Service Pack 3?<br> http://www.microsoft.com/technet/network/ipsec/ipsecfaq.mspx<br> Question: <em>Is Advanced Encryptio...
[ { "answer_id": 133466, "author": "RichS", "author_id": 6247, "author_profile": "https://Stackoverflow.com/users/6247", "pm_score": 2, "selected": false, "text": "<p>You haven't maxed out the available port handles have you ?<br>\n <code>netstat -a</code></p>\n\n<p>I saw something simi...
2008/09/25
[ "https://Stackoverflow.com/questions/133453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22174/" ]
Does IPsec in Windows XP Sp3 support AES-256 encryption? **Update:** 1. Windows IPsec FAQ says that it's not supported in Windows XP, but maybe they changed it in Service Pack 3? http://www.microsoft.com/technet/network/ipsec/ipsecfaq.mspx Question: *Is Advanced Encryption Standard (AES) encryption supported?* ...
You may well be starving the stack. It is pretty easy to drain in a high open/close transactions per second environment e.g. webserver serving lots of unpooled requests. This is exhacerbated by the default TIME-WAIT delay - the amount of time that a socket has to be closed before being recycled defaults to 90s (if I ...
133,487
<p>I have a LinkedList, where Entry has a member called id. I want to remove the Entry from the list where id matches a search value. What's the best way to do this? I don't want to use Remove(), because Entry.Equals will compare other members, and I only want to match on id. I'm hoping to do something kind of like...
[ { "answer_id": 133503, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>Just use the Where extension method. You will get a new list (IIRC).</p>\n" }, { "answer_id": 133577, "autho...
2008/09/25
[ "https://Stackoverflow.com/questions/133487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2348/" ]
I have a LinkedList, where Entry has a member called id. I want to remove the Entry from the list where id matches a search value. What's the best way to do this? I don't want to use Remove(), because Entry.Equals will compare other members, and I only want to match on id. I'm hoping to do something kind of like this: ...
``` list.Remove(list.First(e => e.id == searchId)); ```
133,515
<p>I am using <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx" rel="noreferrer">SqlMetal</a> to general my DataContext.dbml class for my ASP.net application using LinqToSql. When I initially created the DataContext.dbml file, Visual Studio used this to create a related DataContext.designer.cs file. This ...
[ { "answer_id": 134670, "author": "DamienG", "author_id": 5720, "author_profile": "https://Stackoverflow.com/users/5720", "pm_score": 4, "selected": true, "text": "<p>The designer.cs file is normally maintained automatically as you make changes to the DBML within Visual Studio. If VS isn'...
2008/09/25
[ "https://Stackoverflow.com/questions/133515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51/" ]
I am using [SqlMetal](http://msdn.microsoft.com/en-us/library/bb386987.aspx) to general my DataContext.dbml class for my ASP.net application using LinqToSql. When I initially created the DataContext.dbml file, Visual Studio used this to create a related DataContext.designer.cs file. This designer file contains the Data...
The designer.cs file is normally maintained automatically as you make changes to the DBML within Visual Studio. If VS isn't running when you recreate the DBML it may not know. Check that the .DBML file in Visual Studio has Custom Tool property set to MSLinqToSQLGenerator. If it isn't, then set it to that. If it is try...
133,559
<p>I am writing a Windows service that pulls messages from an MSMQ and posts them to a legacy system (Baan). If the post fails or the machine goes down during the post, I don't want to loose the message. I am therefore using MSMQ transactions. I abort on failure, and I commit on success.</p> <p>When working against a ...
[ { "answer_id": 133654, "author": "Maurice", "author_id": 19676, "author_profile": "https://Stackoverflow.com/users/19676", "pm_score": 2, "selected": false, "text": "<p>Using TransactionScope should work provided the MSDTC is running on both machines.</p>\n\n<pre><code>MessageQueue queue...
2008/09/25
[ "https://Stackoverflow.com/questions/133559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7668/" ]
I am writing a Windows service that pulls messages from an MSMQ and posts them to a legacy system (Baan). If the post fails or the machine goes down during the post, I don't want to loose the message. I am therefore using MSMQ transactions. I abort on failure, and I commit on success. When working against a local queu...
I left a comment asking about the version of MSMQ that you're using, as I think this is the cause of your problem. Transactional Receive wasn't implemented in the earlier versions of MSMQ. If that is the case, then this [blog post](http://blogs.msdn.com/johnbreakwell/archive/2007/12/11/how-do-i-get-transactional-remote...
133,571
<p>Wanted to convert</p> <pre><code>&lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; </code></pre> <p>into</p> <pre><code>&lt;br/&gt; </code></pre>
[ { "answer_id": 133593, "author": "mdec", "author_id": 15534, "author_profile": "https://Stackoverflow.com/users/15534", "pm_score": 2, "selected": false, "text": "<p>Use a regular expression to match <code>&lt;br/&gt;</code> one or more times, then use preg_replace (or similar) to replac...
2008/09/25
[ "https://Stackoverflow.com/questions/133571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20907/" ]
Wanted to convert ``` <br/> <br/> <br/> <br/> <br/> ``` into ``` <br/> ```
You can do this with a regular expression: ``` preg_replace("/(<br\s*\/?>\s*)+/", "<br/>", $input); ``` This if you pass in your source HTML, this will return a string with a single <br/> replacing every run of them.
133,596
<p>Is there a way to make a Radio Button enabled/disabled (not checked/unchecked) via CSS? </p> <p>I've need to toggle some radio buttons on the client so that the values can be read on the server, but setting the 'enabled' property to 'false' then changing this on the client via javascript seems to prevent me from po...
[ { "answer_id": 133617, "author": "neuroguy123", "author_id": 12529, "author_profile": "https://Stackoverflow.com/users/12529", "pm_score": 3, "selected": false, "text": "<p>Disabled is a html attribute, not a css attribute.</p>\n\n<p>Why can't you just use some jQuery</p>\n\n<pre><code>$...
2008/09/25
[ "https://Stackoverflow.com/questions/133596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6624/" ]
Is there a way to make a Radio Button enabled/disabled (not checked/unchecked) via CSS? I've need to toggle some radio buttons on the client so that the values can be read on the server, but setting the 'enabled' property to 'false' then changing this on the client via javascript seems to prevent me from posting back...
To the best of my knowledge CSS cannot affect the functionality of the application. It can only affect the display. So while you can hide it with css (display:none) you can't disable it. What you could do would be to disable it on page load with javascript. There are a couple ways to do this but an easy way would be ...
133,601
<p>Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown number of open/close braces nested within the outer braces?</p> <p>For example:</p> <pre><code>public...
[ { "answer_id": 133614, "author": "Craig H", "author_id": 2328, "author_profile": "https://Stackoverflow.com/users/2328", "pm_score": 2, "selected": false, "text": "<p>No, you are getting into the realm of <a href=\"http://en.wikipedia.org/wiki/Context-free_grammar\" rel=\"nofollow norefe...
2008/09/25
[ "https://Stackoverflow.com/questions/133601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1199234/" ]
Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown number of open/close braces nested within the outer braces? For example: ``` public MyMethod() { if (t...
No. It's that easy. A finite automaton (which is the data structure underlying a regular expression) does not have memory apart from the state it's in, and if you have arbitrarily deep nesting, you need an arbitrarily large automaton, which collides with the notion of a *finite* automaton. You can match nested/paired ...
133,648
<p>I want to insert say 50,000 records into sql server database 2000 at a time. How to accomplish this?</p>
[ { "answer_id": 133687, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 0, "selected": false, "text": "<p>Do you mean for a test of some kind?</p>\n\n<pre><code>declare @index integer\nset @index = 0\nwhile @index &lt; 50000\...
2008/09/25
[ "https://Stackoverflow.com/questions/133648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
I want to insert say 50,000 records into sql server database 2000 at a time. How to accomplish this?
You can use the SELECT TOP clause: in MSSQL 2005 it was extended allowing you to use a variable to specify the number of records (older version allowed only a numeric constant) You can try something like this: (untested, because I have no access to a MSSQL2005 at the moment) ``` begin declare @n int, @rows int s...
133,660
<p>I need to create a directory on a mapped network drive. I am using a code:</p> <pre><code>DirectoryInfo targetDirectory = new DirectoryInfo(path); if (targetDirectory != null) { targetDirectory.Create(); } </code></pre> <p>If I specify the path like "\\\\ServerName\\Directory", it all goes OK. If I map the "\\...
[ { "answer_id": 133708, "author": "fhe", "author_id": 4445, "author_profile": "https://Stackoverflow.com/users/4445", "pm_score": 1, "selected": false, "text": "<p>You can try to use <a href=\"http://msdn.microsoft.com/en-us/library/aa385453.aspx\" rel=\"nofollow noreferrer\">WNetConnecti...
2008/09/25
[ "https://Stackoverflow.com/questions/133660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to create a directory on a mapped network drive. I am using a code: ``` DirectoryInfo targetDirectory = new DirectoryInfo(path); if (targetDirectory != null) { targetDirectory.Create(); } ``` If I specify the path like "\\\\ServerName\\Directory", it all goes OK. If I map the "\\ServerName\Directory" as, ...
Mapped network drives are user specific, so if the app is running under a different identity than the user that created the mapped drive letter (z:) it won't work.
133,671
<p>In my ASP.net MVC app I have a view that looks like this:</p> <pre><code>... &lt;label&gt;Due Date&lt;/label&gt; &lt;%=Html.TextBox("due")%&gt; ... </code></pre> <p>I am using a <code>ModelBinder</code> to bind the post to my model (the due property is of <code>DateTime</code> type). The problem is when I put "01/...
[ { "answer_id": 134097, "author": "Switters", "author_id": 1860358, "author_profile": "https://Stackoverflow.com/users/1860358", "pm_score": 1, "selected": false, "text": "<p>In order to get strongly typed access to your model in the code behind of your view you can do this:</p>\n\n<pre><...
2008/09/25
[ "https://Stackoverflow.com/questions/133671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736/" ]
In my ASP.net MVC app I have a view that looks like this: ``` ... <label>Due Date</label> <%=Html.TextBox("due")%> ... ``` I am using a `ModelBinder` to bind the post to my model (the due property is of `DateTime` type). The problem is when I put "01/01/2009" into the textbox, and the post does not validate (due to ...
I just came across this very simple and elegant solution, available in MVC 2: <http://geekswithblogs.net/michelotti/archive/2010/02/05/mvc-2-editor-template-with-datetime.aspx> Basically if you are using MVC 2.0, use the following in your view. ``` <%=Html.LabelFor(m => m.due) %> <%=Html.EditorFor(m => m.due)%> `...
133,675
<p>I need to implement red eye reduction for an application I am working on.</p> <p>Googling mostly provides links to commercial end-user products.</p> <p>Do you know a good red eye reduction algorithm, which could be used in a GPL application?</p>
[ { "answer_id": 133696, "author": "japollock", "author_id": 1210318, "author_profile": "https://Stackoverflow.com/users/1210318", "pm_score": 2, "selected": false, "text": "<p>The simplest algorithm, and still one that is very effective would be to zero out the R of the RGB triple for the...
2008/09/25
[ "https://Stackoverflow.com/questions/133675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20107/" ]
I need to implement red eye reduction for an application I am working on. Googling mostly provides links to commercial end-user products. Do you know a good red eye reduction algorithm, which could be used in a GPL application?
I'm way late to the party here, but for future searchers I've used the following algorithm for a personal app I wrote. First of all, the region to reduce is selected by the user and passed to the red eye reducing method as a center Point and radius. The method loops through each pixel within the radius and does the fo...
133,680
<p>When I am using Bitvise Tunnelier and I spawn a new xterm window connecting to our sun station everything works nicely. We have visual slick edit installed on the sun station and I have been instructed to open it using the command vs&amp;. When I do this I get the following:</p> <pre><code>fbm240-1:/home/users/ajah...
[ { "answer_id": 133736, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 0, "selected": false, "text": "<p>What is your DISPLAY environment variable in the shell where you run vs? Is it really \"&lt;Default Display>\"? If yes, try ...
2008/09/25
[ "https://Stackoverflow.com/questions/133680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5831/" ]
When I am using Bitvise Tunnelier and I spawn a new xterm window connecting to our sun station everything works nicely. We have visual slick edit installed on the sun station and I have been instructed to open it using the command vs&. When I do this I get the following: ``` fbm240-1:/home/users/ajahn 1 % vs& [1] 4716...
You're going to need an Xwindows server on your Windows box in order to run graphical Unix apps remotely on the Sun server and have it display on your Windows box. I don't think Tunnelier supports Xwindows tunneling. Take a look at Xming, an Xwindows server for Windows that comes with Putty, an ssh client: <http://sou...
133,710
<p>When I use the task, the property is only set to TRUE if the resource (say file) is available. If not, the property is undefined.</p> <p>When I print the value of the property, it gives true if the resource was available, but otherwise just prints the property name.</p> <p>Is there a way to set the property to so...
[ { "answer_id": 133770, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 5, "selected": true, "text": "<p>You can use a condition in combination with not:</p>\n\n<p><a href=\"http://ant.apache.org/manual/Tasks/condition.html...
2008/09/25
[ "https://Stackoverflow.com/questions/133710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When I use the task, the property is only set to TRUE if the resource (say file) is available. If not, the property is undefined. When I print the value of the property, it gives true if the resource was available, but otherwise just prints the property name. Is there a way to set the property to some value if the re...
You can use a condition in combination with not: <http://ant.apache.org/manual/Tasks/condition.html> ``` <condition property="fooDoesNotExist"> <not> <available filepath="path/to/foo"/> </not> </condition> ```
133,719
<p>I am running Ruby and MySQL on a Windows box.</p> <p>I have some Ruby code that needs to connect to a MySQL database a perform a select. To connect to the database I need to provide the password among other things. </p> <p>The Ruby code can display a prompt requesting the password, the user types in the password a...
[ { "answer_id": 133745, "author": "jk.", "author_id": 21284, "author_profile": "https://Stackoverflow.com/users/21284", "pm_score": 5, "selected": false, "text": "<p>Poor man's solution:</p>\n\n<pre><code>system \"stty -echo\"\n# read password\nsystem \"stty echo\"\n</code></pre>\n\n<p>Or...
2008/09/25
[ "https://Stackoverflow.com/questions/133719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15868/" ]
I am running Ruby and MySQL on a Windows box. I have some Ruby code that needs to connect to a MySQL database a perform a select. To connect to the database I need to provide the password among other things. The Ruby code can display a prompt requesting the password, the user types in the password and hits the Enter...
To answer my own question, and for the benefit of anyone else who would like to know, there is a Ruby gem called [HighLine](http://rubydoc.info/gems/highline/frames) that you need. ``` require 'rubygems' require 'highline/import' def get_password(prompt="Enter Password") ask(prompt) {|q| q.echo = false} end thePa...
133,772
<p>I've got a class that I'm using as a settings class that is serialized into an XML file that administrators can then edit to change settings in the application. (The settings are a little more complex than the <code>App.config</code> allows for.)</p> <p>I'm using the <code>XmlSerializer</code> class to deserialize ...
[ { "answer_id": 133804, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 1, "selected": false, "text": "<p>I dont think you can use the automatic serialization since the property is read only.</p>\n\n<p>My course of action woul...
2008/09/25
[ "https://Stackoverflow.com/questions/133772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21807/" ]
I've got a class that I'm using as a settings class that is serialized into an XML file that administrators can then edit to change settings in the application. (The settings are a little more complex than the `App.config` allows for.) I'm using the `XmlSerializer` class to deserialize the XML file, and I want it to b...
You have to use a mutable list type, like ArrayList (or IList IIRC).
133,777
<p>I have a subversion repository that contains a number so subfolders, corresponding to the various applications, configuration files, DLLs, etc (I'll call them 'modules') that make up my project. Now we are starting to "branch" into several related projects. That is, each high-level project will use a number of the...
[ { "answer_id": 133807, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 0, "selected": false, "text": "<p>I think that your use of \"high-level\" to describe what a project is suggests that you should have a Projects/modules s...
2008/09/25
[ "https://Stackoverflow.com/questions/133777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17962/" ]
I have a subversion repository that contains a number so subfolders, corresponding to the various applications, configuration files, DLLs, etc (I'll call them 'modules') that make up my project. Now we are starting to "branch" into several related projects. That is, each high-level project will use a number of the modu...
It would seem best to organize by **Project** at the top level, since you're going to want to checkout an entire branch and have a working copy for the project. If you organize by module, you'll have to do multiple checkouts (one for each module you're using) in order to build your project to a point where it's useable...
133,837
<p>What might be the best way to start programming using boost lambda libraries.</p>
[ { "answer_id": 133905, "author": "Ryan", "author_id": 17917, "author_profile": "https://Stackoverflow.com/users/17917", "pm_score": 2, "selected": false, "text": "<p>Depends. Are you already well versed in functional programming concepts? If not, I'd suggest that you start in a language ...
2008/09/25
[ "https://Stackoverflow.com/questions/133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
What might be the best way to start programming using boost lambda libraries.
Remaining within the boundaries of the C++ language and libraries, I would suggest first getting used to programming using STL algorithm function templates, as one the most common use you will have for boost::lambda is to replace functor classes with inlined expressions inlined. The library documentation itself gives ...
133,860
<p>My Apache server runs on some non-default (not-root) account. When it tries to run a python script which in turn executes a subversion check-out command, 'svn checkout' fails with the following error message:</p> <pre><code>svn: Can't open file '/root/.subversion/servers': Permission denied </code></pre> <p>At the...
[ { "answer_id": 133963, "author": "pfranza", "author_id": 22221, "author_profile": "https://Stackoverflow.com/users/22221", "pm_score": 0, "selected": false, "text": "<p>Try granting the Apache user (the user that the apache service is running under) r+w permissions on that file.</p>\n" ...
2008/09/25
[ "https://Stackoverflow.com/questions/133860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140995/" ]
My Apache server runs on some non-default (not-root) account. When it tries to run a python script which in turn executes a subversion check-out command, 'svn checkout' fails with the following error message: ``` svn: Can't open file '/root/.subversion/servers': Permission denied ``` At the same time running that py...
It sounds like the environment you apache process is running under is a little unusual. For whatever reason, svn seems to think the user configuration files it needs are in /root. You can avoid having svn use the root versions of the files by specifying on the command line which config directory to use, like so: ``` s...
133,883
<p>How can I script a bat or cmd to stop and start a service reliably with error checking (or let me know that it wasn't successful for whatever reason)?</p>
[ { "answer_id": 133900, "author": "ZombieSheep", "author_id": 377, "author_profile": "https://Stackoverflow.com/users/377", "pm_score": 3, "selected": false, "text": "<p>Using the return codes from <code>net start</code> and <code>net stop</code> seems like the best method to me. Try a lo...
2008/09/25
[ "https://Stackoverflow.com/questions/133883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
How can I script a bat or cmd to stop and start a service reliably with error checking (or let me know that it wasn't successful for whatever reason)?
Use the `SC` (service control) command, it gives you a lot more options than just `start` & `stop`. ``` DESCRIPTION: SC is a command line program used for communicating with the NT Service Controller and services. USAGE: sc <server> [command] [service name] ... The option <server...
133,886
<p>Lexical analyzers are quite easy to write when you have regexes. Today I wanted to write a simple general analyzer in Python, and came up with:</p> <pre><code>import re import sys class Token(object): """ A simple Token structure. Contains the token type, value and position. """ def __init__(s...
[ { "answer_id": 134065, "author": "Armin Ronacher", "author_id": 19990, "author_profile": "https://Stackoverflow.com/users/19990", "pm_score": 2, "selected": false, "text": "<p><code>re.match</code> is anchored. You can give it a position argument:</p>\n\n<pre><code>pos = 0\nend = len(te...
2008/09/25
[ "https://Stackoverflow.com/questions/133886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Lexical analyzers are quite easy to write when you have regexes. Today I wanted to write a simple general analyzer in Python, and came up with: ``` import re import sys class Token(object): """ A simple Token structure. Contains the token type, value and position. """ def __init__(self, type, val...
You can merge all your regexes into one using the "|" operator and let the regex library do the work of discerning between tokens. Some care should be taken to ensure the preference of tokens (for example to avoid matching a keyword as an identifier).
133,887
<p>I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax like </p> <pre><code>val = myHash("Key").("key") </code></pre> <p>I know I need to use Generics but I can't figure out the correct syntax using VB in ASP.NET 2.0, there are plenty of c# examples on the net but they aren't h...
[ { "answer_id": 133907, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": true, "text": "<p>OK, I'm better at C# than vb.net, but I'll give this a go....</p>\n\n<pre><code>Dim myHash as Dictionary(Of string,...
2008/09/25
[ "https://Stackoverflow.com/questions/133887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12226/" ]
I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax like ``` val = myHash("Key").("key") ``` I know I need to use Generics but I can't figure out the correct syntax using VB in ASP.NET 2.0, there are plenty of c# examples on the net but they aren't helping much. Cheers!
OK, I'm better at C# than vb.net, but I'll give this a go.... ``` Dim myHash as Dictionary(Of string, Dictionary(Of string, Integer)); ```
133,897
<p>I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that is, short perpendicular lines at each of my end points. The caps should be N pixels in length.</p> <p>Thus, to draw my "...
[ { "answer_id": 133952, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 8, "selected": true, "text": "<p>You need to compute a unit vector that's perpendicular to the line segment. Avoid computing the slope because that ...
2008/09/25
[ "https://Stackoverflow.com/questions/133897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12058/" ]
I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that is, short perpendicular lines at each of my end points. The caps should be N pixels in length. Thus, to draw my "cap" line ...
You need to compute a unit vector that's perpendicular to the line segment. Avoid computing the slope because that can lead to divide by zero errors. ``` dx = x1-x2 dy = y1-y2 dist = sqrt(dx*dx + dy*dy) dx /= dist dy /= dist x3 = x1 + (N/2)*dy y3 = y1 - (N/2)*dx x4 = x1 - (N/2)*dy y4 = y1 + (N/2)*dx ```
133,922
<p>This is a <em>super basic</em> question but I'm trying to execute a Query that I'm building via some form values against the MS Access database the form resides in. I don't think I need to go through ADO formally, but maybe I do.</p> <p>Anyway, some help would be appreciated. Sorry for being a n00b. ;)</p>
[ { "answer_id": 134347, "author": "jinsungy", "author_id": 1316, "author_profile": "https://Stackoverflow.com/users/1316", "pm_score": 2, "selected": false, "text": "<p>You can use the following DAO code to query an Access DB:</p>\n\n<pre><code>Dim rs As DAO.Recordset\nDim db As Database\...
2008/09/25
[ "https://Stackoverflow.com/questions/133922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
This is a *super basic* question but I'm trying to execute a Query that I'm building via some form values against the MS Access database the form resides in. I don't think I need to go through ADO formally, but maybe I do. Anyway, some help would be appreciated. Sorry for being a n00b. ;)
You can use the following DAO code to query an Access DB: ``` Dim rs As DAO.Recordset Dim db As Database Set db = CurrentDb Set rs = db.OpenRecordset("SELECT * FROM Attendance WHERE ClassID = " & ClassID) do while not rs.EOF 'do stuff rs.movenext loop rs.Close Set rs = Nothing ``` In my case, ClassID is a tex...
133,925
<p>I'm trying to direct a browser to a different page. If I wanted a GET request, I might say</p> <pre><code>document.location.href = 'http://example.com/q=a'; </code></pre> <p>But the resource I'm trying to access won't respond properly unless I use a POST request. If this were not dynamically generated, I might use...
[ { "answer_id": 133937, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 2, "selected": false, "text": "<p>You could dynamically add the form using DHTML and then submit.</p>\n" }, { "answer_id": 133951, "aut...
2008/09/25
[ "https://Stackoverflow.com/questions/133925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16981/" ]
I'm trying to direct a browser to a different page. If I wanted a GET request, I might say ``` document.location.href = 'http://example.com/q=a'; ``` But the resource I'm trying to access won't respond properly unless I use a POST request. If this were not dynamically generated, I might use the HTML ``` <form actio...
Dynamically create `<input>`s in a form and submit it ----------------------------------------------------- ```js /** * sends a request to the specified url from a form. this will change the window location. * @param {string} path the path to send the post request to * @param {object} params the parameters to add t...
133,953
<p>I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these options </p> <ul> <li>Allow this workflow to be manually started by an authenticated user with Edit Items Permissions. </li> <li>Start t...
[ { "answer_id": 145346, "author": "Kyle Trauberman", "author_id": 21461, "author_profile": "https://Stackoverflow.com/users/21461", "pm_score": 0, "selected": false, "text": "<p>I've encountered this issue as well and found out that once a workflow has started, it cannot be re-started aut...
2008/09/25
[ "https://Stackoverflow.com/questions/133953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18246/" ]
I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these options * Allow this workflow to be manually started by an authenticated user with Edit Items Permissions. * Start this workflow when a new ...
**Finally, we got through the support services processes at Microsoft and got a solution!** First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something with next service pack oder n...
133,956
<p>I am currently running into a problem where an element is coming back from my xml file with a single quote in it. This is causing xml_parse to break it up into multiple chunks, example: Get Wired, You're Hired! Is then enterpreted as 'Get Wired, You' being one object, the single quote being a second, and 're Hired!'...
[ { "answer_id": 145346, "author": "Kyle Trauberman", "author_id": 21461, "author_profile": "https://Stackoverflow.com/users/21461", "pm_score": 0, "selected": false, "text": "<p>I've encountered this issue as well and found out that once a workflow has started, it cannot be re-started aut...
2008/09/25
[ "https://Stackoverflow.com/questions/133956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22216/" ]
I am currently running into a problem where an element is coming back from my xml file with a single quote in it. This is causing xml\_parse to break it up into multiple chunks, example: Get Wired, You're Hired! Is then enterpreted as 'Get Wired, You' being one object, the single quote being a second, and 're Hired!' a...
**Finally, we got through the support services processes at Microsoft and got a solution!** First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something with next service pack oder n...
133,958
<p>I'm calling some code that uses the BitmapData class from .NET. I've hit something where I can't find a definitive answer on Googlespace.</p> <p>Because it seems that LockBits and UnlockBits must always be called in a pair, I'm using this:</p> <pre><code> System.Drawing.Imaging.BitmapData tempImageData = t...
[ { "answer_id": 133998, "author": "mmr", "author_id": 21981, "author_profile": "https://Stackoverflow.com/users/21981", "pm_score": 0, "selected": false, "text": "<p>Are you expecting some sort of exception to be thrown? If you are, can you catch it? If not, then I don't see the point o...
2008/09/25
[ "https://Stackoverflow.com/questions/133958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40352/" ]
I'm calling some code that uses the BitmapData class from .NET. I've hit something where I can't find a definitive answer on Googlespace. Because it seems that LockBits and UnlockBits must always be called in a pair, I'm using this: ``` System.Drawing.Imaging.BitmapData tempImageData = tempImage.LockBits( ...
The try-finally pattern is correct. Since this is external code, you have no control over what exceptions are thrown, and the UnlockBits cleanup code needs to be executed regardless of what error has occurred.
133,973
<p>I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the <code>this</code> pointer is being used. From the behavior of the program, I have deduced that the <code>this</code> pointer is referring to...
[ { "answer_id": 134062, "author": "Rakesh Pai", "author_id": 20089, "author_profile": "https://Stackoverflow.com/users/20089", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Is this defined behavior? Is it\n cross-browser safe?</p>\n</blockquote>\n\n<p>Yes. And yes.</p>\n\...
2008/09/25
[ "https://Stackoverflow.com/questions/133973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10861/" ]
I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the `this` pointer is being used. From the behavior of the program, I have deduced that the `this` pointer is referring to the class on which the meth...
Cannibalized from another post of mine, here's more than you ever wanted to know about *this*. Before I start, here's the most important thing to keep in mind about Javascript, and to repeat to yourself when it doesn't make sense. Javascript does not have classes (ES6 `class` is [syntactic sugar](https://stackoverflow...
133,977
<p>In VB6, I used a call to the Windows API, <strong>GetAsyncKeyState</strong>, to determine if the user has hit the ESC key to allow them to exit out of a long running loop.</p> <pre><code>Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer </code></pre> <p>Is there an equivalent in pu...
[ { "answer_id": 134009, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 3, "selected": true, "text": "<p>You can find the P/Invoke declaration for GetAsyncKeyState from <a href=\"http://pinvoke.net/default.aspx/user32/Ge...
2008/09/25
[ "https://Stackoverflow.com/questions/133977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
In VB6, I used a call to the Windows API, **GetAsyncKeyState**, to determine if the user has hit the ESC key to allow them to exit out of a long running loop. ``` Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer ``` Is there an equivalent in pure .NET that does require a direct call...
You can find the P/Invoke declaration for GetAsyncKeyState from <http://pinvoke.net/default.aspx/user32/GetAsyncKeyState.html> Here's the C# signature for example: ``` [DllImport("user32.dll")] static extern short GetAsyncKeyState(int vKey); ```
133,988
<p>I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh about every 10 seconds on this page. One area of improvement that we found we could make with this function was to cache ...
[ { "answer_id": 134014, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 7, "selected": true, "text": "<p>Without putting my brain fully into gear, from a quick scan of what you say it looks as though you need to intern()...
2008/09/25
[ "https://Stackoverflow.com/questions/133988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I have a webapp that I am in the middle of doing some load/performance testing on, particularily on a feature where we expect a few hundred users to be accessing the same page and hitting refresh about every 10 seconds on this page. One area of improvement that we found we could make with this function was to cache the...
Without putting my brain fully into gear, from a quick scan of what you say it looks as though you need to intern() your Strings: ``` final String firstkey = "Data-" + email; final String key = firstkey.intern(); ``` Two Strings with the same value are otherwise not necessarily the same object. Note that this may i...
134,001
<p>I need to be able to load the entire contents of a text file and load it into a variable for further processing. </p> <p>How can I do that?</p> <hr> <p>Here's what I did thanks to Roman Odaisky's answer.</p> <pre><code>SetLocal EnableDelayedExpansion set content= for /F "delims=" %%i in (test.txt) do set conten...
[ { "answer_id": 134135, "author": "Roman Odaisky", "author_id": 21055, "author_profile": "https://Stackoverflow.com/users/21055", "pm_score": 5, "selected": true, "text": "<p>Use <code>for</code>, something along the lines of:</p>\n\n<pre><code>set content=\nfor /f \"delims=\" %%i in ('fi...
2008/09/25
[ "https://Stackoverflow.com/questions/134001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
I need to be able to load the entire contents of a text file and load it into a variable for further processing. How can I do that? --- Here's what I did thanks to Roman Odaisky's answer. ``` SetLocal EnableDelayedExpansion set content= for /F "delims=" %%i in (test.txt) do set content=!content! %%i echo %content...
Use `for`, something along the lines of: ``` set content= for /f "delims=" %%i in ('filename') do set content=%content% %%i ``` Maybe you’ll have to do `setlocal enabledelayedexpansion` and/or use `!content!` rather than `%content%`. I can’t test, as I don’t have any MS Windows nearby (and I wish you the same :-). ...
134,018
<p>I'm trying to create with Delphi a component inherited from TLabel, with some custom graphics added to it on TLabel.Paint. I want the graphics to be on left side of text, so I overrode GetClientRect:</p> <pre><code>function TMyComponent.GetClientRect: TRect; begin result := inherited GetClientRect; result.Left ...
[ { "answer_id": 134160, "author": "robsoft", "author_id": 3897, "author_profile": "https://Stackoverflow.com/users/3897", "pm_score": 0, "selected": false, "text": "<p>What methods/functionality are you getting from TLabel that you need this component to do?</p>\n\n<p>Would you perhaps be...
2008/09/25
[ "https://Stackoverflow.com/questions/134018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7735/" ]
I'm trying to create with Delphi a component inherited from TLabel, with some custom graphics added to it on TLabel.Paint. I want the graphics to be on left side of text, so I overrode GetClientRect: ``` function TMyComponent.GetClientRect: TRect; begin result := inherited GetClientRect; result.Left := 20; end; `...
First excuse-me for my bad English. I think it is not a good idea change the ClientRect of the component. This property is used for many internal methods and procedures so you can accidentally change the functionality/operation of that component. I think that you can change the point to write the text (20 pixels in...
134,034
<p>I have a custom login component in Flex that is a simple form that dispatches a custom LoginEvent when a user click the login button:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?> &lt;mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnLogin}"> &lt;mx:Metadata> [Event(name=...
[ { "answer_id": 134166, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 1, "selected": false, "text": "<p>ah! I figured it out...it was a big oversight on mine...it's just one of those days...</p>\n\n<p>I couldn't get the handl...
2008/09/25
[ "https://Stackoverflow.com/questions/134034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
I have a custom login component in Flex that is a simple form that dispatches a custom LoginEvent when a user click the login button: ``` <?xml version="1.0" encoding="utf-8"?> <mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" defaultButton="{btnLogin}"> <mx:Metadata> [Event(name="login",tpye="events.Lo...
ah! I figured it out...it was a big oversight on mine...it's just one of those days... I couldn't get the handle on my component because it was not yet created...I fixed this by simply waiting for the component's creationComplete event to fire and then add the event listener.
134,049
<p>Earlier this week I ask a question about filtering out duplicate values in sequence at run time. Had some good answers but the amount of data I was going over was to slow and not feasible.</p> <p>Currently in our database, event values are not filtered. Resulting in duplicate data values (with varying timestamps). ...
[ { "answer_id": 134234, "author": "mikeymo", "author_id": 4398, "author_profile": "https://Stackoverflow.com/users/4398", "pm_score": 1, "selected": false, "text": "<p>If I understand correctly, what you want to do is simply prevent the dupes from even getting in the database. If that is ...
2008/09/25
[ "https://Stackoverflow.com/questions/134049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20737/" ]
Earlier this week I ask a question about filtering out duplicate values in sequence at run time. Had some good answers but the amount of data I was going over was to slow and not feasible. Currently in our database, event values are not filtered. Resulting in duplicate data values (with varying timestamps). We need to...
Here's an update solution. Performance will vary depending on indexes. ``` DECLARE @MyTable TABLE ( DeviceName varchar(100), EventTime DateTime, OnOff int, GoodForRead int ) INSERT INTO @MyTable(DeviceName, OnOff, EventTime) SELECT 'F07331E4-26EC-41B6-BEC5-002AACA58337', 1, '2008-05-08 04:03:47.000' INSERT I...
134,058
<p>I need to alter the length of a column <code>column_length</code> in say more than 500 tables and the tables might have no of records ranging from 10 records to 3 or 4 million records.</p> <ol> <li>The column may just be a normal column</li> </ol> <pre><code>CREATE TABLE test(column_length varchar(10)) </code></pre>...
[ { "answer_id": 134966, "author": "J.J.", "author_id": 21204, "author_profile": "https://Stackoverflow.com/users/21204", "pm_score": 3, "selected": true, "text": "<p>Yes you should be able to just modify the columns. From my experience it is faster to leave the index and primary key in pl...
2008/09/25
[ "https://Stackoverflow.com/questions/134058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21968/" ]
I need to alter the length of a column `column_length` in say more than 500 tables and the tables might have no of records ranging from 10 records to 3 or 4 million records. 1. The column may just be a normal column ``` CREATE TABLE test(column_length varchar(10)) ``` 2. The column might contain non-clustered index...
Yes you should be able to just modify the columns. From my experience it is faster to leave the index and primary key in place.
134,068
<p>I'm trying to achieve the equivalent of a WinForms <code>ListView</code> with its <code>View</code> property set to <code>View.List</code>. Visually, the following works fine. The file names in my <code>Listbox</code> go from top to bottom, and then wrap to a new column.</p> <p>Here's the basic XAML I'm working wit...
[ { "answer_id": 135908, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 4, "selected": true, "text": "<p>It turns out that when it wraps around in my handling of the <code>KeyDown</code> event, selection changes to the co...
2008/09/25
[ "https://Stackoverflow.com/questions/134068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22211/" ]
I'm trying to achieve the equivalent of a WinForms `ListView` with its `View` property set to `View.List`. Visually, the following works fine. The file names in my `Listbox` go from top to bottom, and then wrap to a new column. Here's the basic XAML I'm working with: ``` <ListBox Name="thelist" IsSynchronizedWith...
It turns out that when it wraps around in my handling of the `KeyDown` event, selection changes to the correct item, but focus is on the old item. Here is the updated `KeyDown` eventhandler. Because of Binding, the `Items` collection returns my actual items rather than `ListBoxItem`s, so I have to do a call near the e...
134,099
<p>Let's say I have code like this:</p> <pre><code>$dbh = new PDO("blahblah"); $stmt = $dbh-&gt;prepare('SELECT * FROM users where username = :username'); $stmt-&gt;execute( array(':username' =&gt; $_REQUEST['username']) ); </code></pre> <p>The PDO documentation says:</p> <blockquote> <p>The parameters to prepare...
[ { "answer_id": 134137, "author": "JimmyJ", "author_id": 2083, "author_profile": "https://Stackoverflow.com/users/2083", "pm_score": 4, "selected": false, "text": "<p>Personally I would always run some form of sanitation on the data first as you can never trust user input, however when us...
2008/09/25
[ "https://Stackoverflow.com/questions/134099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
Let's say I have code like this: ``` $dbh = new PDO("blahblah"); $stmt = $dbh->prepare('SELECT * FROM users where username = :username'); $stmt->execute( array(':username' => $_REQUEST['username']) ); ``` The PDO documentation says: > > The parameters to prepared statements don't need to be quoted; the driver han...
The short answer is **YES**, PDO prepares are secure enough if used properly. --- I'm adapting [this answer](https://stackoverflow.com/a/12118602/338665) to talk about PDO... The long answer isn't so easy. It's based off an attack [demonstrated here](http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-esc...
134,103
<p>On occasion, I find myself wanting to search the text of changelist descriptions in Perforce. There doesn't appear to be a way to do this in P4V. I can do it by redirecting the output of the changes command to a file...</p> <pre><code>p4 changes -l &gt; p4changes.txt </code></pre> <p>...(the -l switch tells it t...
[ { "answer_id": 134183, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 4, "selected": false, "text": "<p>I use <a href=\"http://www.perforce.com/perforce/doc.current/manuals/p4report/01_install.html\" rel=\"noreferrer\">p4sql</a...
2008/09/25
[ "https://Stackoverflow.com/questions/134103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
On occasion, I find myself wanting to search the text of changelist descriptions in Perforce. There doesn't appear to be a way to do this in P4V. I can do it by redirecting the output of the changes command to a file... ``` p4 changes -l > p4changes.txt ``` ...(the -l switch tells it to dump the full text of the cha...
When the submitted changelist pane has focus, a CTRL+F lets you do an arbitrary text search, which includes changelist descriptions. The only limitation is that it searches just those changelists that have been fetched from the server, so you may need to up the number retrieved. This is done via the "Number of changel...
134,125
<p>I have three <code>divs</code>:</p> <pre><code>&lt;div id="login" /&gt; &lt;div id="content" /&gt; &lt;div id="menu" /&gt; </code></pre> <p>How would I define the CSS styles (without touching the HTML) to have the <code>menu-div</code> as the left column, the <code>login-div</code> in the right column and the ...
[ { "answer_id": 134162, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 4, "selected": true, "text": "<pre><code>#menu {\n position:absolute;\n top:0;\n left:0;\n width:100px;\n}\n#content, #login {\n margin-left:1...
2008/09/25
[ "https://Stackoverflow.com/questions/134125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9632/" ]
I have three `divs`: ``` <div id="login" /> <div id="content" /> <div id="menu" /> ``` How would I define the CSS styles (without touching the HTML) to have the `menu-div` as the left column, the `login-div` in the right column and the `content-div` also in the right column but below the `login-div`. The `width...
``` #menu { position:absolute; top:0; left:0; width:100px; } #content, #login { margin-left:120px; } ``` Why this way? The menu coming last in the markup makes it tough. You might also be able to float both content and login right, and added a clear:right to content, but I think this might be your best bet....