qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
154,469
<p>A feature of C++ is the ability to create unnamed (anonymous) namespaces, like so:</p> <pre><code>namespace { int cannotAccessOutsideThisFile() { ... } } // namespace </code></pre> <p>You would think that such a feature would be useless -- since you can't specify the name of the namespace, it's impossible to access anything within it from outside. But these unnamed namespaces <em>are</em> accessible within the file they're created in, as if you had an implicit using-clause to them.</p> <p>My question is, why or when would this be preferable to using static functions? Or are they essentially two ways of doing the exact same thing?</p>
[ { "answer_id": 154482, "author": "luke", "author_id": 16434, "author_profile": "https://Stackoverflow.com/users/16434", "pm_score": 10, "selected": true, "text": "static" }, { "answer_id": 155734, "author": "Community", "author_id": -1, "author_profile": "https://Stac...
2008/09/30
[ "https://Stackoverflow.com/questions/154469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
154,483
<p>I would like to do some condition formatting of strings. I know that you can do some conditional formatting of integers and floats as follows:</p> <pre><code>Int32 i = 0; i.ToString("$#,##0.00;($#,##0.00);Zero"); </code></pre> <p>The above code would result in one of three formats if the variable is positive, negative, or zero.</p> <p>I would like to know if there is any way to use sections on string arguments. For a concrete, but <strong>contrived</strong> example, I would be looking to replace the "if" check in the following code:</p> <pre><code>string MyFormatString(List&lt;String&gt; items, List&lt;String&gt; values) { string itemList = String.Join(", " items.ToArray()); string valueList = String.Join(", " values.ToArray()); string formatString; if (items.Count &gt; 0) //this could easily be: //if (!String.IsNullOrEmpty(itemList)) { formatString = "Items: {0}; Values: {1}"; } else { formatString = "Values: {1}"; } return String.Format(formatString, itemList, valueList); } </code></pre>
[ { "answer_id": 154487, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 1, "selected": false, "text": "formatString = (items.Count > 0) ? \"Items: {0}; Values: {1}\" : \"Values: {1}\";\n" }, { "answer_id": 154492, "au...
2008/09/30
[ "https://Stackoverflow.com/questions/154483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
154,485
<p>The title pretty much says it all. I want to create a SqlConnection and then check that connection without opening a database, cause at that point I don't know yet where will I connect to. Is it possible to do that? The SqlConnection class has a 'Open' member which tries to open the database you'd set in the Database property, and if you didn't set one, SqlServer tries with the master db. The thing is the user I'm trying to connect with (MACHINE\ASPNET) has access to some databases (which I don't know yet) and not the master db.</p> <p>Regards, Seba</p>
[ { "answer_id": 154527, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "SELECT HAS_DBACCESS('Northwind');\n" }, { "answer_id": 8276158, "author": "soni", "author_id": 1066540,...
2008/09/30
[ "https://Stackoverflow.com/questions/154485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23893/" ]
154,489
<p>I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off?</p>
[ { "answer_id": 154524, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "Encoding x = Encoding[28591]; // Equivalent to Encoding.GetEncoding(28591)\nEncoding y = Encoding[\"Foo\"]; // Equivalent...
2008/09/30
[ "https://Stackoverflow.com/questions/154489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
154,501
<p>I'm looking for a program that I can install on a Mac that will tell me how many bytes I download each day, and store that info in such a way that I could later view the results.</p> <p>Limiting by ports (80, 443, 21, 22) would be awesome as well.</p> <p>Does such a thing exist?</p>
[ { "answer_id": 155878, "author": "mike511", "author_id": 9593, "author_profile": "https://Stackoverflow.com/users/9593", "pm_score": 0, "selected": false, "text": "netstat -ib\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12930/" ]
154,502
<p>I'm having issues with color matching css background colors with colors in images on the same html page. What gives?</p>
[ { "answer_id": 154512, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "pngcrush" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489/" ]
154,533
<p>What is the best way to bind WPF properties to ApplicationSettings in C#? Is there an automatic way like in a Windows Forms Application? Similar to <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">this question</a>, how (and is it possible to) do you do the same thing in WPF?</p>
[ { "answer_id": 155585, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 2, "selected": false, "text": " public bool PlaySounds\n {\n get { return (bool)GetValue(PlaySoundsProperty); }\n set { SetValue(PlaySo...
2008/09/30
[ "https://Stackoverflow.com/questions/154533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
154,535
<p>I have used Photoshop CS2's "Save for Web" feature to create a table of images for my site layout.</p> <p>This HTML appears fine in a web browser, however when imported into Visual Studio and viewed in the site designer, the metrics are wrong and there are horizontal gaps between images (table cells).</p> <p>The output from Photoshop does not refer to any stylesheets.<br> The table attributes set border, cellpadding and cellspacing to 0.</p> <p>Here is how it looks in the Designer:</p> <p><img src="https://sites.google.com/site/sizerfx/Home/layout1.png?attredirects=0" alt="alt text"></p> <p>And here is how it looks in the browser:</p> <p><img src="https://sites.google.com/site/sizerfx/Home/layout2.png?attredirects=0" alt="alt text"></p> <p>Is Visual Studio picky about layout of tables and images? Is this a bug in Visual Studio 2005?</p>
[ { "answer_id": 155585, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 2, "selected": false, "text": " public bool PlaySounds\n {\n get { return (bool)GetValue(PlaySoundsProperty); }\n set { SetValue(PlaySo...
2008/09/30
[ "https://Stackoverflow.com/questions/154535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/414107/" ]
154,536
<p>Does anyone know of any good C++ code that does this?</p>
[ { "answer_id": 4823686, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "string urlDecode(string &SRC) {\n string ret;\n char ch;\n int i, ii;\n for (i=0; i<SRC.length(); i++) {\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2033811/" ]
154,538
<p>Long story short, I need to put some text in my Flex application and I don't want users to be able to copy. I was going to use a label, but apparently labels do not support text wrapping. Can I make it so that users cannot select text in a Flex Text control?</p> <p>Thanks.</p>
[ { "answer_id": 154848, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 0, "selected": false, "text": "print(\"\n <mx:Text enabled=\"false\" disabledColor=\"0x000000\" text=Text\"/>\n\");\n" }, { "answer_id": 1...
2008/09/30
[ "https://Stackoverflow.com/questions/154538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
154,543
<p>If you create a panel on a form and set it to Dock=Top and drop another panel and set its Dock=Fill, it may fill the entire form, ignoring the first panel. Changing the tab order does nothing.</p>
[ { "answer_id": 28459277, "author": "Pandichie Anton-Valentin", "author_id": 1561462, "author_profile": "https://Stackoverflow.com/users/1561462", "pm_score": 3, "selected": false, "text": "DockStyle.Fill" }, { "answer_id": 45008286, "author": "Marcus", "author_id": 672939...
2008/09/30
[ "https://Stackoverflow.com/questions/154543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2277/" ]
154,551
<p>Let's say that a class has a <code>public int counter</code> field that is accessed by multiple threads. This <code>int</code> is only incremented or decremented.</p> <p>To increment this field, which approach should be used, and why?</p> <ul> <li><code>lock(this.locker) this.counter++;</code>,</li> <li><code>Interlocked.Increment(ref this.counter);</code>,</li> <li>Change the access modifier of <code>counter</code> to <code>public volatile</code>.</li> </ul> <p>Now that I've discovered <code>volatile</code>, I've been removing many <code>lock</code> statements and the use of <code>Interlocked</code>. But is there a reason not to do this?</p>
[ { "answer_id": 154582, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": false, "text": "Interlocked" }, { "answer_id": 154590, "author": "Michael Damatov", "author_id": 23372, "author_prof...
2008/09/30
[ "https://Stackoverflow.com/questions/154551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
154,554
<p>I'm writing a simple web service using Microsoft Visual Web Developer 2005 (Express Edition), and the dynamically generated WSDL has a minOccurs="0" for all the parameters. </p> <p>How do I get minOccurs="1" for the required parameters without resorting to creating a static WSDL file?</p> <p>I need to do this <strong>using a ASP.NET Web Service</strong> (.NET v2). So, no WCF.</p>
[ { "answer_id": 189317, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 2, "selected": false, "text": "XmlElement(IsNullable = true)" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23899/" ]
154,577
<p>In terms of Java, when someone asks: </p> <blockquote> <p>what is polymorphism?</p> </blockquote> <p>Would <strong>overloading</strong> or <strong>overriding</strong> be an acceptable answer?</p> <p>I think there is a bit more to it than that. </p> <p><em>IF you had a abstract base class that defined a method with no implementation, and you defined that method in the sub class, is that still overridding?</em></p> <p>I think <strong>overloading</strong> is not the right answer for sure.</p>
[ { "answer_id": 154594, "author": "Clyde", "author_id": 945, "author_profile": "https://Stackoverflow.com/users/945", "pm_score": 2, "selected": false, "text": "public int DoSomething(int objectId) { ... }\npublic int DoSomething(string objectName) { ... }\n" }, { "answer_id": 154...
2008/09/30
[ "https://Stackoverflow.com/questions/154577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
154,597
<p>Note, I realize that this has been addressed <a href="https://stackoverflow.com/questions/944/unhandled-exception-handler-in-net-11">here</a>. That post discusses exception handling in .NET 1.1 while implying that there is a better solution for >.NET 2.0 so this question is specifically about the more recent .NET versions.</p> <p>I have a windows forms application which is expected to frequently and unexpectedly lose connectivity to the database, in which case it is to reset itself to its initial state.</p> <p>I am already doing error logging, retry connection, etc. through a set of decorators on my custom DBWrapper object. After that is taken care of however, I would like to let the error fall through the stack. Once it reaches the top and is unhandled I would like it to be swallowed and my ApplicationResetter.Reset() method to be executed.</p> <p>Can anyone tell me how to do this?</p> <p>If this is impossible, then is there at least a way to handle this without introducing a dependency on ApplicationResetter to every class which might receive such an error and without actually shutting down and restarting my application (which would just look ugly)?</p>
[ { "answer_id": 154656, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 1, "selected": false, "text": "static void Main()\n{\n Application.ThreadException += Application_ThreadException;\n //...\n }\n\n static void A...
2008/09/30
[ "https://Stackoverflow.com/questions/154597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
154,598
<p>IO.popen() and system() in Ruby is sorely lacking several useful features, such as:</p> <ul> <li>obtaining the return value of the function</li> <li>capturing both stdout and stderr (seperately and merged)</li> <li>running without spawning an extra cmd.exe or /bin/sh process</li> </ul> <p>Python has a module "subprocess" which I was thinking about using as inspiration for a similar module in Ruby. Now to the questions:</p> <ul> <li>How are Ruby-programmers working around the issues above, for example obtaining the return value when doing a popen() call?</li> <li>Is this something which has already been implemented?</li> </ul>
[ { "answer_id": 154703, "author": "Priit", "author_id": 22964, "author_profile": "https://Stackoverflow.com/users/22964", "pm_score": 3, "selected": false, "text": "$?.exitstatus" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13051/" ]
154,625
<p>I've noticed that sometimes wrapper scripts will use <code>${1:+"$@"}</code> for the parameters rather than just <code>"$@"</code>.</p> <p>For example, <a href="http://svn.macosforge.org/repository/macports/trunk/dports/editors/vim-app/files/gvim.sh" rel="noreferrer">http://svn.macosforge.org/repository/macports/trunk/dports/editors/vim-app/files/gvim.sh</a> uses</p> <pre><code>exec "$binary" $opts ${1:+"$@"} </code></pre> <p>Can anyone break <code>${1:+"$@"}</code> down into English and explain why it would be an advantage over plain <code>"$@"</code>?</p>
[ { "answer_id": 154637, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 2, "selected": false, "text": " ${parameter:+word}\n Use Alternate Value. If parameter is null or unset, nothing is\n substituted, ...
2008/09/30
[ "https://Stackoverflow.com/questions/154625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
154,630
<p>Other than <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall" rel="nofollow noreferrer">-Wall</a>, what other warnings have people found useful?</p> <p><em><a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html" rel="nofollow noreferrer">Options to Request or Suppress Warnings</a></em></p>
[ { "answer_id": 154851, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 6, "selected": false, "text": "gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual \\\n -Wstrict-prototypes -Wmissing-prot...
2008/09/30
[ "https://Stackoverflow.com/questions/154630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9831/" ]
154,636
<p>At the moment we use <a href="http://www.hsqldb.org/" rel="noreferrer">HSQLDB</a> as an embedded database, but we search for a database with less memory footprint as the data volume grows.</p> <p><a href="http://developers.sun.com/javadb/" rel="noreferrer">Derby / JavaDB</a> is not an option at the moment because it stores properties globally in the system properties. So we thought of <a href="http://www.h2database.com/html/main.html" rel="noreferrer">h2</a>.</p> <p>While we used HSQLDB we created a Server-object, set the parameters and started it. This is described <a href="http://hsqldb.org/doc/guide/ch04.html#N10BBC" rel="noreferrer">here</a> (and given as example in the class org.hsqldb.test.TestBase).</p> <p>The question is: Can this be done analogous with the h2 database, too? Do you have any code samples for that? Scanning the h2-page, I did not find an example.</p>
[ { "answer_id": 155237, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 6, "selected": true, "text": "import org.h2.tools.Server;\n...\n// start the TCP Server\nServer server = Server.createTcpServer(args).start();\n...\n// st...
2008/09/30
[ "https://Stackoverflow.com/questions/154636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13209/" ]
154,652
<p>Is anyone out there still using DataFlex? If so, what are you favorite tips and tricks for this venerable 4GL?</p>
[ { "answer_id": 155555, "author": "seanyboy", "author_id": 1726, "author_profile": "https://Stackoverflow.com/users/1726", "pm_score": 3, "selected": true, "text": "clear orders\nmove const.complete to orders.status\nfind ge orders by index.2\nrepeat\n if orders.status ne const.complet...
2008/09/30
[ "https://Stackoverflow.com/questions/154652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
154,655
<p>We have a VXML project that a 3rd party parses to provide us with a phone navigation system. We require them to enter an id code to leave a message, which is later reviewed by our company.</p> <p>We currently have this working as follows:</p> <pre><code>Response.Cache.SetCacheability(HttpCacheability.NoCache); Stream m = new MemoryStream(); //Create Memory Stream - Used to create XML document in Memory XmlTextWriter XML_Writer = new XmlTextWriter(m, System.Text.Encoding.UTF8); XML_Writer.Formatting = Formatting.Indented; XML_Writer.WriteStartDocument(); /* snip - writing a valid XML document */ XML_Writer.WriteEndDocument(); XML_Writer.Flush(); m.Position = 0; byte[] b = new byte[m.Length]; m.Read(b, 0, (int)m.Length); XML_Writer.Close(); HttpContext.Current.Response.Write(System.Text.Encoding.UTF8.GetString(b, 0, b.Length)); </code></pre> <p>I'm just maintaining this app, I didn't write it...but the end section seems convoluted to me.</p> <p>I know it's taking the output stream and feeding the written XML into it...but why is it first reading the entire string? Isn't that inefficient?</p> <p>Is there a better way to write the above code?</p>
[ { "answer_id": 154684, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 2, "selected": true, "text": "Output" }, { "answer_id": 154700, "author": "Boaz", "author_id": 2892, "author_profile": "https://St...
2008/09/30
[ "https://Stackoverflow.com/questions/154655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23902/" ]
154,661
<p>Due to the legacy nature of some of our code, we're still using Microsoft Visual 6.0 (SP6). When I attach to a running process to debug it for the first time, it has no knowledge of where the source files are located when I break into the process. It therefore asks me to navigate to the appropriate directory in my source tree, given a source file name. It remembers these directories, so I don't have to enter the same directory twice, but it's still painful.</p> <p>Is there a way of pre-configuring VC6 with all the source file directories in my tree? Note that our project is built using makefiles (using nmake), rather than via DSPs.</p>
[ { "answer_id": 173240, "author": "Jason Etheridge", "author_id": 2193, "author_profile": "https://Stackoverflow.com/users/2193", "pm_score": 0, "selected": false, "text": "REGEDIT4\n\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Devstudio\\6.0\\Build\nSystem\\Components\\Platforms\\Win32 (x8...
2008/09/30
[ "https://Stackoverflow.com/questions/154661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2193/" ]
154,672
<p>I asked a question about Lua perfromance, and on of the <a href="https://stackoverflow.com/questions/124455/how-do-you-pre-size-an-array-in-lua#152894">responses</a> asked:</p> <blockquote> <p>Have you studied general tips for keeping Lua performance high? i.e. know table creation and rather reuse a table than create a new one, use of 'local print=print' and such to avoid global accesses.</p> </blockquote> <p>This is a slightly different question from <a href="https://stackoverflow.com/questions/89523/lua-patternstips-and-tricks">Lua Patterns,Tips and Tricks</a> because I'd like answers that specifically impact performance and (if possible) an explanation of why performance is impacted.</p> <p>One tip per answer would be ideal.</p>
[ { "answer_id": 12865406, "author": "dualed", "author_id": 1244588, "author_profile": "https://Stackoverflow.com/users/1244588", "pm_score": 7, "selected": true, "text": "do\n x = gFoo + gFoo;\nend\ndo -- this actually performs better.\n local lFoo = gFoo;\n x = lFoo + lFoo;\nend\n" ...
2008/09/30
[ "https://Stackoverflow.com/questions/154672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
154,680
<p>How would I create the equivalent Linq To Objects query?</p> <pre><code>SELECT MIN(CASE WHEN p.type = "In" THEN p.PunchTime ELSE NULL END ) AS EarliestIn, MAX(CASE WHEN p.type = "Out" THEN p.PunchTime ELSE NULL END ) AS LatestOUt FROM Punches p </code></pre>
[ { "answer_id": 155059, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": " List<int> myInts = new List<int>() { 1, 4, 2, 0, 3 };\n var y = myInts.Aggregate(\n new { Min = int.MaxValue, Ma...
2008/09/30
[ "https://Stackoverflow.com/questions/154680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6819/" ]
154,686
<p>I've got a stock Debian Etch system, using Exim4. The domains are mostly local but there are some that are remote. To handle the delivery of remote mail I use the Debian configuration file:</p> <pre><code> /etc/exim4/hubbed_hosts </code></pre> <p>This file lists the domain names, and remote MX machines to deliver to. For example:</p> <pre><code> example.org: mx.example.com example.com: mx2.example.com </code></pre> <p>Looking at the exim4 configuration file I see that this used as follows:</p> <pre><code>hubbed_hosts: debug_print = "R: hubbed_hosts for $domain" driver = manualroute domains = "${if exists{CONFDIR/hubbed_hosts}\ {partial-lsearch;CONFDIR/hubbed_hosts}\ fail}" route_data = ${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}} transport = remote_smtp </code></pre> <p>The issue I have is that <em>some</em> of the hosts I'm using need to have their mail delivered to a non-standard port. Unfortunately the Debian hubbed_hosts file doesn't work if I try to change it to include a port:</p> <pre><code>example.org: mx1.example.org:2525 example.com: 1.2.3.4.2525 </code></pre> <p>Is it possible to dynamically allow the port to be specified?</p>
[ { "answer_id": 154711, "author": "manicmethod", "author_id": 12098, "author_profile": "https://Stackoverflow.com/users/12098", "pm_score": 1, "selected": false, "text": "remote_hub_2525:\ndriver = smtp\nport = 2525\n" }, { "answer_id": 154796, "author": "Community", "auth...
2008/09/30
[ "https://Stackoverflow.com/questions/154686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
154,697
<p>I'm trying to retrieve numeric values from a <code>DataGridView</code>. So far, the only way I've found is to retrieve them as a string and convert them to numeric.</p> <pre><code>Convert.ToDouble(MyGrid.SelectedRows[0].Cells[0].Value.ToString()); </code></pre> <p>There must be an easier way. The cell is originally populated from a <code>DataSet</code> with a numeric field value but since the <code>DataGridViewCell</code> object returns it as an object, I can't do a straight assignment. I must be missing something simple here.</p> <p>Thanks.</p>
[ { "answer_id": 154825, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 0, "selected": false, "text": "Convert.ToDouble" }, { "answer_id": 154945, "author": "Vivek", "author_id": 7418, "author_profile": ...
2008/09/30
[ "https://Stackoverflow.com/questions/154697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
154,698
<p>In java, I could do this with the 'final' keyword. I don't see 'final' in C#. Is there a substitute?</p>
[ { "answer_id": 154699, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 6, "selected": true, "text": "sealed" }, { "answer_id": 154770, "author": "Nasir", "author_id": 16522, "author_profile": "https://Sta...
2008/09/30
[ "https://Stackoverflow.com/questions/154698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18931/" ]
154,702
<p>We are using the MVC framework (release 5) and the CrystalReportViewer control to show our reports. I cannot get any of the buttons at the top of the report viewer control to work.</p> <p>If I'm working with the report 'HoursSummary'. If I hover over any of the buttons on the report viewer in IE the displayed link at the bottom of the pages is '../HoursSummary'. This creates a url of '<a href="http://localhost/HoursSummary" rel="noreferrer">http://localhost/HoursSummary</a>'. There is no 'HoursSummary' controller so I keep receiving 404 errors.</p> <ul> <li>I believe I want to redirect to '<a href="http://localhost/reports/HoursSummary" rel="noreferrer">http://localhost/reports/HoursSummary</a>' since I do have a reports controller. If this is the correct method does anyone know which property I should set on the CrystalReportViewer control to make that happen?</li> <li>Is there an easier method to handle this situation?</li> </ul>
[ { "answer_id": 154699, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 6, "selected": true, "text": "sealed" }, { "answer_id": 154770, "author": "Nasir", "author_id": 16522, "author_profile": "https://Sta...
2008/09/30
[ "https://Stackoverflow.com/questions/154702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7561/" ]
154,706
<p>Unfortunately, there seems to be no string.Split(string separator), only string.Split(char speparator).</p> <p>I want to break up my string based on a multi-character separator, a la VB6. Is there an easy (that is, not by referencing Microsoft.VisualBasic or having to learn RegExes) way to do this in c#?</p> <p>EDIT: Using .NET Framework 3.5.</p>
[ { "answer_id": 154716, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": ".Split(string[] separator, StringSplitOptions options) \n.Split(string[] separator, int count, StringSplitOptions opt...
2008/09/30
[ "https://Stackoverflow.com/questions/154706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
154,707
<p>I want to store a large number of sound files in a database, but I don't know if it is a good practice. I would like to know the pros and cons of doing it in this way.</p> <p>I also thought on the possibility to have "links" to those files, but maybe this will carry more problems than solutions. Any experience in this direction will be welcome :)</p> <p>Note: The database will be MySQL.</p>
[ { "answer_id": 154793, "author": "CMPalmer", "author_id": 14894, "author_profile": "https://Stackoverflow.com/users/14894", "pm_score": 3, "selected": false, "text": "C:\\MyProgram\\Data\\Sounds\\X\\XYZ.Wav\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19689/" ]
154,708
<p>Ok, Regex wizards. I want to be able to search through my logfile and find any sessions with the word 'error' in it and then return the entire session log entry.</p> <p>I know I can do this with a string/array but I'd like to learn how to do it with Regex but here's the question. If I decide to do this with Regex do I <a href="http://www.codinghorror.com/blog/archives/001016.html" rel="nofollow noreferrer">have one or two problems</a>? ;o)</p> <p>Here's the log:</p> <p>PS: I'm using the perl Regex engine.</p> <p><strong>Note</strong>: I don't think I can get this done in Regex. In other words, I now have two problems. ;o) I've tried the solutions below but, since I've confused the issue by stating that I was using a Perl engine, many of the answers were in Perl (which cannot be used in my case). I did however post my solution below.</p> <hr> <pre><code>2008.08.27 08:04:21 (Wed)------------Start of Session----------------- Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19) Sending stdin.txt to foo@bar.com Subject: test 1 Login name is foo@bar.com The SMTP server does not require AUTH LOGIN. Are you sure server supports AUTH? The SMTP server does not like the sender name. Have you set your mail address correctly? 2008.08.27 08:04:24 (Wed)-------------End of Session------------------ 2008.08.27 08:05:56 (Wed)------------Start of Session----------------- Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19) Error: Wait a bit (possible timeout). SMTP server error Error: Not a socket. Error: Not a socket. 2008.08.27 08:06:26 (Wed)-------------End of Session------------------ 2008.08.27 08:07:58 (Wed)------------Start of Session----------------- Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19) Sending stdin.txt to foo@bar.com Subject: Lorem Update 08/27/2008 Login name is foo@bar.com 2008.08.27 08:07:58 (Wed)-------------End of Session------------------ </code></pre>
[ { "answer_id": 154743, "author": "Kyle", "author_id": 2237619, "author_profile": "https://Stackoverflow.com/users/2237619", "pm_score": 3, "selected": false, "text": "\nperl -ne 'BEGIN{$/=\"\"} print if /error/i' < logfile\n" }, { "answer_id": 154886, "author": "moritz", ...
2008/09/30
[ "https://Stackoverflow.com/questions/154708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
154,718
<p>My web application sends email fairly often, and it sends 3 kinds of emails: initiated by user, in response to an event in the system, and in automatic response to an email received by the application.</p> <p>I would like to make sure that the third type of email does not get stuck in an endless loop of auto-responders talking to each other. Currently, I use the header:</p> <pre><code>Precedence: junk </code></pre> <p>but Yahoo! mail is treating these messages as spam. This is obviously not ideal, because we would like SOMEBODY to read our auto-response and make a decision on it, just not an out-of-office reply.</p> <p><strong>What is the best way to send an email without triggering either junk filters or auto-responders?</strong></p> <pre><code>Precedence: junk? Precedence: bulk? Precedence: list? X-Priority: 2? </code></pre>
[ { "answer_id": 154794, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 5, "selected": true, "text": "Return-Path: <>\n" }, { "answer_id": 301958, "author": "user38936", "author_id": 38936, "author_profile": "h...
2008/09/30
[ "https://Stackoverflow.com/questions/154718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3140/" ]
154,722
<p>I've recently come across a feature of doing a large query in oracle, where changing one thing resulted in a query that used to take 10 minutes taking 3 hours.</p> <p>To briefly summarise, I store a lot of coordinates in the database, with each coordinate having a probability. I then want to 'bin' these coordinates into 50 metre bins (basically round the coordinate down to the nearest 50 metres) and sum the probability.</p> <p>To do this, part of the query is 'select x,y,sum(probability) from .... group by x,y'</p> <p>Initially I was storing a large number of points with a probability of 0.1 and queries were running reasonably ok, taking about 10 minutes for each one.</p> <p>Then I had a request to change how the probabilities were calculated to adjust the distribution, so rather than all of them being 0.1, they were different values (e.g. 0.03, 0.06, 0.12, 0.3, 0.12, 0.06, 0.03). Running exactly the same query resulted in queries of about 3 hours.</p> <p>Changing back to all 0.1 brought the queries back to 10 minutes.</p> <p>Looking at the query plan and performance of the system, it looked like the problem was with the 'hash group' functionality designed to speed up grouping in oracle. I'm guessing that it was creating hash entries for each unique x,y,probability value and then summing probability for each unique x,y value.</p> <p>Can anyone explain this behaviour any better? </p> <p><strong>Additional Info</strong></p> <p>Thanks to the answers. They allowed me to verify what was going on. I'm currently running a query and the tempseg_size from v$sql_workarea_active is currently at 7502561280 and growing rapidly.</p> <p>Given that the development server I'm running on only has 8gb of ram, it looks like the query needs to use temporary tables. </p> <p>I've managed to workaround this for now by changing the types of queries and precalculating some of the information.</p>
[ { "answer_id": 156072, "author": "David Aldridge", "author_id": 6742, "author_profile": "https://Stackoverflow.com/users/6742", "pm_score": 2, "selected": false, "text": "explain plan for\nselect x,y,sum(probability) from .... group by x,y\n/\n\nselect * from table(dbms_xplan.display)\n/...
2008/09/30
[ "https://Stackoverflow.com/questions/154722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5932/" ]
154,724
<p>The use of weak references is something that I've never seen an implementation of so I'm trying to figure out what the use case for them is and how the implementation would work. When have you needed to use a <code>WeakHashMap</code> or <code>WeakReference</code> and how was it used?</p>
[ { "answer_id": 155312, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 3, "selected": false, "text": "private static IdMutexProvider MUTEX_PROVIDER = new IdMutexProvider();\n\npublic void performTask(String resourceId) {\n I...
2008/09/30
[ "https://Stackoverflow.com/questions/154724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12662/" ]
154,730
<p>I am supposed to provide my users a really simple way of capturing video clips out of my OpenGL application's main window. I am thinking of adding buttons and/or keyboard shortcuts for starting and stopping the capture; when starting, I could ask for a filename and other options, if any. It has to run in Windows (XP/Vista), but I also wouldn't like to close the Linux door which I've so far been able to keep open.</p> <p>The application uses OpenGL fragment and shader programs, the effects due to which I absolutely need to have in the eventual videos.</p> <p>It looks to me like there might be even several different approaches that could potentially fulfill my requirements (but I don't really know where I should start):</p> <ul> <li><p>An encoding library with functions like startRecording(filename), stopRecording, and captureFrame. I could call captureFrame() after every frame rendered (or every second/third/whatever). If doing so makes my program run slower, it's not really a problem.</p></li> <li><p>A standalone external program that can be programmatically controlled from my application. After all, a standalone program that can <em>not</em> be controlled almost does what I need... But as said, it should be really simple for the users to operate, and I would appreciate seamlessness as well; my application typically runs full-screen. Additionally, it should be possible to distribute as part of the installation package for my application, which I currently prepare using NSIS.</p></li> <li><p>Use the Windows API to capture screenshots frame-by-frame, then employ (for example) one of the <a href="https://stackoverflow.com/questions/93954/how-to-programatically-create-videos">libraries mentioned here</a>. It seems to be easy enough to find examples of how to capture screenshots in Windows; however, I would love a solution which doesn't really force me to get my hands super-dirty on the WinAPI level.</p></li> <li><p>Use OpenGL to render into an offscreen target, then use a library to produce the video. I don't know if this is even possible, and I'm afraid it might not be the path of least pain anyway. In particular, I would not like the actual rendering to take a different execution path depending on whether video is being captured or not. Additionally, I would avoid anything that might decrease the frame rate in the normal, non-capture mode.</p></li> </ul> <p>If the solution were free in either sense of the word, then that would be great, but it's not really an absolute requirement. In general, the less bloat there is, the better. On the other hand, for reasons beyond this question, I cannot link in any GPL-only code, unfortunately.</p> <p>Regarding the file format, I cannot expect my users to start googling for any codecs, but as long as also <em>displaying</em> the videos is easy enough for a basic-level Windows user, I don't really care what the format is. However, it would be great if it were possible to control the compression quality of the output.</p> <p>Just to clarify: I <em>don't</em> need to capture video from an external device like camcorder, nor am I really interested in mouse movements, even though getting them does not harm either. There are no requirements regarding audio; the application makes no noise whatsoever.</p> <p>I write C++ using Visual Studio 2008, for this very application also taking benefit of GLUT and GLUI. I have a solid understanding regarding C++ and linking in libraries and that sort of stuff, but on the other hand OpenGL is quite new for me: so far, I've really only learnt the necessary bits to actually get my job done.</p> <p>I don't need a solution super-urgently, so feel free to take your time :)</p>
[ { "answer_id": 155043, "author": "Reunanen", "author_id": 19254, "author_profile": "https://Stackoverflow.com/users/19254", "pm_score": 1, "selected": false, "text": "glReadPixels" }, { "answer_id": 18703223, "author": "tommy chheng", "author_id": 337493, "author_prof...
2008/09/30
[ "https://Stackoverflow.com/questions/154730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19254/" ]
154,754
<p>I would find out the <em>floppy inserted state</em>:</p> <ul> <li>no floppy inserted</li> <li>unformatted floppy inserted</li> <li>formatted floppy inserted</li> </ul> <p>Can this determined using "WMI" in the System.Management namespace?</p> <p>If so, can I generate events when the <em>floppy inserted state</em> changes? </p>
[ { "answer_id": 163970, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 2, "selected": false, "text": "strComputer = \".\"\nSet objWMIService = GetObject( _\n \"winmgmts:\\\\\" & strComputer & \"\\root\\cimv2\")\nSet colIte...
2008/09/30
[ "https://Stackoverflow.com/questions/154754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14841/" ]
154,762
<p>I need to create XML in Perl. From what I read, <a href="http://search.cpan.org/dist/XML-LibXML" rel="noreferrer">XML::LibXML</a> is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is <a href="http://search.cpan.org/dist/XML-Writer" rel="noreferrer">XML::Writer</a> still maintained? Does anyone like/use it?</p> <p>In addition to feature-completeness, I am interested an easy-to-use syntax, so please describe the syntax and any other reasons why you like that module in your answer.</p> <p>Please respond with one suggestion per answer, and if someone has already answered with your favorite, please vote that answer up. Hopefully it will be easy to see what is most popular.</p> <p>Thanks!</p>
[ { "answer_id": 155010, "author": "Yanick", "author_id": 10356, "author_profile": "https://Stackoverflow.com/users/10356", "pm_score": 6, "selected": true, "text": "use XML::Writer;\n\nmy $writer = new XML::Writer(); # will write to stdout\n$writer->startTag(\"greeting\", \n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
154,791
<p>I'm writing a Java Tree in which tree nodes could have children that take a long time to compute (in this case, it's a file system, where there may be network timeouts that prevent getting a list of files from an attached drive).</p> <p>The problem I'm finding is this:</p> <ol> <li><p><code>getChildCount()</code> is called before the user specifically requests opening a particular branch of the tree. I believe this is done so the <code>JTree</code> knows whether to show a + icon next to the node.</p></li> <li><p>An accurate count of children from <code>getChildCount()</code> would need to perform the potentially expensive operation </p></li> <li><p>If I fake the value of <code>getChildCount()</code>, the tree only allocates space for that many child nodes before asking for an enumeration of the children. (If I return '1', I'll only see 1 child listed, despite that there are more)</p></li> </ol> <p>The enumeration of the children can be expensive and time-consuming, I'm okay with that. But I'm not okay with <code>getChildCount()</code> needing to know the exact number of children.</p> <p>Any way I can work around this?</p> <p><strong>Added:</strong> The other problem is that if one of the nodes represents a floppy drive (how archaic!), the drive will be polled before the user asks for its files; if there's no disk in the drive, this results in a system error.</p> <p><strong>Update:</strong> Unfortunately, implementing the <code>TreeWillExpand</code> listener isn't the solution. That can allow you to veto an expansion, but the number of nodes shown is still restricted by the value returned by <code>TreeNode.getChildCount()</code>.</p>
[ { "answer_id": 155063, "author": "Aleksandar Dimitrov", "author_id": 11797, "author_profile": "https://Stackoverflow.com/users/11797", "pm_score": 0, "selected": false, "text": "n0" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
154,837
<p>We have an "engine" that loads dlls dynamically (whatever is located in a certain directory) and calls Workflow classes from them by way of reflection.</p> <p>We now have some new Workflows that require access to a database, so I figured that I would put a config file in the dll directory.</p> <p>But for some reason my Workflows just don't see the config file.</p> <pre><code>&lt;configuration&gt; &lt;appSettings&gt; &lt;add key="ConnectString" value="Data Source=officeserver;Database=mydatabase;User ID=officeuser;Password=officeuser;" /&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>Given the above config file, the following code prints an empty string:</p> <pre><code>Console.WriteLine(ConfigurationManager.AppSettings["ConnectString"]); </code></pre> <p>I think what I want is to just specify a config filename, but I'm having problems here. I'm just not getting results. Anyone have any pointers?</p>
[ { "answer_id": 154914, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<applicationSettings>\n <MyLibrary.My.MySettings>\n <setting name=\"SomeSetting\" serializeAs=\"String\">\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23597/" ]
154,842
<p>I posted an answer to <a href="https://stackoverflow.com/questions/154706">this question</a>, including a very short rant at the end about how String.Split() should accept IEnumerable&lt;string> rather than string[]. </p> <p>That got me thinking. What if the base Object class from which everything else inherits provided a default implementation for IEnumerable such that everything now returns an Enumerator over exactly one item (itself) -- unless it's overridden to do something else like with collections classes.</p> <p>The idea is that then if methods like String.Split() did accept IEnumerable rather than an array I could pass a single string to the function and it would just work, rather than having to much about with creating a separator array.</p> <p>I'm sure there are all kinds of reasons not to do this, not the least of which is that if everything implemented IEnumerable, then the few classes where the implementation strays from the default could behave differently than you'd expect in certain scenarios. But I still thought it would be a fun exercise: what other consequences would there be?</p>
[ { "answer_id": 154932, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "public static IEnumerable<object> ToEnumerable(this object someObject)\n{\n return System.Linq.Enumerable.Repeat(someObject...
2008/09/30
[ "https://Stackoverflow.com/questions/154842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
154,845
<p>I have a DataRow and I am getting one of the elements which is a Amount with a dollar sign. I am calling a toString on it. Is there another method I can call on it to remove the dollar sign if present. </p> <p><strong>So something like:</strong></p> <p><em>dr.ToString.Substring(1, dr.ToString.Length);</em></p> <p>But more conditionally in case the dollar sign ever made an appearance again.</p> <p>I am trying to do this with explicitly defining another string.</p>
[ { "answer_id": 154857, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 5, "selected": true, "text": "Convert.ToString(dr(columnName)).Replace(\"$\", String.Empty)\n" }, { "answer_id": 154956, "author": "Shaun ...
2008/09/30
[ "https://Stackoverflow.com/questions/154845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
154,846
<p>I'm looking for a way to create an online form that will update an Access database that has just a few tables. Does anyone know of a simple solution for this?</p>
[ { "answer_id": 154857, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 5, "selected": true, "text": "Convert.ToString(dr(columnName)).Replace(\"$\", String.Empty)\n" }, { "answer_id": 154956, "author": "Shaun ...
2008/09/30
[ "https://Stackoverflow.com/questions/154846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6958/" ]
154,853
<p>I have a folder, <code>c:\websites\test</code>, and it contains folders and files that were checked out from a repository that no longer exists. How do I get Subversion to stop tracking that folder and any of the subfolders and files? </p> <p>I know I could simply delete the <code>.svn</code> folder, but there are a lot of sub-folders in many layers.</p>
[ { "answer_id": 154860, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 7, "selected": false, "text": "svn export /path/to/old/working/copy /path/to/plain/code\n" }, { "answer_id": 154874, "author": "1800 INFORMATI...
2008/09/30
[ "https://Stackoverflow.com/questions/154853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
154,862
<p>How can I convert a JavaScript string value to be in all lower case letters?</p> <p>Example: <code>&quot;Your Name&quot;</code> to <code>&quot;your name&quot;</code></p>
[ { "answer_id": 154882, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 5, "selected": false, "text": "toLowerCase()" }, { "answer_id": 154891, "author": "John Topley", "author_id": 1450, "author_profile": ...
2008/09/30
[ "https://Stackoverflow.com/questions/154862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5440/" ]
154,897
<p>Did you ever had a bug in your code, you could not resolve? I hope I'm not the only one out there, who made this experience ...</p> <p>There exist some classes of bugs, that are very hard to track down:</p> <ul> <li><strong>timing-related bugs</strong> (that occur during inter-process-communication for example)</li> <li><strong>memory-related bugs</strong> (most of you know appropriate examples, I guess !!!)</li> <li><strong>event-related bugs</strong> (hard to debug, because every break point you run into makes your IDE the target for mouse release/focus events ...)</li> <li><strong>OS-dependent bugs</strong></li> <li><strong>hardware dependent bugs</strong> (occurs on release machine, but not on developer machine)</li> <li>...</li> </ul> <p>To be honest, from time to time I fail to fix such a bug on my own ... After debugging for hours (or sometimes even days) I feel very demoralized.</p> <p>What do you do in this situation (apart from asking others for help which is not always possible)?</p> <p>Do you</p> <ul> <li>use pencil and paper instead of a debugger</li> <li>face for another thing and return to this bug later</li> <li>...</li> </ul> <p>Please let me know!</p>
[ { "answer_id": 154931, "author": "camflan", "author_id": 22445, "author_profile": "https://Stackoverflow.com/users/22445", "pm_score": 1, "selected": false, "text": ":" }, { "answer_id": 154990, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://S...
2008/09/30
[ "https://Stackoverflow.com/questions/154897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2012356/" ]
154,900
<p>I was wrestling with some Perl that uses hash references.</p> <p>In the end it turned out that my problem was the line:</p> <pre><code>$myhash{$key} |= {}; </code></pre> <p>That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value".</p> <p>Dereferencing this and trying to use it as a hash reference, however, resulted in interpreter errors about using a string as a hash reference.</p> <p>Changing it to:</p> <pre><code>if( ! exists $myhash{$key}) { $myhash{$key} = {}; } </code></pre> <p>... made things work.</p> <p>So I don't have a <em>problem</em>. But I'm curious about what was going on.</p> <p>Can anyone explain?</p>
[ { "answer_id": 154916, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "my %myhash;\n$myhash{$key} ||= {};\n" }, { "answer_id": 154984, "author": "Michael Carman", "author_id": 823...
2008/09/30
[ "https://Stackoverflow.com/questions/154900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7512/" ]
154,902
<p>I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error:</p> <pre><code>a.c: In function `goUpDir': a.c:44: parse error before `char' a.c:45: `newDir' undeclared (first use in this function) a.c:45: (Each undeclared identifier is reported only once a.c:45: for each function it appears in.) a.c: In function `goIntoDir': a.c:54: parse error before `char' a.c:57: `newDir' undeclared (first use in this function) a.c:57: `oldDir' undeclared (first use in this function) </code></pre> <p>The main problems seem to be the parse error before <code>char</code> (the others are related)</p> <pre><code>44 char newDir[50] = ""; 54 char* oldDir = (char*)get_current_dir_name(); </code></pre> <p>These are just simple C-style strings declarations. Is there a header file that I need to include to get it to work in UNIX?</p> <p>P.S. what is the command to see what version of unix and which version of gcc you are using? Knowing this will allow me to be more specific in my question.</p> <p>Thanks</p>
[ { "answer_id": 154937, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 0, "selected": false, "text": "gcc --version\n" }, { "answer_id": 154943, "author": "Paul Tomblin", "author_id": 3333, "author_profil...
2008/09/30
[ "https://Stackoverflow.com/questions/154902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
154,964
<p>I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record that we see in many solutions. My question: Is there a better alternative?</p> <p>Scenario: You have a huge DB (in terms of tables, not records), and then the customer comes and asks you to add "timestamping" to 80% of your tables.</p> <p>I believe this can be accomplished by using a separate table (TIMESTAMPS). This table would have, in addition to the obvious timestamp column, the table name and the primary key for the table being updated. (I'm assuming here that you use an int as primary key for most of your tables, but the table name would most likely have to be a string).</p> <p>To picture this suppose this basic scenario. We would have two tables:</p> <p>PAYMENT :- (your usual records)<br> TIMESTAMP :- {current timestamp} + {<code>TABLE_UPDATED</code>, <code>id_of_entry_updated</code>, <code>timestamp_type</code>}</p> <p>Note that in this design you don't need those two "extra" columns in your native payment object (which, by the way, might make it thru your ORM solution) because you are now indexing by <code>TABLE_UPDATED</code> and <code>id_of_entry_updated</code>. In addition, <code>timestamp_type</code> will tell you if the entry is for insertion (e.g "1"), update (e.g "2"), and anything else you may want to add, like "deletion".</p> <p>I would like to know what do you think about this design. I'm most interested in best practices, what works and scales over time. References, links, blog entries are more than welcome. I know of at least one patent (pending) that tries to address this problem, but it seems details are not public at this time.</p> <p>Cheers, Eduardo</p>
[ { "answer_id": 154997, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": true, "text": "Change Data Capture" }, { "answer_id": 155015, "author": "davetron5000", "author_id": 3029, "author...
2008/09/30
[ "https://Stackoverflow.com/questions/154964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23920/" ]
155,022
<p>What is the easiest way to find out how much memory an object uses in .NET?</p> <p>Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types.</p> <p>Some related posts:</p> <ul> <li><a href="https://stackoverflow.com/questions/109836/object-memory-analysis-in-net">Object Memory Analysis in .NET</a></li> <li><a href="https://stackoverflow.com/questions/151936/does-an-empty-array-in-net-use-any-space">Does an empty array in .NET use any space?</a></li> </ul>
[ { "answer_id": 155048, "author": "Mladen", "author_id": 21404, "author_profile": "https://Stackoverflow.com/users/21404", "pm_score": 1, "selected": true, "text": "int startMem = GC.GetTotalMemory(true);\nYourClass c = new YourClass();\nint endMem = GC.GetTotalMemory(true);\nint usedMeme...
2008/09/30
[ "https://Stackoverflow.com/questions/155022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15985/" ]
155,054
<p>Is it possible to define a timestamp column in a MySQL table that will automatically be updated every time a field in the same row is modified? Ideally this column should initially be set to the time a row was inserted.</p> <p>Cheers, Don</p>
[ { "answer_id": 155096, "author": "quickcel", "author_id": 9129, "author_profile": "https://Stackoverflow.com/users/9129", "pm_score": 6, "selected": false, "text": "ALTER TABLE `table1` ADD `lastUpdated` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;\n" }, ...
2008/09/30
[ "https://Stackoverflow.com/questions/155054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
155,071
<p>Do you have a simple debounce routine handy to deal with a single switch input?</p> <p>This is a simple bare metal system without any OS.</p> <p>I would like to avoid a looping construct with a specific count, as the processor speed might fluctuate.</p>
[ { "answer_id": 155137, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 5, "selected": true, "text": "#define CHECK_MSEC 5 // Read hardware every 5 msec\n#define PRESS_MSEC 10 // Stable time before registering pressed\n#define ...
2008/09/30
[ "https://Stackoverflow.com/questions/155071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
155,074
<p>I'm a newbie when it comes to SQL. When creating a stored procedure with parameters as such:</p> <pre><code>@executed bit, @failure bit, @success bit, @testID int, @time float = 0, @name varchar(200) = '', @description varchar(200) = '', @executionDateTime nvarchar(max) = '', @message nvarchar(max) = '' </code></pre> <p>This is the correct form for default values in T-SQL? I have tried to use NULL instead of ''. </p> <p>When I attempted to execute this procedure through C# I get an error referring to the fact that description is expected but not provided. When calling it like this:</p> <pre><code> cmd.Parameters["@description"].Value = result.Description; </code></pre> <p>result.Description is null. Should this not default to NULL (well '' in my case right now) in SQL? </p> <p>Here's the calling command:</p> <pre><code> cmd.CommandText = "EXEC [dbo].insert_test_result @executed, @failure, @success, @testID, @time, @name, @description, @executionDateTime, @message;"; ... cmd.Parameters.Add("@description", SqlDbType.VarChar); cmd.Parameters.Add("@executionDateTime", SqlDbType.VarChar); cmd.Parameters.Add("@message", SqlDbType.VarChar); cmd.Parameters["@name"].Value = result.Name; cmd.Parameters["@description"].Value = result.Description; ... try { connection.Open(); cmd.ExecuteNonQuery(); } ... finally { connection.Close(); } </code></pre>
[ { "answer_id": 155082, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "cmd.CommandText = \"insert_test_result\";\ncmd.CommandType = CommandType.StoredProcedure;\n" }, { "answer_id":...
2008/09/30
[ "https://Stackoverflow.com/questions/155074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13688/" ]
155,080
<p>I can get rootmenuitemlefthtml and rootmenuitemrighthtml to emit but not separator. Tried CDATA wrapping and setting SeparatorCssClass. I just want pipes between root menu items.</p> <pre><code>&lt;dnn:SOLPARTMENU runat="server" id="dnnSOLPARTMENU" Separator="&lt;![CDATA[|]]&gt;" SeparatorCssClass="MainMenu_SeparatorCSS" usearrows="false" userootbreadcrumbarrow="false" usesubmenubreadcrumbarrow="false" rootmenuitemlefthtml="&amp;nbsp;&amp;lt;span&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;" rootmenuitemrighthtml="&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/span&amp;gt;" rootmenuitemcssclass="rootmenuitem" rootmenuitemselectedcssclass="rootmenuitemselected" rootmenuitembreadcrumbcssclass="rootmenuitembreadcrumb" submenucssclass="submenu" submenuitemselectedcssclass="submenuitemselected" submenuitembreadcrumbcssclass="submenuitembreadcrumb" CSSNodeSelectedRoot="rootmenuitembreadcrumb" CSSNodeSelectedSub="submenuitembreadcrumb" MouseOverAction="False" MouseOutHideDelay="0" delaysubmenuload="true" level="Root" /&gt; </code></pre>
[ { "answer_id": 391474, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<dnn:SOLPARTMENU runat=\"server\" ID=\"dnnHorizontalSolpart\" ProviderName=\"SolpartMenuNavigationProvider\"\n ClearDefault...
2008/09/30
[ "https://Stackoverflow.com/questions/155080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489/" ]
155,084
<p>I'm about to push out a website soon and so I've gotten in the last stages. Time to optimize the baby! The website performs pretty good overall, with an average framerate of 32fps. But at some heavy animation parts it likes to drop a couple of frames to about 22fps. Which is not that horrible. But I'm tweaking it as much as possible to keep it running at the highest speed possible.</p> <p>I might overlooked some tips and tricks to make this baby run even smoother. </p> <p>So hereby I open this thread to share whatever ninja tricks ever helped you in the past. A couple of mine which I can think of right now:</p> <p><strong>Sequencing the animation:</strong></p> <p>Let as less as possible transitions happen at the same time, try to make it act more as a transformer, one thing at a time. Next to gaining speed in animation, you probably end up gaining more flow.</p> <p><strong>Keep the animating objects as small as possible:</strong></p> <p>So flash has to calculate less pixels at the same time.</p> <p><strong>cacheAsBitmap = true:</strong></p> <p>Those big movieclips, vector shapes being moved around, are probably quicker moved when they are cached as a bitmap. Might take up some space in your memory, but anything for higher framerates ;)</p> <p><strong>Destroy everything you do not use:</strong></p> <p>Set those unused movieclips to null and then remove it as a child. So your garbage collector takes care of it.</p>
[ { "answer_id": 155182, "author": "Iain", "author_id": 11911, "author_profile": "https://Stackoverflow.com/users/11911", "pm_score": 2, "selected": false, "text": "cacheAsBitmap = true:" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671/" ]
155,087
<p>Before you start firing at me, I'm NOT looking to do this, but someone in <a href="https://stackoverflow.com/questions/154698/how-can-i-keep-a-class-from-being-inherited-in-c">another post</a> said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things...</p>
[ { "answer_id": 155185, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 5, "selected": true, "text": "// error CS0549: 'Seal.GetName()' is a new virtual member in sealed class 'Seal'\n" }, { "answer_id": 156599, ...
2008/09/30
[ "https://Stackoverflow.com/questions/155087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
155,097
<p>I am programmatically exporting data (using PHP 5.2) into a .csv test file.<br> Example data: <code>Numéro 1</code> (note the accented e). The data is <code>utf-8</code> (no prepended BOM).</p> <p>When I open this file in MS Excel is displays as <code>Numéro 1</code>.</p> <p>I am able to open this in a text editor (UltraEdit) which displays it correctly. UE reports the character is <code>decimal 233</code>.</p> <p>How can I <strong>export text</strong> data in a .csv file so <strong>that MS Excel will correctly render</strong> it, preferably without forcing the use of the import wizard, or non-default wizard settings?</p>
[ { "answer_id": 155176, "author": "James Baker", "author_id": 9365, "author_profile": "https://Stackoverflow.com/users/9365", "pm_score": 9, "selected": true, "text": "" }, { "answer_id": 595754, "author": "Kristof Neirynck", "author_id": 11451, "author_profile": "h...
2008/09/30
[ "https://Stackoverflow.com/questions/155097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23598/" ]
155,101
<p>When I parse my xml file (variable f) in this method, I get an error </p> <blockquote> <p>C:\Documents and Settings\joe\Desktop\aicpcudev\OnlineModule\map.dtd (The system cannot find the path specified)</p> </blockquote> <p>I know I do not have the dtd, nor do I need it. How can I parse this File object into a Document object while ignoring DTD reference errors?</p> <pre><code>private static Document getDoc(File f, String docId) throws Exception{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); return doc; } </code></pre>
[ { "answer_id": 155330, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 2, "selected": false, "text": "myDocumentBuilder.setEntityResolver(new EntityResolver() {\n public InputSource resolveEntity(java.lang.String pub...
2008/09/30
[ "https://Stackoverflow.com/questions/155101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
155,105
<p>I am getting the following error when I put class files in subfolders of my App_Code folder:</p> <p>errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?)</p> <p>This class is not in a namespace at all. Any ideas?</p>
[ { "answer_id": 155149, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 5, "selected": true, "text": "<configuration>\n <system.web>\n <compilation>\n <codeSubDirectories>\n <add directoryName=...
2008/09/30
[ "https://Stackoverflow.com/questions/155105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18926/" ]
155,116
<p>I have several different c# worker applications that run various continuous tasks: sending emails from queue, importing new orders from website database to orders database, making database backups and restores, running data processing for OLTP -> OLAP, and other related tasks. Before, I released these as windows services, but currently I release them as regular console applications. They are all based on a common task runner framework I created, and I am happy with that, however I am not sure what is the best way to deploy these types of applications. I like the console version because it is quick and easy, and it is possible to quickly see program activity and output. The downside is that the worker computer has several console screens running and it gets messy. On the other hand the service method seems to take to long to deploy and I have to go through event logs to see messages. What are some experiences/comments on this?</p>
[ { "answer_id": 155180, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 1, "selected": false, "text": "installutil MyApp.exe\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13855/" ]
155,144
<p>I've got a relatively large .Net system that consists of a number of different applications. Rather than having lots of different app.config files, I would like to share a single configuration file between all the apps.</p> <p>I would also like to have one version when developing on my machine, one version for someone else developing on their machine, one version for a test system and one version for a live system. </p> <p>Is there an easy way of doing this? </p>
[ { "answer_id": 155167, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 2, "selected": false, "text": "copy /Y c:\\path\\to\\master\\project\\app.config $(TargetPath).config\nexit 0\n" }, { "answer_id": 155485, ...
2008/09/30
[ "https://Stackoverflow.com/questions/155144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5932/" ]
155,152
<p>I'm building a form with php/mysql. I've got a table with a list of locations and sublocations. Each sublocation has a parent location. A column "parentid" references another locationid in the same table. I now want to load these values into a dropdown in the following manner:</p> <pre><code>--Location 1 ----Sublocation 1 ----Sublocation 2 ----Sublocation 3 --Location 2 ----Sublocation 4 ----Sublocation 5 </code></pre> <p>etc. etc.</p> <p>Did anyone get an elegant solution for doing this?</p>
[ { "answer_id": 155177, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 0, "selected": false, "text": "<?php\n\n$data = array(\n 'Location 1' => array(\n 'Sublocation1',\n 'Sublocation2',\n 'Sublocati...
2008/09/30
[ "https://Stackoverflow.com/questions/155152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22837/" ]
155,188
<p>I have one text input and one button (see below). How can I use JavaScript to <strong>trigger the button's click event</strong> when the <kbd>Enter</kbd> key is pressed inside the text box?</p> <p>There is already a different submit button on my current page, so I can't simply make the button a submit button. And, I <em>only</em> want the <kbd>Enter</kbd> key to click this specific button if it is pressed from within this one text box, nothing else.</p> <pre><code>&lt;input type="text" id="txtSearch" /&gt; &lt;input type="button" id="btnSearch" value="Search" onclick="doSomething();" /&gt; </code></pre>
[ { "answer_id": 155193, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 6, "selected": false, "text": "<input type = \"submit\"\n id = \"btnSearch\"\n value = \"Search\"\n onclick = \"return doSomething();...
2008/09/30
[ "https://Stackoverflow.com/questions/155188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23947/" ]
155,191
<p>I have written something that uses the following includes:</p> <pre><code>#include &lt;math.h&gt; #include &lt;time.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;windows.h&gt; #include &lt;commctrl.h&gt; </code></pre> <p>This code works fine on 2 machines with the Platform SDK installed, but doesn't run (neither debug nor release versions) on clean installs of windows (VMs of course). It dies with the quite familiar:</p> <pre><code>--------------------------- C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe --------------------------- C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. --------------------------- OK --------------------------- </code></pre> <p>How can I make it run on clean installs? Which dll is it using which it can't find? My bet is on commctrl, but can someone enlighten me on why it's isn't with every windows?</p> <p>Further more, if anyone has tips on how to debug such a thing, as my CPP is already rusty, as it seems :)</p> <p>Edit - What worked for me is downloading the Redistributable for Visual Studio 2008. I don't think it's a good solution - downloading a 2MB file and an install to run a simple 11K tool. I think I'll change the code to use LoadLibrary to get the 2 or 3 functions I need from comctl32.dll. Thanks everyone :)</p>
[ { "answer_id": 155431, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 1, "selected": false, "text": "msvcrt.dll" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23942/" ]
155,202
<p>I am troubleshooting an issue with IIS6 where all sites bound to ip addresses other than the default give an error message "network location cannot be reached" when trying to start any of these sites.</p> <p>The nic has all the ip addresses configured. When I do a httpcfg query iplisten, I see only the default ip address. When I added them with httpcfg, then all the web sites stopped working so I figured I didn something wrong so I removed them.</p> <p>Two questions: 1- Why are those websites refusing to start? 2- What should be in the result of httpcfg query iplisten? All ip addresses or just one?</p> <p>The websites used to work fine and something has changed. I applied a few Windows updates but I am not sure if they broke anything (I doubt it.. otherwise hundreds of web hosting companies would be screaming)</p>
[ { "answer_id": 155348, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 0, "selected": false, "text": "ERROR_NETWORK_UNREACHABLE" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5232/" ]
155,203
<p>What is a good error handling practice for an asp.net site? Examples? Thanks!</p>
[ { "answer_id": 155238, "author": "John", "author_id": 33, "author_profile": "https://Stackoverflow.com/users/33", "pm_score": 4, "selected": true, "text": " try\n {\n //Code that could error here\n }\n catch (FormatException ex)\n {\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/155203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
155,220
<p>We are trying to update our classic asp search engine to protect it from SQL injection. We have a VB 6 function which builds a query dynamically by concatenating a query together based on the various search parameters. We have converted this to a stored procedure using dynamic sql for all parameters except for the keywords.</p> <p>The problem with keywords is that there are a variable number words supplied by the user and we want to search several columns for each keyword. Since we cannot create a separate parameter for each keyword, how can we build a safe query?</p> <p>Example:</p> <pre><code>@CustomerId AS INT @Keywords AS NVARCHAR(MAX) @sql = 'SELECT event_name FROM calendar WHERE customer_id = @CustomerId ' --(loop through each keyword passed in and concatenate) @sql = @sql + 'AND (event_name LIKE ''%' + @Keywords + '%'' OR event_details LIKE ''%' + @Keywords + '%'')' EXEC sp_executesql @sql N'@CustomerId INT, @CustomerId = @CustomerId </code></pre> <p>What is the best way to handle this and maintaining protection from SQL injection? </p>
[ { "answer_id": 155332, "author": "Rikalous", "author_id": 4271, "author_profile": "https://Stackoverflow.com/users/4271", "pm_score": 2, "selected": false, "text": "string sql = \"SELECT Name, Title FROM Staff WHERE UserName=@UserId\";\nusing (SqlCommand cmd = new SqlCommand(sql))\n{\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/155220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23918/" ]
155,234
<p>I have a cluster of three mongrels running under nginx, and I deploy the app using Capistrano 2.4.3. When I "cap deploy" when there is a running system, the behavior is: </p> <ol> <li>The app is deployed. The code is successfully updated. </li> <li><p>In the cap deploy output, there is this: </p> <ul> <li>executing "sudo -p 'sudo password: ' mongrel_rails cluster::restart -C /var/www/rails/myapp/current/config/mongrel_cluster.yml"</li> <li>servers: ["myip"]</li> <li>[myip] executing command</li> <li>** [out :: myip] stopping port 9096</li> <li>** [out :: myip] stopping port 9097</li> <li>** [out :: myip] stopping port 9098</li> <li>** [out :: myip] already started port 9096</li> <li>** [out :: myip] already started port 9097</li> <li>** [out :: myip] already started port 9098</li> </ul></li> <li>I check immediately on the server and find that Mongrel is still running, and the PID files are still present for the previous three instances. </li> <li>A short time later (less than one minute), I find that Mongrel is no longer running, the PID files are gone, and it has failed to restart. </li> <li>If I start mongrel on the server by hand, the app starts up just fine. </li> </ol> <p>It seems like 'mongrel_rails cluster::restart' isn't properly waiting for a full stop before attempting a restart of the cluster. How do I diagnose and fix this issue?</p> <p>EDIT: Here's the answer: </p> <p>mongrel_cluster, in the "restart" task, simply does this: </p> <pre><code> def run stop start end </code></pre> <p>It doesn't do any waiting or checking to see that the process exited before invoking "start". This is <a href="http://rubyforge.org/tracker/index.php?func=detail&amp;aid=19657&amp;group_id=1336&amp;atid=5291" rel="nofollow noreferrer">a known bug with an outstanding patch submitted</a>. I applied the patch to Mongrel Cluster and the problem disappeared. </p>
[ { "answer_id": 156017, "author": "Ryan McGeary", "author_id": 8985, "author_profile": "https://Stackoverflow.com/users/8985", "pm_score": 1, "selected": false, "text": "cap deploy:restart" }, { "answer_id": 157964, "author": "rwc9u", "author_id": 7778, "author_profile...
2008/09/30
[ "https://Stackoverflow.com/questions/155234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13472/" ]
155,243
<p>As a follow up to a <a href="https://stackoverflow.com/questions/151590/java-how-do-detect-a-remote-side-socket-close">recent question</a>, I wonder why it is impossible in Java, without attempting reading/writing on a TCP socket, to detect that the socket has been gracefully closed by the peer? This seems to be the case regardless of whether one uses the pre-NIO <code>Socket</code> or the NIO <code>SocketChannel</code>.</p> <p>When a peer gracefully closes a TCP connection, the TCP stacks on both sides of the connection know about the fact. The server-side (the one that initiates the shutdown) ends up in state <code>FIN_WAIT2</code>, whereas the client-side (the one that does not explicitly respond to the shutdown) ends up in state <code>CLOSE_WAIT</code>. Why isn't there a method in <code>Socket</code> or <code>SocketChannel</code> that can query the TCP stack to see whether the underlying TCP connection has been terminated? Is it that the TCP stack doesn't provide such status information? Or is it a design decision to avoid a costly call into the kernel?</p> <p>With the help of the users who have already posted some answers to this question, I think I see where the issue might be coming from. The side that doesn't explicitly close the connection ends up in TCP state <code>CLOSE_WAIT</code> meaning that the connection is in the process of shutting down and waits for the side to issue its own <code>CLOSE</code> operation. I suppose it's fair enough that <code>isConnected</code> returns <code>true</code> and <code>isClosed</code> returns <code>false</code>, but why isn't there something like <code>isClosing</code>?</p> <p>Below are the test classes that use pre-NIO sockets. But identical results are obtained using NIO.</p> <pre><code>import java.net.ServerSocket; import java.net.Socket; public class MyServer { public static void main(String[] args) throws Exception { final ServerSocket ss = new ServerSocket(12345); final Socket cs = ss.accept(); System.out.println("Accepted connection"); Thread.sleep(5000); cs.close(); System.out.println("Closed connection"); ss.close(); Thread.sleep(100000); } } import java.net.Socket; public class MyClient { public static void main(String[] args) throws Exception { final Socket s = new Socket("localhost", 12345); for (int i = 0; i &lt; 10; i++) { System.out.println("connected: " + s.isConnected() + ", closed: " + s.isClosed()); Thread.sleep(1000); } Thread.sleep(100000); } } </code></pre> <p>When the test client connects to the test server the output remains unchanged even after the server initiates the shutdown of the connection:</p> <pre><code>connected: true, closed: false connected: true, closed: false ... </code></pre>
[ { "answer_id": 157139, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 2, "selected": false, "text": "select(2)" }, { "answer_id": 157534, "author": "Alexander", "author_id": 16724, "author_profile": "https://S...
2008/09/30
[ "https://Stackoverflow.com/questions/155243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16724/" ]
155,246
<p>I have a test environment for a database that I want to reload with new data at the start of a testing cycle. I am not interested in rebuilding the entire database- just simply "re-setting" the data. </p> <p>What is the best way to remove all the data from all the tables using TSQL? Are there system stored procedures, views, etc. that can be used? I do not want to manually create and maintain truncate table statements for each table- I would prefer it to be dynamic.</p>
[ { "answer_id": 155270, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "tables" }, { "answer_id": 155275, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "...
2008/09/30
[ "https://Stackoverflow.com/questions/155246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
155,260
<p>I have been learning about the basics of C# but haven't come across a good explanation of what this is:</p> <pre><code>var l = new List&lt;string&gt;(); </code></pre> <p>I don't know what the <code>&lt;string&gt;</code> is doing or if it's the <code>List</code> that is doing the magic. I have also seen objects been thrown within the <code>&lt; &gt;</code> tags.</p> <p>Can someone explain this to me with examples, please?</p>
[ { "answer_id": 155280, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 1, "selected": false, "text": "int x = (int)myArrayList[4];\n" }, { "answer_id": 155286, "author": "Eric Z Beard", "author_id": 1219,...
2008/09/30
[ "https://Stackoverflow.com/questions/155260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22459/" ]
155,271
<p>Is there a way to hide the text limit line in netbeans 6.5?</p>
[ { "answer_id": 1210584, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<entry javaType=\"java.lang.Boolean\" name=\"text-limit-line-visible\" xml:space=\"preserve\">\n<value><![CDATA[false]]></val...
2008/09/30
[ "https://Stackoverflow.com/questions/155271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
155,279
<p>I have an AdvancedDataGrid that uses customer grouping of data. Not all of the groups will be at the same level in the hierarchy, and groups can contain both groups and members. We have a sort callback, but it's not being called except for groups at the leaf-most levels. See code below for an example -- expand all of the groups, then click the sort column on "date of birth" to get a reverse sort by date of birth. (Oddly, for some unfathomable reason, the first ascending sort works.)</p> <p>We're not getting called for any of the data that's grouped at the same level as a group member.</p> <p>How do I fix this?</p> <p>Thanks.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" &gt; &lt;mx:Script&gt; &lt;![CDATA[ import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn; import mx.collections.HierarchicalData; import mx.utils.ObjectUtil; private var arrData : Array = [ { name: "User A", dob: "04/14/1980" }, { name: "User B", dob: "01/02/1975" }, { name: "Group A", children: [ { name: "User E", dob: "09/13/1972" }, { name: "User F", dob: "11/22/1993" } ] }, { name: "Group B", children: [ { name: "Group B1", children: [ { name: "User I", dob: "01/23/1984" }, { name: "User J", dob: "11/10/1948" } ] }, { name: "User G", dob: "04/09/1989" }, { name: "User H", dob: "06/20/1963" } ] }, { name: "User C", dob: "12/30/1977" }, { name: "User D", dob: "10/27/1968" } ]; private function date_sortCompareFunc(itemA:Object, itemB:Object):int { if ( itemA.hasOwnProperty("dob") &amp;&amp; itemB.hasOwnProperty("dob")) { var dateA:Date = new Date(Date.parse(itemA.dob)); var dateB:Date = new Date(Date.parse(itemB.dob)); return ObjectUtil.dateCompare(dateA, dateB); } else if ( itemA.hasOwnProperty("dob")) { return 1; } else if (itemB.hasOwnProperty("dob")) { return -1; } return ObjectUtil.stringCompare(itemA.name, itemB.name); } private function date_dataTipFunc(item:Object):String { if (item.hasOwnProperty("dob")) { return dateFormatter.format(item.dob); } return ""; } private function label_dob(item:Object, col:AdvancedDataGridColumn):String { var dob:String=""; if(item.hasOwnProperty("dob")) { dob=item.dob; } return dob; } ]]&gt; &lt;/mx:Script&gt; &lt;mx:DateFormatter id="dateFormatter" formatString="MMMM D, YYYY" /&gt; &lt;mx:AdvancedDataGrid id="adgTest" dataProvider="{new HierarchicalData(this.arrData)}" designViewDataType="tree" width="746" height="400"&gt; &lt;mx:columns&gt; &lt;mx:AdvancedDataGridColumn headerText="Name" dataField="name"/&gt; &lt;mx:AdvancedDataGridColumn dataField="dob" headerText="Date of birth" labelFunction="label_dob" sortCompareFunction="date_sortCompareFunc" showDataTips="true" dataTipFunction="date_dataTipFunc" /&gt; &lt;/mx:columns&gt; &lt;/mx:AdvancedDataGrid&gt; &lt;/mx:Application&gt; </code></pre>
[ { "answer_id": 156283, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 0, "selected": false, "text": "dob:\"01/01/1970\"" }, { "answer_id": 1406772, "author": "Invalid Character", "author_id": 9610, "au...
2008/09/30
[ "https://Stackoverflow.com/questions/155279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22809/" ]
155,291
<p>I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything.</p> <p>I'd rather not use Disabled, since I want the checked check boxes to be submitted with the rest of the form, I just don't want the client to be able to change them under certain circumstances.</p>
[ { "answer_id": 155301, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 9, "selected": false, "text": "READONLY" }, { "answer_id": 155324, "author": "powtac", "author_id": 22470, "author_profile": "https://S...
2008/09/30
[ "https://Stackoverflow.com/questions/155291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
155,303
<p>How do I go from this string: "ThisIsMyCapsDelimitedString"</p> <p>...to this string: "This Is My Caps Delimited String"</p> <p>Fewest lines of code in VB.net is preferred but C# is also welcome.</p> <p>Cheers!</p>
[ { "answer_id": 155331, "author": "Max Schmeling", "author_id": 3226, "author_profile": "https://Stackoverflow.com/users/3226", "pm_score": 0, "selected": false, "text": "string myString = \"ThisIsMyCapsDelimitedString\";\n\nfor (int i = 1; i < myString.Length; i++)\n{\n if (myString[...
2008/09/30
[ "https://Stackoverflow.com/questions/155303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17235/" ]
155,306
<p>I have a textarea with many lines of input, and a JavaScript event fires that necessitates I scroll the textarea to line 345.</p> <p><code>scrollTop</code> sort of does what I want, except as far as I can tell it's pixel level, and I want something that operates on a line level. What also complicates things is that, afaik once again, it's not possible to make textareas not line-wrap.</p>
[ { "answer_id": 155404, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 5, "selected": true, "text": "<script type=\"text/javascript\" language=\"JavaScript\">\nfunction Jump(line)\n{\n var ta = document.getElementById(\"Text...
2008/09/30
[ "https://Stackoverflow.com/questions/155306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23845/" ]
155,308
<p>I'm trying to get a PHP site working in IIS on Windows Server with MySQL.</p> <p>I'm getting this error…</p> <p>Fatal error: Call to undefined function mysql_connect() in C:\inetpub...\adodb\drivers\adodb-mysql.inc.php on line 363</p> <hr /> <p>Update…</p> <p>This link outlines the steps I followed to install PHP on my server:<br /> <a href="https://stackoverflow.com/questions/11919/how-do-i-get-php-and-mysql-working-on-iis-70#94341">How do I get PHP and MySQL working on IIS 7.0 ?</a><br /> (note especially steps 6 and 8 regarting php.ini and php_mysql.dll).</p> <p>Only two lines in the phpinfo report reference SQL:</p> <pre><code>&lt;?php phpinfo(); ?&gt; </code></pre> <blockquote> <p>Configure Command:<br /> cscript /nologo configure.js &quot;--enable-snapshot-build&quot; &quot;--enable-mysqlnd&quot;</p> <p>sql.safe_mode:<br /> Local Value Off, Master Value Off</p> </blockquote> <p><a href="http://img79.imageshack.us/img79/2373/configurecommandmw8.gif" rel="nofollow noreferrer">PHP Configure Command http://img79.imageshack.us/img79/2373/configurecommandmw8.gif</a></p> <p><a href="http://img49.imageshack.us/img49/3066/sqlsafemoderu6.gif" rel="nofollow noreferrer">PHP sql.safe_mode http://img49.imageshack.us/img49/3066/sqlsafemoderu6.gif</a></p> <hr /> <p>Update…</p> <p>I found the solution: <a href="https://stackoverflow.com/questions/158279/how-do-i-install-mysql-modules-within-php#160746">How do I install MySQL modules within PHP?</a></p>
[ { "answer_id": 155316, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<?php\n phpinfo();\n?>\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
155,311
<p>I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++?</p> <p>I would like to pass it two parameters and do not need a result.</p>
[ { "answer_id": 155420, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 2, "selected": false, "text": "boost::thread some_thread(&SomeFunction, param1, param2);\n" }, { "answer_id": 155434, "author": "David Smit...
2008/09/30
[ "https://Stackoverflow.com/questions/155311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
155,314
<p>I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail.</p> <p>Something along these lines should work: </p> <pre><code>// filename examples: "test.avi", "test.dvr-ms" // position is from 0 to 100 percent (0.0 to 1.0) // returns a bitmap byte[] GetVideoThumbnail(string filename, float position) { } </code></pre> <p>Does anyone know how to do this in .Net 3.0? </p> <p>The correct solution will be the "best" implementation of this function. Bonus points for avoiding selection of blank frames. </p>
[ { "answer_id": 6852123, "author": "Ahmad Behjati", "author_id": 866395, "author_profile": "https://Stackoverflow.com/users/866395", "pm_score": 2, "selected": false, "text": "Process ffmpeg;\n\nstring video;\nstring thumb;\n\nvideo = Server.MapPath(\"first.avi\");\nthumb = Server.MapPath...
2008/09/30
[ "https://Stackoverflow.com/questions/155314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
155,321
<p>I'm trying to build a mapping table to associate the IDs of new rows in a table with those that they're copied from. The OUTPUT INTO clause seems perfect for that, but it doesn't seem to behave according to the documentation. </p> <p>My code:</p> <pre><code>DECLARE @Missing TABLE (SrcContentID INT PRIMARY KEY ) INSERT INTO @Missing ( SrcContentID ) SELECT cshadow.ContentID FROM Private.Content AS cshadow LEFT JOIN Private.Content AS cglobal ON cshadow.Tag = cglobal.Tag WHERE cglobal.ContentID IS NULL PRINT 'Adding new content headers' DECLARE @Inserted TABLE (SrcContentID INT PRIMARY KEY, TgtContentID INT ) INSERT INTO Private.Content ( Tag, Description, ContentDate, DateActivate, DateDeactivate, SortOrder, CreatedOn, IsDeleted, ContentClassCode, ContentGroupID, OrgUnitID ) OUTPUT cglobal.ContentID, INSERTED.ContentID INTO @Inserted (SrcContentID, TgtContentID) SELECT Tag, Description, ContentDate, DateActivate, DateDeactivate, SortOrder, CreatedOn, IsDeleted, ContentClassCode, ContentGroupID, NULL FROM Private.Content AS cglobal INNER JOIN @Missing AS m ON cglobal.ContentID = m.SrcContentID </code></pre> <p>Results in the error message:</p> <pre><code>Msg 207, Level 16, State 1, Line 34 Invalid column name 'SrcContentID'. </code></pre> <p>(line 34 being the one with the OUTPUT INTO)</p> <p>Experimentation suggests that only rows that are actually present in the target of the INSERT can be selected in the OUTPUT INTO. But this contradicts the docs in the books online. The article on <strong>OUTPUT Clause</strong> has example E that describes a similar usage:</p> <blockquote> <p>The OUTPUT INTO clause returns values from the table being updated (WorkOrder) and also from the Product table. The Product table is used in the FROM clause to specify the rows to update.</p> </blockquote> <p>Has anyone worked with this feature?</p> <p>(In the meantime I've rewritten my code to do the job using a cursor loop, but that's ugly and I'm still curious)</p>
[ { "answer_id": 156352, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 5, "selected": true, "text": "INSERTED" }, { "answer_id": 662046, "author": "Roland Zwaga", "author_id": 79594, "author_profile": "...
2008/09/30
[ "https://Stackoverflow.com/questions/155321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10082/" ]
155,366
<p>Rep steps:</p> <ol> <li>create example .NET form application</li> <li>put a TextBox on the form</li> <li>wire a function up to the TextBox's Enter event</li> </ol> <p>When you run this application, the <strong>Control.Enter</strong> event fires when focus first goes to the TextBox. However, if you click away into another application and then click back into the test application, the event will not fire again.</p> <p>So <strong>moving between applications does not trigger Enter/Leave</strong>.</p> <p>Is there another alternative <em>Control-level</em> event that I can use, which will fire in this scenario?</p> <p>Ordinarily, I would use <strong>Form.Activated</strong>. Unfortunately, that is troublesome here because my component is hosted by a docking system that can undock my component into a new Form without notifying me.</p>
[ { "answer_id": 158860, "author": "Fry", "author_id": 23553, "author_profile": "https://Stackoverflow.com/users/23553", "pm_score": 0, "selected": false, "text": "Grid currentGrid = (Grid)sender;\n" }, { "answer_id": 32187337, "author": "user5261230", "author_id": 5261230,...
2008/09/30
[ "https://Stackoverflow.com/questions/155366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23933/" ]
155,367
<p>Change Data Capture is a new feature in SQL Server 2008. From MSDN:</p> <blockquote> <p>Change data capture provides historical change information for a user table by capturing both the fact that DML changes were made and the actual data that was changed. Changes are captured by using an asynchronous process that reads the transaction log and has a low impact on the system</p> </blockquote> <p>This is highly sweet - no more adding CreatedDate and LastModifiedBy columns manually.</p> <p>Does Oracle have anything like this?</p>
[ { "answer_id": 49542172, "author": "Lukasz Szozda", "author_id": 5070879, "author_profile": "https://Stackoverflow.com/users/5070879", "pm_score": 0, "selected": false, "text": "CREATE TABLESPACE SPACE_FOR_ARCHIVE \ndatafile 'C:\\ORACLE DB12\\ARCH_SPACE.DBF'size 50G;\n\nCREATE FLASHBACK ...
2008/09/30
[ "https://Stackoverflow.com/questions/155367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
155,371
<p>I want to use XMLHttpRequest in JavaScript to POST a form that includes a file type input element so that I can avoid page refresh and get useful XML back.</p> <p>I can submit the form without page refresh, using JavaScript to set the target attribute on the form to an iframe for MSIE or an object for Mozilla, but this has two problems. The minor problem is that target is not W3C compliant (which is why I set it in JavaScript, not in XHTML). The major problem is that the onload event doesn't fire, at least not on Mozilla on OS X Leopard. Besides, XMLHttpRequest would make for prettier response code because the returned data could be XML, not confined to XHTML as is the case with iframe.</p> <p>Submitting the form results in HTTP that looks like: </p> <pre><code>Content-Type: multipart/form-data;boundary=&lt;boundary string&gt; Content-Length: &lt;length&gt; --&lt;boundary string&gt; Content-Disposition: form-data, name="&lt;input element name&gt;" &lt;input element value&gt; --&lt;boundary string&gt; Content-Disposition: form-data, name=&lt;input element name&gt;"; filename="&lt;input element value&gt;" Content-Type: application/octet-stream &lt;element body&gt; </code></pre> <p>How do I get the XMLHttpRequest object's send method to duplicate the above HTTP stream?</p>
[ { "answer_id": 155429, "author": "helios", "author_id": 9686, "author_profile": "https://Stackoverflow.com/users/9686", "pm_score": 0, "selected": false, "text": "var lFrame = document.getElementById('myframe');\nlFrame.onreadystatechange = function()\n{\n if (lFrame.readyState == 'com...
2008/09/30
[ "https://Stackoverflow.com/questions/155371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14405/" ]
155,375
<p>I'm working with a datagrid and adapter that correspond with an MSAccess table through a stored query (named "UpdatePaid", 3 paramaters as shown below) like so:</p> <pre><code> OleDbCommand odc = new OleDbCommand("UpdatePaid", connection); OleDbParameter param; odc.CommandType = CommandType.StoredProcedure; param = odc.Parameters.Add("v_iid", OleDbType.Double); param.SourceColumn = "I"; param.SourceVersion = DataRowVersion.Original; param = odc.Parameters.Add("v_pd", OleDbType.Boolean); param.SourceColumn = "Paid"; param.SourceVersion = DataRowVersion.Current; param = odc.Parameters.Add("v_Projected", OleDbType.Currency); param.SourceColumn = "ProjectedCost"; param.SourceVersion = DataRowVersion.Current; odc.Prepare(); myAdapter.UpdateCommand = odc; ... myAdapter.Update(); </code></pre> <p>It works fine...but the really weird thing is that it <em>didn't</em> until I put in the <strong>odc.Prepare()</strong> call.<br><br>My question is thus: Do I need to do that all the time when working with OleDb stored procs/queries? Why? I also have another project coming up where I'll have to do the same thing with a SqlDbCommand... do I have to do it with those, too? </p>
[ { "answer_id": 155571, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 0, "selected": false, "text": "Prepare()" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13776/" ]
155,378
<p>I have a <code>double</code> value <code>f</code> and would like a way to nudge it very slightly larger (or smaller) to get a new value that will be as close as possible to the original but still strictly greater than (or less than) the original.</p> <p>It doesn't have to be close down to the last bit—it's more important that whatever change I make is guaranteed to produce a different value and not round back to the original.</p>
[ { "answer_id": 155397, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 7, "selected": true, "text": "nextafter" }, { "answer_id": 155406, "author": "Community", "author_id": -1, "author_profile":...
2008/09/30
[ "https://Stackoverflow.com/questions/155378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
155,388
<p>Suppose that I have interface MyInterface and 2 classes A, B which implement MyInterface.<br> I declared 2 objects: <code>MyInterface a = new A()</code> , and <code>MyInterface b = new B()</code>.<br> When I try to pass to a function - function <code>doSomething(A a){}</code> I am getting an error.</p> <p>This is my code:</p> <pre><code>public interface MyInterface {} public class A implements MyInterface{} public class B implements MyInterface{} public class Tester { public static void main(String[] args){ MyInterface a = new A(); MyInterface b = new B(); test(b); } public static void test(A a){ System.out.println("A"); } public static void test(B b){ System.out.println("B"); } } </code></pre> <p>My problem is that I am getting from some component interface which can be all sorts of classes and I need to write function for each class.<br> So one way is to get interface and to check which type is it. (instance of A)</p> <p>I would like to know how others deal with this problem??</p> <p>Thx</p>
[ { "answer_id": 155417, "author": "perimosocordiae", "author_id": 10601, "author_profile": "https://Stackoverflow.com/users/10601", "pm_score": 0, "selected": false, "text": "public abstract class Parent {}" }, { "answer_id": 155418, "author": "Goran", "author_id": 23164, ...
2008/09/30
[ "https://Stackoverflow.com/questions/155388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23968/" ]
155,391
<p>What is the difference between a BitmapFrame and BitmapImage in WPF? Where would you use each (ie. why would you use a BitmapFrame rather than a BitmapImage?)</p>
[ { "answer_id": 155433, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 5, "selected": true, "text": "Uri uri = ...;\nBitmapSource bmp = new BitmapImage(uri);\nConsole.WriteLine(\"{0}x{1}\", bmp.PixelWIdth, bmp.PixelHeight)...
2008/09/30
[ "https://Stackoverflow.com/questions/155391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
155,426
<p>I tried to set innerHTML on an element in firefox and it worked fine, tried it in IE and got unexpected errors with no obvious reason why.</p> <p>For example if you try and set the innerHTML of a table to " hi from stu " it will fail, because the table must be followed by a sequence.</p>
[ { "answer_id": 161491, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 2, "selected": false, "text": "// removing the scripts to avoid any 'Permission Denied' errors in IE\nvar cleaned = html.replace(/<script(.|\\s)*?\\/s...
2008/09/30
[ "https://Stackoverflow.com/questions/155426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
155,427
<p>I have a form element that I want to address via javascript, but it doesn't like the syntax.</p> <pre><code>&lt;form name="mycache"&gt; &lt;input type="hidden" name="cache[m][2]"&gt; &lt;!-- ... --&gt; &lt;/form&gt; </code></pre> <p>I want to be able to say:</p> <pre><code>document.mycache.cache[m][2] </code></pre> <p>but obviously I need to indicate that <code>cache[m][2]</code> is the whole name, and not an array reference to <code>cache</code>. Can it be done?</p>
[ { "answer_id": 155437, "author": "Chris Pietschmann", "author_id": 7831, "author_profile": "https://Stackoverflow.com/users/7831", "pm_score": 3, "selected": true, "text": "<html>\n<body>\n\n<form id=\"form1\">\n\n<input type='test' id='field[m][2]' name='field[m][2]' value='Chris'/>\n\n...
2008/09/30
[ "https://Stackoverflow.com/questions/155427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14253/" ]
155,435
<p>In JavaScript, you can do this:</p> <pre><code>var a = null; var b = "I'm a value"; var c = null; var result = a || b || c; </code></pre> <p>And 'result' will get the value of 'b' because JavaScript short-circuits the 'or' operator.</p> <p>I want a one-line idiom to do this in ColdFusion and the best I can come up with is:</p> <pre><code>&lt;cfif LEN(c) GT 0&gt;&lt;cfset result=c&gt;&lt;/cfif&gt; &lt;cfif LEN(b) GT 0&gt;&lt;cfset result=b&gt;&lt;/cfif&gt; &lt;cfif LEN(a) GT 0&gt;&lt;cfset result=a&gt;&lt;/cfif&gt; </code></pre> <p>Can anyone do any better than this?</p>
[ { "answer_id": 155529, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 4, "selected": true, "text": "<cfset result = ListFirst( \"#a#,#b#,#c#\" )/>\n" }, { "answer_id": 155550, "author": "Peter Boughton", ...
2008/09/30
[ "https://Stackoverflow.com/questions/155435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13958/" ]
155,436
<p><strong>What are the best practices for naming unit test classes and test methods?</strong></p> <p>This was discussed on SO before, at <a href="https://stackoverflow.com/questions/96297/naming-conventions-for-unit-tests">What are some popular naming conventions for Unit Tests?</a></p> <p>I don't know if this is a very good approach, but currently in my testing projects, I have one-to-one mappings between each production class and a test class, e.g. <code>Product</code> and <code>ProductTest</code>.</p> <p>In my test classes I then have methods with the names of the methods I am testing, an underscore, and then the situation and what I expect to happen, e.g. <code>Save_ShouldThrowExceptionWithNullName()</code>.</p>
[ { "answer_id": 155475, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 6, "selected": false, "text": "[name of your 'unit']Tests\n" }, { "answer_id": 155480, "author": "Sklivvz", "author_id": 7028, "a...
2008/09/30
[ "https://Stackoverflow.com/questions/155436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11829/" ]
155,449
<p>Right now I have the following in my <code>.vimrc</code>:</p> <pre><code>au BufWritePost *.c,*.cpp,*.h !ctags -R </code></pre> <p>There are a few problems with this:</p> <ol> <li>It's slow -- regenerates tags for files that haven't changed since the last tag generation.</li> <li>I have to push the enter button <em>again</em> after writing the file because of an inevitable "press Enter or type command to continue".</li> </ol> <p>When you combine these two issues I end up pushing the additional enter too soon (before <code>ctags -R</code> has finished), then see the annoying error message, and have to push enter again.</p> <p>I know it doesn't sound like a big deal, but with the amount of file writes I do on a given day it tends to get really annoying. There's gotta be a better way to do it!</p>
[ { "answer_id": 155515, "author": "Zathrus", "author_id": 16220, "author_profile": "https://Stackoverflow.com/users/16220", "pm_score": 7, "selected": true, "text": "au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &" }, { "answer_id": 156781, "author": "Luc Hermitte", "aut...
2008/09/30
[ "https://Stackoverflow.com/questions/155449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
155,458
<p>I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data.</p> <p>Here is the code :</p> <pre><code> if (region != null) { .... } </code></pre> <p>This is working but when looping and looping sometime the region object is NOT null (I can see data inside it in debug mode). In step-by-step when debugging, it doesn't go inside the IF statement... When I do a Quick Watch with these following expression : I see the (region == null) return false, AND (region != null) return false too... <strong>why and how?</strong></p> <p><strong>Update</strong></p> <p>Someone point out that the object was == and != overloaded:</p> <pre><code> public static bool operator ==(Region r1, Region r2) { if (object.ReferenceEquals(r1, null)) { return false; } if (object.ReferenceEquals(r2, null)) { return false; } return (r1.Cmr.CompareTo(r2.Cmr) == 0 &amp;&amp; r1.Id == r2.Id); } public static bool operator !=(Region r1, Region r2) { if (object.ReferenceEquals(r1, null)) { return false; } if (object.ReferenceEquals(r2, null)) { return false; } return (r1.Cmr.CompareTo(r2.Cmr) != 0 || r1.Id != r2.Id); } </code></pre>
[ { "answer_id": 155467, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 6, "selected": true, "text": "public static bool operator ==(Region r1, Region r2)\n{\n if (object.ReferenceEquals( r1, r2)) {\n // handle...
2008/09/30
[ "https://Stackoverflow.com/questions/155458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
155,460
<p>I'm using LINQ to SQL and C#. I have two LINQ classes: User and Network. </p> <p>User has UserID (primary key) and NetworkID</p> <p>Network has NetworkID (primary key) and an AdminID (a UserID)</p> <p>The following code works fine:</p> <pre><code>user.Network.AdminID = 0; db.SubmitChanges(); </code></pre> <p>However, if I access the AdminID before making the change, the change never happens to the DB. So the following doesn't work:</p> <pre><code>if(user.Network.AdminID == user.UserID) { user.Network.AdminID = 0; db.SubmitChanges(); } </code></pre> <p>It is making it into the if statement and calling submit changes. For some reason, the changes to AdminID never make it to the DB. No error thrown, the change just never 'takes'.</p> <p>Any idea what could be causing this?</p> <p>Thanks.</p>
[ { "answer_id": 155658, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "{\n Contact previousValue = this._Contact.Entity;\n if (((previousValue != value)\n || (this._Contact.HasLoadedOrAssigned...
2008/09/30
[ "https://Stackoverflow.com/questions/155460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23971/" ]
155,462
<p>In Ruby:</p> <pre><code>for i in A do # some code end </code></pre> <p>is the same as: </p> <pre><code>A.each do |i| # some code end </code></pre> <p><code>for</code> is not a kernel method:</p> <ul> <li>What exactly is "<code>for</code>" in ruby</li> <li>Is there a way to use other keywords to do similar things? </li> </ul> <p>Something like:</p> <pre><code> total = sum i in I {x[i]} </code></pre> <p>mapping to:</p> <pre><code> total = I.sum {|i] x[i]} </code></pre>
[ { "answer_id": 155513, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": false, "text": "for" }, { "answer_id": 155531, "author": "rampion", "author_id": 9859, "author_profile": "https://Stac...
2008/09/30
[ "https://Stackoverflow.com/questions/155462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14167/" ]
155,504
<p>I had a look in the reference doc, and Spring seems to have pretty good support for sending mail. However, I need to login to a mail account, read the messages, and download any attachments. Is downloading mail attachments supported by the Spring mail API?</p> <p>I know you can do this with the Java Mail API, but in the past I've found that very verbose and unpleasant to work with.</p> <p><strong>EDIT</strong>: I've received several replies pointing towards tutorials that describe how to send mail with attachments, but what I'm asking about is how to <strong>read</strong> attachments from <strong>received</strong> mail.</p> <p>Cheers, Don</p>
[ { "answer_id": 158511, "author": "Steven M. Cherry", "author_id": 24193, "author_profile": "https://Stackoverflow.com/users/24193", "pm_score": 5, "selected": true, "text": "/**\n * Copyright (c) 2008 Steven M. Cherry\n * All rights reserved.\n */\npackage utils.scheduled;\n\nimport j...
2008/09/30
[ "https://Stackoverflow.com/questions/155504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
155,507
<p>How exactly can I create a new directory using Emacs? What commands do I use? (If possible, please provide an example)</p>
[ { "answer_id": 155510, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 9, "selected": true, "text": "dir/to/create" }, { "answer_id": 155519, "author": "Kirk Strauser", "author_id": 32538, "author_profile": "ht...
2008/09/30
[ "https://Stackoverflow.com/questions/155507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
155,514
<p>How do I convert a utf-8 string to a utf-16 string in PHP?</p>
[ { "answer_id": 155528, "author": "chroder", "author_id": 18802, "author_profile": "https://Stackoverflow.com/users/18802", "pm_score": 4, "selected": false, "text": "mb_convert_encoding" }, { "answer_id": 901141, "author": "Jesper Grann Laursen", "author_id": 110214, ...
2008/09/30
[ "https://Stackoverflow.com/questions/155514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23598/" ]
155,517
<p>Is it possible to cancel out of a long running process in VB6.0 without using DoEvents?</p> <p>For example:</p> <pre><code>for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end if next Sub btnCancel_Click() cancel = true End Sub </code></pre> <p>I assume I need a "DoEvents" before the "if cancel then..." is there a better way? It's been awhile...</p>
[ { "answer_id": 160893, "author": "Joel Spolsky", "author_id": 4, "author_profile": "https://Stackoverflow.com/users/4", "pm_score": 6, "selected": true, "text": "DoEvents" }, { "answer_id": 206791, "author": "Shane Miskin", "author_id": 16415, "author_profile": "https...
2008/09/30
[ "https://Stackoverflow.com/questions/155517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5019/" ]
155,532
<p>Are there any good methods for getting ASP.NET 2.0 to validate under the XHTML 1.0 Strict (or Transitional) DTD? I'm interested to hear some ideas before I hack up the core of the HTTP response.</p> <p>One major problem is the form tag itself, this is the output I got from W3C when I tried to validate:</p> <pre><code>Line 13, Column 11: there is no attribute "name". &lt;form name="aspnetForm" method="post" action="Default.aspx" onsubmit="javascript </code></pre> <p>That tag is very fundamental to ASP.NET, as you all know. Hmmmm.</p>
[ { "answer_id": 156533, "author": "Calroth", "author_id": 23358, "author_profile": "https://Stackoverflow.com/users/23358", "pm_score": 5, "selected": true, "text": "<system.web>\n ... other configuration goes here ...\n <xhtmlConformance mode=\"Strict\" />\n</system.web>\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12252/" ]
155,540
<p>I'm writing a scheduler or sorts. It's basically a table with a list of exes (like "C:\a.exe") and a console app that looks at the records in the table every minute or so and runs the tasks that haven't been run yet.</p> <p>I run the tasks like this:</p> <pre><code>System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = someExe; // like "a.exe" p.Start(); </code></pre> <p>How can I tell if a particular task failed? For example what if a.exe throws an unhandled exception? I'd like the above code to know when this happens and update the tasks table with something like "the particular task failed" etc.</p> <p>How can I do this?</p> <p>I'm not using the Sql Agent or the Windows Scheduler because someone else told me not to. He has more "experience" so I'm basically just following orders. Feel free to suggest alternatives.</p>
[ { "answer_id": 155563, "author": "Pete", "author_id": 76, "author_profile": "https://Stackoverflow.com/users/76", "pm_score": 2, "selected": false, "text": "string output = p.StandardOutput.ReadToEnd();\n" }, { "answer_id": 157096, "author": "Jonathan C Dickinson", "autho...
2008/09/30
[ "https://Stackoverflow.com/questions/155540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]