qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
37,011
<p>Should you ever use protected member variables? What are the the advantages and what issues can this cause?</p>
[ { "answer_id": 194655, "author": "paercebal", "author_id": 14089, "author_profile": "https://Stackoverflow.com/users/14089", "pm_score": 2, "selected": false, "text": "template <typename T, typename TContainer>\nclass Base\n{\n // etc.\n protected\n TContainer container ;\n}\n\ntem...
2008/08/31
[ "https://Stackoverflow.com/questions/37011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3305/" ]
37,026
<p>If one Googles for "difference between <code>notify()</code> and <code>notifyAll()</code>" then a lot of explanations will pop up (leaving apart the javadoc paragraphs). It all boils down to the number of waiting threads being waken up: one in <code>notify()</code> and all in <code>notifyAll()</code>.</p> <p>However (if I do understand the difference between these methods right), only one thread is always selected for further monitor acquisition; in the first case the one selected by the VM, in the second case the one selected by the system thread scheduler. The exact selection procedures for both of them (in the general case) are not known to the programmer.</p> <p>What's the <strong>useful</strong> difference between <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#notify%28%29" rel="noreferrer">notify()</a> and <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#notifyAll%28%29" rel="noreferrer">notifyAll()</a> then? Am I missing something?</p>
[ { "answer_id": 37038, "author": "Spoike", "author_id": 3713, "author_profile": "https://Stackoverflow.com/users/3713", "pm_score": 2, "selected": false, "text": "notify()" }, { "answer_id": 37046, "author": "Liedman", "author_id": 890, "author_profile": "https://Stack...
2008/08/31
[ "https://Stackoverflow.com/questions/37026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3894/" ]
37,029
<p>It is generally accepted that the use of cursors in stored procedures should be avoided where possible (replaced with set based logic etc). If you take the cases where you need to iterate over some data, and can do in a read only manner, are fast forward (read only forward) cursor more or less inefficient than say while loops? From my investigations it looks as though the cursor option is generally faster and uses less reads and cpu time. I haven't done any extensive testing, but is this what others find? Do cursors of this type (fast forward) carry additional overhead or resource that could be expensive that I don't know about.</p> <p>Is all the talk about not using cursors really about avoiding the use of cursors when set-based approaches are available, and the use of updatable cursors etc.</p>
[ { "answer_id": 461370, "author": "Miles D", "author_id": 3898, "author_profile": "https://Stackoverflow.com/users/3898", "pm_score": 2, "selected": false, "text": "SELECT" }, { "answer_id": 27359172, "author": "Fabiano Novaes Ferreira", "author_id": 4337447, "author_p...
2008/08/31
[ "https://Stackoverflow.com/questions/37029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3898/" ]
37,041
<p>I have a question on the best way of exposing an asynchronous remote interface.</p> <p>The conditions are as follows:</p> <ul> <li>The protocol is asynchronous</li> <li>A third party can modify the data at any time</li> <li>The command round-trip can be significant</li> <li>The model should be well suited for UI interaction</li> <li>The protocol supports queries over certain objects, and so must the model</li> </ul> <p>As a means of improving my lacking skills in this area (and brush up my Java in general), I have started a <a href="http://Telharmonium.devjavu.com/" rel="nofollow noreferrer">project</a> to create an Eclipse-based front-end for <a href="http://xmms2.xmms.se" rel="nofollow noreferrer">xmms2</a> (described below).</p> <p>So, the question is; how should I expose the remote interface as a neat data model (In this case, track management and event handling)?</p> <p>I welcome anything from generic discussions to pattern name-dropping or concrete examples and patches :)</p> <hr> <p>My primary goal here is learning about this class of problems in general. If my project can gain from it, fine, but I present it strictly to have something to start a discussion around.</p> <p>I've implemented a protocol abstraction which I call <a href="http://telharmonium.devjavu.com/browser/trunk/xmms2-client" rel="nofollow noreferrer">'client'</a> (for legacy reasons) which allows me to access most exposed features using method calls which I am happy with even if it's far from perfect.</p> <p>The features provided by the xmms2 daemon are things like track searching, meta-data retrieval and manipulation, change playback state, load playlists and so on and so forth.</p> <p>I'm in the middle of updating to the latest stable release of xmms2, and I figured I might as well fix some of the glaring weaknesses of my current implementation.</p> <p>My plan is to build a better abstraction on top of the protocol interface, one that allows a more natural interaction with the daemon. The current <a href="http://telharmonium.devjavu.com/browser/trunk/xmms2-model" rel="nofollow noreferrer">'model'</a> implementation is hard to use and is frankly quite ugly (not to mention the UI-code which is truly horrible atm).</p> <p>Today I have the <a href="http://telharmonium.devjavu.com/browser/trunk/xmms2-model/src/se/fnord/xmms2/model/Tracks.java" rel="nofollow noreferrer">Tracks</a> interface which I can use to get instances of <a href="http://telharmonium.devjavu.com/browser/trunk/xmms2-model/src/se/fnord/xmms2/model/Track.java" rel="nofollow noreferrer">Track</a> classes based on their id. Searching is performed through the <a href="http://telharmonium.devjavu.com/browser/trunk/xmms2-model/src/se/fnord/xmms2/model/Collections.java" rel="nofollow noreferrer">Collections</a> interface (unfortunate namespace clash) which I'd rather move to Tracks, I think.</p> <p>Any data can be modified by a third party at any time, and this should be properly reflected in the model and change-notifications distributed</p> <p>These interfaces are exposed when connecting, by returning an object hierarchy that looks like this:</p> <ul> <li>Connection <ul> <li>Playback getPlayback() <ul> <li>Play, pause, jump, current track etc</li> <li>Expose playback state changes</li> </ul></li> <li>Tracks getTracks() <ul> <li>Track getTrack(id) etc</li> <li>Expose track updates</li> </ul></li> <li>Collections getCollection() <ul> <li>Load and manipulate playlists or named collections</li> <li>Query media library</li> <li>Expose collection updates</li> </ul></li> </ul></li> </ul>
[ { "answer_id": 37093, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": 3, "selected": true, "text": "java.util.concurrent" }, { "answer_id": 37123, "author": "Henrik Gustafsson", "author_id": 2010, "author_pr...
2008/08/31
[ "https://Stackoverflow.com/questions/37041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2010/" ]
37,048
<p>Can anyone advise on how to crop an image, let's say jpeg, without using any .NET framework constructs, just raw bytes? Since this is the only* way in Silverlight...</p> <p>Or point to a library?</p> <p>I'm not concerned with rendering i'm wanting to manipulate a jpg before uploading.</p> <p>*There are no GDI+(System.Drawing) or WPF(System.Windows.Media.Imaging) libraries available in Silverlight.</p> <p>Lockbits requires GDI+, clarified question</p> <p>Using fjcore: <a href="http://code.google.com/p/fjcore/" rel="nofollow noreferrer">http://code.google.com/p/fjcore/</a> to resize but no way to crop :(</p>
[ { "answer_id": 97669, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 2, "selected": false, "text": "for (int y = 0; y < _newHeight; y++)\n{\n i_sY = (int)sY; sX = 0;\n\n UpdateProgress((double)y / _newHeight);\n\n ...
2008/08/31
[ "https://Stackoverflow.com/questions/37048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580/" ]
37,053
<p>I'm trying to find out the 'correct' windows API for finding out the localized name of 'special' folders, specifically the Recycle Bin. I want to be able to prompt the user with a suitably localized dialog box asking them if they want to send files to the recycle bin or delete them directly.</p> <p>I've found lots on the internet (and on Stackoverflow) about how to do the actual deletion, and it seems simple enough, I just really want to be able to have the text localized.</p>
[ { "answer_id": 7417694, "author": "ladenedge", "author_id": 222481, "author_profile": "https://Stackoverflow.com/users/222481", "pm_score": 0, "selected": false, "text": "public static string GetLocalizedRecycleBinName()\n{\n IntPtr relative_pidl, parent_ptr, absolute_pidl;\n\n PInvo...
2008/08/31
[ "https://Stackoverflow.com/questions/37053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1849/" ]
37,056
<p>I'm setting up a web application with a FreeBSD PostgreSQL back-end. I'm looking for some database performance optimization tool/technique.</p>
[ { "answer_id": 65180, "author": "brianestes", "author_id": 8993, "author_profile": "https://Stackoverflow.com/users/8993", "pm_score": 2, "selected": false, "text": "#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements\n #...
2008/08/31
[ "https://Stackoverflow.com/questions/37056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313/" ]
37,069
<p>On Mac OS X 10.5 I downloaded the latest version of Apache 2.2.9. After the usual configure, make, make install dance I had a build of apache without mod_rewrite. This wasn't statically linked and the module was not built in the /modules folder either.</p> <p>I had to do the following to build Apache and mod_rewrite:</p> <pre><code>./configure --prefix=/usr/local/apache2 --enable-rewrite=shared </code></pre> <ul> <li>Is there a way to tell Apache to build all modules as Shared Modules (DSOs) so I can control loading from the Apache config?</li> <li>Now that I have built Apache and the mod_rewrite DSO, how can I build another shared module without building all of Apache?</li> </ul> <p>(The last time I built Apache (2.2.8) on Solaris, by default it built everything as a shared module.)</p>
[ { "answer_id": 37111, "author": "Brendan", "author_id": 199, "author_profile": "https://Stackoverflow.com/users/199", "pm_score": 5, "selected": true, "text": "./configure" }, { "answer_id": 9094896, "author": "so_mv", "author_id": 186858, "author_profile": "https://S...
2008/08/31
[ "https://Stackoverflow.com/questions/37069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636/" ]
37,070
<p>This is a somewhat low-level question. In x86 assembly there are two SSE instructions: </p> <blockquote> <p><code>MOVDQA <i><em>xmmi, m128</em></i></code></p> </blockquote> <p>and </p> <blockquote> <p><code>MOVNTDQA <i><em>xmmi, m128</em></i></code></p> </blockquote> <p>The IA-32 Software Developer's Manual says that the <em>NT</em> in MOVNTDQA stands for <em>Non-Temporal</em>, and that otherwise it's the same as MOVDQA.</p> <p>My question is, what does <em>Non-Temporal</em> mean? </p>
[ { "answer_id": 53199688, "author": "chus", "author_id": 1037634, "author_profile": "https://Stackoverflow.com/users/1037634", "pm_score": 4, "selected": false, "text": "prefetchnta" } ]
2008/08/31
[ "https://Stackoverflow.com/questions/37070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
37,073
<p>What is currently the best way to get a favicon to display in all browsers that currently support it?</p> <p>Please include:</p> <ol> <li><p>Which image formats are supported by which browsers.</p></li> <li><p>Which lines are needed in what places for the various browsers.</p></li> </ol>
[ { "answer_id": 37076, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": false, "text": "favicon.*" }, { "answer_id": 37091, "author": "John Topley", "author_id": 1450, "author_profile": "https://S...
2008/08/31
[ "https://Stackoverflow.com/questions/37073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/177/" ]
37,089
<p>When launching a thread or a process in .NET or Java, is there a way to choose which processor or core it is launched on? How does the shared memory model work in such cases?</p>
[ { "answer_id": 37117, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 2, "selected": false, "text": "Processes" }, { "answer_id": 37127, "author": "sieben", "author_id": 1147, "author_profile": "https:/...
2008/08/31
[ "https://Stackoverflow.com/questions/37089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/646/" ]
37,095
<p>How do I avoid read locks in my database?</p> <p>Answers for multiple databases welcome!</p>
[ { "answer_id": 37099, "author": "Joe Barone", "author_id": 3452, "author_profile": "https://Stackoverflow.com/users/3452", "pm_score": 2, "selected": false, "text": "Select table1.columna, table2.columna\nfrom table1 with(nolock), table2 with(nolock)\n" } ]
2008/08/31
[ "https://Stackoverflow.com/questions/37095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
37,101
<p>Is there a way clear or reset the outputcache for an entire website without a restart?</p> <p>I'm just starting to use outputcache on a site and when I make a mistake in setting it up I need a page I can browse to that will reset it.</p>
[ { "answer_id": 37167, "author": "Ethan Gunderson", "author_id": 2066, "author_profile": "https://Stackoverflow.com/users/2066", "pm_score": 4, "selected": true, "text": "Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)\n\n Dim path As String\n path=\"/Abosol...
2008/08/31
[ "https://Stackoverflow.com/questions/37101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
37,103
<p>I have a container div with a fixed <code>width</code> and <code>height</code>, with <code>overflow: hidden</code>.</p> <p>I want a horizontal row of float: left divs within this container. Divs which are floated left will naturally push onto the 'line' below after they read the right bound of their parent. This will happen even if the <code>height</code> of the parent should not allow this. This is how this looks:</p> <p><img src="https://i.stack.imgur.com/v2x7d.png" alt="Wrong" /></p> <p>How I would like it to look:</p> <p>![Right][2] - <em>removed image shack image that had been replaced by an advert</em></p> <p>Note: the effect I want can be achieved by using inline elements &amp; <code>white-space: no-wrap</code> (that is how I did it in the image shown). This, however, is no good to me (for reasons too lengthy to explain here), as the child divs need to be floated block level elements.</p>
[ { "answer_id": 37125, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 3, "selected": false, "text": "#foo {\n background: red;\n max-height: 100px;\n overflow-y: hidden;\n}\n\n.bar {\n background: blue;\n width: 100p...
2008/08/31
[ "https://Stackoverflow.com/questions/37103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1349865/" ]
37,104
<p>What's are the best practices for versioning web sites?</p> <ul> <li>Which revision control systems are well suited for such a job?</li> <li>What special-purpose tools exist?</li> <li>What other questions should I be asking?</li> </ul>
[ { "answer_id": 37147, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": 2, "selected": false, "text": "<?php print(\"$Revision: 1 $\"); ?>\n" } ]
2008/08/31
[ "https://Stackoverflow.com/questions/37104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
37,122
<p>How do I make a user's browser blink/flash/highlight in the task bar using JavaScript? For example, if I make an AJAX request every 10 seconds to see if the user has any new messages on the server, I want the user to know it right away, even if he is using another application at the time.</p> <p><em>Edit: These users do want to be distracted when a new message arrives.</em></p>
[ { "answer_id": 37283, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 1, "selected": false, "text": "document.title = \"[user] hello world\";\n" }, { "answer_id": 156274, "author": "nickf", "author_id": 9...
2008/08/31
[ "https://Stackoverflow.com/questions/37122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191/" ]
37,142
<p>Even though <a href="http://twistedmatrix.com/pipermail/twisted-python/2004-May/007896.html" rel="noreferrer">Python</a> and <a href="http://www.reddit.com/comments/6wmum/thread_safe_ruby_on_rails_in_22_release/" rel="noreferrer">Ruby</a> have one kernel thread per interpreter thread, they have a global interpreter lock (GIL) that is used to protect potentially shared data structures, so this inhibits multi-processor execution. Even though the portions in those languajes that are written in C or C++ can be free-threaded, that's not possible with pure interpreted code unless you use multiple processes. What's the best way to achieve this? <a href="http://blogs.codehaus.org/people/tirsen/archives/001041_ruby_on_rails_and_fastcgi_scaling_using_processes_instead_of_threads.html" rel="noreferrer">Using FastCGI</a>? Creating a <a href="http://blog.innerewut.de/files/images/stage_2.png" rel="noreferrer">cluster or a farm</a> of virtualized servers? Using their Java equivalents, JRuby and Jython?</p>
[ { "answer_id": 37146, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "mod_wsgi" }, { "answer_id": 191257, "author": "David Eyk", "author_id": 18950, "author_profile": "h...
2008/08/31
[ "https://Stackoverflow.com/questions/37142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3855/" ]
37,162
<p>We generate web pages that should always be printed in landscape mode. Web browser print dialogs default to portrait, so for every print job the user has to manually select landscape. It's minor, but would be nice for the user if we can remove this unnecessary step. </p> <p>Thanks in advance to all respondents.</p>
[ { "answer_id": 37168, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "@page" } ]
2008/08/31
[ "https://Stackoverflow.com/questions/37162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3915/" ]
37,198
<ol> <li>Specifically getting on Windows the "..\Documents &amp; Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. <strong>(Now I need the answer to this)</strong></li> <li>the current users My Documents dirctory <strong>(okay this has been answered)</strong> and basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on.</li> </ol>
[ { "answer_id": 37240, "author": "nimish", "author_id": 3926, "author_profile": "https://Stackoverflow.com/users/3926", "pm_score": 3, "selected": false, "text": "System.getProperty(\"user.home\");\n" }, { "answer_id": 37693, "author": "Lee Theobald", "author_id": 1900, ...
2008/08/31
[ "https://Stackoverflow.com/questions/37198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3576/" ]
37,219
<p>Suppose your git history looks like this:</p> <p>1 2 3 4 5</p> <p>1–5 are separate revisions. You need to remove 3 while still keeping 1, 2, 4 and 5. How can this be done?</p> <p>Is there an efficient method when there are hundreds of revisions after the one to be deleted?</p>
[ { "answer_id": 37267, "author": "garethm", "author_id": 2219, "author_profile": "https://Stackoverflow.com/users/2219", "pm_score": 7, "selected": true, "text": "git rebase -i <after-this-commit>" }, { "answer_id": 3705310, "author": "rado", "author_id": 127388, "auth...
2008/08/31
[ "https://Stackoverflow.com/questions/37219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
37,248
<p>While the C# spec does include a pre-processor and basic directives (#define, #if, etc), the language does not have the same flexible pre-processor found in languages such as C/C++. I believe the lack of such a flexible pre-processor was a design decision made by Anders Hejlsberg (although, unfortunately, I can't find reference to this now). From experience, this is certainly a good decision, as there were some really terrible un-maintainable macros created back when I was doing a lot of C/C++. </p> <p>That said, there are a number of scenarios where I could find a slightly more flexible pre-processor to be useful. Code such as the following could be improved by some simple pre-processor directives:</p> <pre><code>public string MyProperty { get { return _myProperty; } set { if (value != _myProperty) { _myProperty = value; NotifyPropertyChanged("MyProperty"); // This line above could be improved by replacing the literal string with // a pre-processor directive like "#Property", which could be translated // to the string value "MyProperty" This new notify call would be as follows: // NotifyPropertyChanged(#Property); } } } </code></pre> <p>Would it be a good idea to write a pre-processor to handle extremely simple cases like this? Steve McConnell wrote in <a href="https://rads.stackoverflow.com/amzn/click/com/0735619670" rel="nofollow noreferrer" rel="nofollow noreferrer">Code Complete</a> (p208):</p> <blockquote> <p><em>Write your own preprocessor</em> If a language doesn't include a preprocessor, it's fairly easy to write one...</p> </blockquote> <p>I am torn. It was a design decision to leave such a flexible pre-processor out of C#. However, an author I highly respect mentions it may be ok in some circumstances.</p> <p><strong>Should I build a C# pre-processor? Is there one available that does the simple things I want to do?</strong></p>
[ { "answer_id": 37941, "author": "Timbo", "author_id": 1810, "author_profile": "https://Stackoverflow.com/users/1810", "pm_score": 1, "selected": false, "text": "public static string GetNameOfCurrentMethod()\n{\n // Skip 1 frame (this method call)\n var trace = new System.Diagnostic...
2008/08/31
[ "https://Stackoverflow.com/questions/37248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/708/" ]
37,275
<p>What is the SQL query to select all of the MSSQL Server's logins?</p> <p>Thank you. More than one of you had the answer I was looking for:</p> <pre><code>SELECT * FROM syslogins </code></pre>
[ { "answer_id": 37280, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": false, "text": "EXEC sp_helplogins\n" }, { "answer_id": 37284, "author": "GateKiller", "author_id": 383, "author_prof...
2008/08/31
[ "https://Stackoverflow.com/questions/37275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208/" ]
37,299
<p>What's the instruction to cause a hard-break in Xcode? For example under Visual Studio I could do '_asm int 3' or 'DebugBreak()'. Under some GCC implementations it's asm("break 0") or asm("trap").</p> <p>I've tried various combos under Xcode without any luck. (inline assembler works fine so it's not a syntax issue).</p> <p>For reference this is for an assert macro. I don't want to use the definitions in assert.h both for portability, and because they appear to do an abort() in the version XCode provides.</p> <hr> <p>John - Super, cheers. For reference the int 3 syntax is the one required for Intel Macs and iPhone.</p> <hr> <p>Chris - Thanks for your comment but there are many reasons to avoid the standard assert() function for codebases ported to different platforms. If you've gone to the trouble of rolling your own assert it's usually because you have additional functionality (logging, stack unwinding, user-interaction) that you wish to retain.</p> <p>Your suggestion of attempting to replace the hander via an implementation of '__assert" or similar is not going to be portable. The standard 'assert' is usually a macro and while it may map to __assert on the Mac it doesn't on other platforms.</p>
[ { "answer_id": 37304, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 6, "selected": true, "text": "asm {trap} ; Halts a program running on PPC32 or PPC64.\n\n__asm {int 3} ; Halts a program running on...
2008/09/01
[ "https://Stackoverflow.com/questions/37299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1043/" ]
37,310
<p>I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly?</p> <p>I would like to know the answer in Java, but if there is a solution that crosses languages I would like to know it.</p> <p>Number 2. in the answer, would be done like the other answer? If so I will mark the other answer accepted as well and reword my question to adress both a factory where an interface is returned and you have no clue what type of concrete class implemented the interface, and the case where you do know what concrete class was used.</p>
[ { "answer_id": 37316, "author": "Cem Catikkas", "author_id": 3087, "author_profile": "https://Stackoverflow.com/users/3087", "pm_score": 6, "selected": true, "text": "IMyInterface fromFactory = factory.create(...); \nAssert.assertTrue(fromFactory instanceof MyInterfaceImpl1);\n" }, ...
2008/09/01
[ "https://Stackoverflow.com/questions/37310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3576/" ]
37,317
<p>I'm working on a windows forms application (C#) where a user is entering data in a form. At any point while editing the data in the form the user can click one of the buttons on the form to perform certain actions. By default the focus goes to the clicked button so the user has to click back on to the control they want to edit in order to continue modifying the data on the form. What I need to be able to do is return the focus to the last edited control after the button click event has been processed. Here's a sample screenshot that illustrates what I'm talking about:</p> <p><img src="https://lh6.ggpht.com/joe.r.barone/SLs4KZMBqfI/AAAAAAAABNw/P6xtqhCo8Y4/s800/SampleApp1.jpg" alt="Sample App Screen Shot"></p> <p>The user can be entering data in textbox1, textbox2, textbox3, etc and click the button. I need the button to return the focus back to the control that most recently had the focus before the button was clicked.</p> <p>I'm wondering if anyone has a better way of implementing this functionality than what I've come up with. Here's what I'm doing right now:</p> <pre><code> public partial class Form1 : Form { Control _lastEnteredControl; private void textBox_Enter(object sender, EventArgs e) { _lastEnteredControl = (Control)sender; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Do something here"); _lastEnteredControl.Focus(); } } </code></pre> <p>So basically what we have here is a class variable that points to the last entered control. Each textbox on the form is setup so the textBox_Enter method is fired when the control receives the focus. Then, when the button is clicked focus is returned to the control that had the focus before the button was clicked. Anybody have any more elegant solutions for this?</p>
[ { "answer_id": 37331, "author": "Dan Herbert", "author_id": 392, "author_profile": "https://Stackoverflow.com/users/392", "pm_score": 1, "selected": false, "text": "private void Form_OnLoad(object obj, EventArgs e)\n{\n AddGotFocusListener(this);\n}\n\nprivate void AddGotFocusListener...
2008/09/01
[ "https://Stackoverflow.com/questions/37317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3452/" ]
37,324
<p>I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an <code>ON</code> clause in C#.</p> <p>How do you represent the following in LINQ to SQL:</p> <pre><code>select DealerContact.* from Dealer inner join DealerContact on Dealer.DealerID = DealerContact.DealerID </code></pre>
[ { "answer_id": 37332, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 10, "selected": true, "text": "from t1 in db.Table1\njoin t2 in db.Table2 on t1.field equals t2.field\nselect new { t1.field2, t2.field3}\n" }, { "...
2008/09/01
[ "https://Stackoverflow.com/questions/37324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
37,335
<p>I am writing a client-side <strong>Swing</strong> application (graphical font designer) on <strong>Java 5</strong>. Recently, I am running into <code>java.lang.OutOfMemoryError: Java heap space</code> error because I am not being conservative on memory usage. The user can open unlimited number of files, and the program keeps the opened objects in the memory. After a quick research I found <a href="http://java.sun.com/docs/hotspot/gc5.0/ergo5.html" rel="noreferrer">Ergonomics in the 5.0 Java Virtual Machine</a> and others saying on Windows machine the JVM defaults max heap size as <code>64MB</code>.</p> <p>Given this situation, how should I deal with this constraint?</p> <p>I could increase the <strong>max heap size</strong> using <strong>command line</strong> option to java, but that would require figuring out available RAM and writing some launching program or script. Besides, increasing to some <strong>finite</strong> max does not <strong>ultimately</strong> get rid of the issue.</p> <p>I could rewrite some of my code to persist objects to file system frequently (using database is the same thing) to free up the memory. It could work, but it's probably a lot work too.</p> <p>If you could point me to details of above ideas or some alternatives like <strong>automatic virtual memory, extending heap size dynamically</strong>, that will be great.</p>
[ { "answer_id": 37349, "author": "Ben Childs", "author_id": 2925, "author_profile": "https://Stackoverflow.com/users/2925", "pm_score": 9, "selected": true, "text": "2GB" }, { "answer_id": 37466, "author": "David Webb", "author_id": 3171, "author_profile": "https://Sta...
2008/09/01
[ "https://Stackoverflow.com/questions/37335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3827/" ]
37,346
<p>If I create a class like so: </p> <pre><code>// B.h #ifndef _B_H_ #define _B_H_ class B { private: int x; int y; }; #endif // _B_H_ </code></pre> <p>and use it like this:</p> <pre><code>// main.cpp #include &lt;iostream&gt; #include &lt;vector&gt; class B; // Forward declaration. class A { public: A() { std::cout &lt;&lt; v.size() &lt;&lt; std::endl; } private: std::vector&lt;B&gt; v; }; int main() { A a; } </code></pre> <p>The compiler fails when compiling <code>main.cpp</code>. Now the solution I know is to <code>#include "B.h"</code>, but I'm curious as to why it fails. Neither <code>g++</code> or <code>cl</code>'s error messages were very enlightening in this matter.</p>
[ { "answer_id": 37348, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 6, "selected": true, "text": "std::vector<B*>" }, { "answer_id": 14010890, "author": "daotheman", "author_id": 1924938, "author_p...
2008/09/01
[ "https://Stackoverflow.com/questions/37346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
37,374
<p>We've just started using LINQ to SQL at work for our DAL &amp; we haven't really come up with a standard for out caching model. Previously we had being using a base 'DAL' class that implemented a cache manager property that all our DAL classes inherited from, but now we don't have that. I'm wondering if anyone has come up with a 'standard' approach to caching LINQ to SQL results?</p> <p>We're working in a web environment (IIS) if that makes a difference. I know this may well end up being a <a href="https://stackoverflow.com/questions/tagged/subjective">subjective</a> question, but I still think the info would be valuable.</p> <p><strong>EDIT:</strong> To clarify, I'm not talking about caching an individual result, I'm after more of an architecture solution, as in how do you set up caching so that all your link methods use the same caching architecture.</p>
[ { "answer_id": 37432, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 2, "selected": false, "text": "List<TableItem> myResult = (from t in db.Table select t).ToList();\n" }, { "answer_id": 357970, "author": "Pete ...
2008/09/01
[ "https://Stackoverflow.com/questions/37374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
37,375
<p>We have a whole bunch of DLLs that give us access to our database and other applications and services.</p> <p>We've wrapped these DLLs with a thin WCF service layer which our clients then consume.</p> <p>I'm a little unsure on how to write unit tests that only test the WCF service layer. Should I just write unit tests for the DLLs, and integration tests for the WCF services? I'd appreciate any wisdom... I know that if my unit tests actually go to the database they won't actually be true unit tests. I also understand that I don't really need to test the WCF service host in a unit test. </p> <p>So, I'm confused about exactly what to test and how.</p>
[ { "answer_id": 37385, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 3, "selected": false, "text": "Public Class ProductService\n Implements IProductService\n\n Private mRepository As IProductRepository\n\n Pub...
2008/09/01
[ "https://Stackoverflow.com/questions/37375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
37,378
<p>Everyone I work with is obsessed with the data-centric approach to enterprise development and hates the idea of using custom collections/objects. What is the best way to convince them otherwise?</p>
[ { "answer_id": 37475, "author": "Brian Leahy", "author_id": 580, "author_profile": "https://Stackoverflow.com/users/580", "pm_score": 1, "selected": false, "text": "Collection<T>" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
37,381
<p>I'm exploring the possibility of writing an application in Erlang, but it would need to have a portion written in Cocoa (presumably Objective-C). I'd like the front-end and back-end to be able to communicate easily. How can this best be done?</p> <p>I can think of using C ports and connected processes, but I think I'd like a reverse situation (the front-end starting and connecting to the back-end). There are named pipes (FIFOs), or I could use network communications over a TCP port or a named BSD socket. Does anyone have experience in this area?</p>
[ { "answer_id": 37408, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 4, "selected": true, "text": "launchd" }, { "answer_id": 37683, "author": "Theo", "author_id": 1109, "author_profile": "https://Stack...
2008/09/01
[ "https://Stackoverflow.com/questions/37381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3948/" ]
37,391
<p>Ok, so PHP isn't the best language to be dealing with arbitrarily large integers in, considering that it only natively supports 32-bit signed integers. What I'm trying to do though is create a class that could represent an arbitrarily large binary number and be able to perform simple arithmetic operations on two of them (add/subtract/multiply/divide).</p> <p>My target is dealing with 128-bit integers.</p> <p>There's a couple of approaches I'm looking at, and problems I see with them. Any input or commentary on what you would choose and how you might go about it would be greatly appreciated.</p> <p><strong>Approach #1:</strong> Create a 128-bit integer class that stores its integer internally as four 32-bit integers. The only problem with this approach is that I'm not sure how to go about handling overflow/underflow issues when manipulating individual chunks of the two operands.</p> <p><strong>Approach #2:</strong> Use the bcmath extension, as this looks like something it was designed to tackle. My only worry in taking this approach is the scale setting of the bcmath extension, because there can't be any rounding errors in my 128-bit integers; they must be precise. I'm also worried about being able to eventually convert the result of the bcmath functions into a binary string (which I'll later need to shove into some mcrypt encryption functions).</p> <p><strong>Approach #3:</strong> Store the numbers as binary strings (probably LSB first). Theoretically I should be able to store integers of any arbitrary size this way. All I would have to do is write the four basic arithmetic functions to perform add/sub/mult/div on two binary strings and produce a binary string result. This is exactly the format I need to hand over to mcrypt as well, so that's an added plus. This is the approach I think has the most promise at the moment, but the one sticking point I've got is that PHP doesn't offer me any way to manipulate the individual bits (that I know of). I believe I'd have to break it up into byte-sized chunks (no pun intended), at which point my questions about handling overflow/underflow from Approach #1 apply.</p>
[ { "answer_id": 1381855, "author": "Jonathon Hill", "author_id": 168815, "author_profile": "https://Stackoverflow.com/users/168815", "pm_score": 3, "selected": true, "text": "gmp_strval(gmp_init($n, 10), 2);\n" }, { "answer_id": 20730795, "author": "Alix Axel", "author_id"...
2008/09/01
[ "https://Stackoverflow.com/questions/37391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384/" ]
37,441
<p>Why are SQL distributions so non-standard despite an ANSI standard existing for SQL? Are there really that many meaningful differences in the way SQL databases work or is it just the two databases with which I have been working: MS-SQL and PostgreSQL? Why do these differences arise?</p>
[ { "answer_id": 37443, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "AUTO INCREMENT" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
37,449
<p>I've used the StAX API in Java quite a bit, and find it quite a clean way of dealing with XML files. Is there any equivalent library I could use for performing similar processing in C?</p>
[ { "answer_id": 465382, "author": "OJW", "author_id": 46478, "author_profile": "https://Stackoverflow.com/users/46478", "pm_score": -1, "selected": false, "text": "\n #include \"expat.h\"`\nVRM_parser = XML_ParserCreate(\"ISO-8859-1\");\nXML_SetElementHandler(VRM_parser, CbStartTagHandler...
2008/09/01
[ "https://Stackoverflow.com/questions/37449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
37,464
<p>If I create an application on my Mac, is there any way I can get it to run on an iPhone without going through the app store?</p> <p>It doesn't matter if the iPhone has to be jailbroken, as long as I can still run an application created using the official SDK. For reasons I won't get into, I can't have this program going through the app store.</p>
[ { "answer_id": 37522, "author": "Jason Weathered", "author_id": 3736, "author_profile": "https://Stackoverflow.com/users/3736", "pm_score": 9, "selected": true, "text": "openssh" }, { "answer_id": 2671953, "author": "Mattias Wadman", "author_id": 56686, "author_profil...
2008/09/01
[ "https://Stackoverflow.com/questions/37464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/752/" ]
37,468
<p>I have a site running in a Windows shared hosting environment. In their control panel for the shared hosting account I have it set to use ASP.NET version 3.0 but it doesn't say 3.5 SP1 specifically.</p> <p>How can I view the installed version running on the server where my website is hosted in an asp.net page?</p>
[ { "answer_id": 6564854, "author": "JanBorup", "author_id": 276414, "author_profile": "https://Stackoverflow.com/users/276414", "pm_score": 1, "selected": false, "text": "<%=Environment.Version%>" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
37,471
<p>The minimum spanning tree problem is to take a connected weighted graph and find the subset of its edges with the lowest total weight while keeping the graph connected (and as a consequence resulting in an acyclic graph).</p> <p>The algorithm I am considering is:</p> <ul> <li>Find all cycles.</li> <li>remove the largest edge from each cycle.</li> </ul> <p>The impetus for this version is an environment that is restricted to "rule satisfaction" without any iterative constructs. It might also be applicable to insanely parallel hardware (i.e. a system where you expect to have several times more degrees of parallelism then cycles).</p> <p>Edits:</p> <p>The above is done in a stateless manner (all edges that are not the largest edge in any cycle are selected/kept/ignored, all others are removed).</p>
[ { "answer_id": 37477, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 1, "selected": false, "text": "V = { a, b, c, d }\nE = { (a,b,1), (b,c,2), (c,a,4), (b,d,9), (d,a,3) }\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
37,473
<p>If I use <code>assert()</code> and the assertion fails then <code>assert()</code> will call <code>abort()</code>, ending the running program abruptly. I can't afford that in my production code. Is there a way to assert in runtime yet be able to catch failed assertions so I have the chance to handle them gracefully?</p>
[ { "answer_id": 37474, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 6, "selected": true, "text": "assert()" }, { "answer_id": 168611, "author": "indiv", "author_id": 19719, "author_profile": "https://St...
2008/09/01
[ "https://Stackoverflow.com/questions/37473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/456/" ]
37,479
<p>Below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name.</p> <pre><code>import cgi class ClassX(object): pass # ... with own __repr__ class ClassY(object): pass # ... with own __repr__ inst_x=ClassX() inst_y=ClassY() inst_z=[ i*i for i in range(25) ] inst_b=True class HTMLDecorator(object): def html(self): # an "enhanced" version of __repr__ return cgi.escape(self.__repr__()).join(("&lt;H1&gt;","&lt;/H1&gt;")) print HTMLDecorator(inst_x).html() print HTMLDecorator(inst_y).html() wrapped_z = HTMLDecorator(inst_z) inst_z[0] += 70 wrapped_z[0] += 71 print wrapped_z.html() print HTMLDecorator(inst_b).html() </code></pre> <p>Output:</p> <pre>Traceback (most recent call last): File "html.py", line 21, in print HTMLDecorator(inst_x).html() TypeError: default __new__ takes no parameters</pre> <p>Is what I'm trying to do possible? If so, what am I doing wrong?</p>
[ { "answer_id": 37488, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 0, "selected": false, "text": "HTMLDecorator.__init__()" }, { "answer_id": 37513, "author": "Harley Holcombe", "author_id": 1057, ...
2008/09/01
[ "https://Stackoverflow.com/questions/37479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1057/" ]
37,483
<p>I suck at math. I need to figure out how to calculate a video duration with only a few examples of values. For example, a value of 70966 is displayed as 1:10 minutes. A value of 30533 displays as 30 seconds. A value of 7007 displays as 7 seconds. </p>
[ { "answer_id": 37487, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 0, "selected": false, "text": " 70966 / 70 seconds = 1013.8\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2601/" ]
37,486
<p>Because regular expressions scare me, I'm trying to find a way to remove all HTML tags and resolve HTML entities from a string in Python.</p>
[ { "answer_id": 37504, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 1, "selected": false, "text": " <div>5 < 7</div>\n" }, { "answer_id": 37512, "author": "Peter Hoffmann", "author_id": 720, "author_pro...
2008/09/01
[ "https://Stackoverflow.com/questions/37486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3971/" ]
37,495
<p>I'm trying to get some stats on how many of the visitors to our website have Silverlight enabled browsers. </p> <p>We currently use Google Analytics for the rest of our stats so ideally we'd like to just add 'Silverlight enabled' tracking in with the rest of our Google Analytics stats. But if it has to get written out to a DB etc then so be it. </p> <p>Nikhil has <a href="http://www.nikhilk.net/Silverlight-Analytics.aspx" rel="nofollow noreferrer">some javascript</a> to Silverlight tracking to Google Analytics. I have tried this code but Google Analytics doesn't pick it up.</p> <p>Does anyone have any other ideas/techniques?</p>
[ { "answer_id": 3323399, "author": "mdarnall", "author_id": 42998, "author_profile": "https://Stackoverflow.com/users/42998", "pm_score": 0, "selected": false, "text": "__utmSetVar()" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242/" ]
37,501
<p>Thanks to a Q&amp;A on stackoverflow. I just found out how to determine the installed version on my hosting provider's server. Now I need to know what that number means.</p> <p>Using <code>&lt;%=Environment.Version%&gt;</code> on my local machine returns 2.0.50727.3053.</p> <p>Can someone give me a list of the version 1, 1.1, 2, etc. to the actual <code>Environment.Version</code> codes or break down what that code means?</p>
[ { "answer_id": 56390256, "author": "RBT", "author_id": 465053, "author_profile": "https://Stackoverflow.com/users/465053", "pm_score": 0, "selected": false, "text": "<%=Environment.Version%>" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
37,525
<p>Imagine we have a program trying to write to a particular file, but failing.</p> <p>On the Windows platform, what are the possible things which might be causing the file to be un-writable, and what steps could be suggested to an end user/administrator to fix it.</p> <hr /> <p>Please include steps which might require administrator permissions (obviously users may not be administrators, but for this question, let's assume they are (or can become) administrators.</p> <p>Also, I'm not really familiar with how permissions are calculated in windows. - Does the user need write access to each directory up the tree, or anything similar to that?</p>
[ { "answer_id": 37527, "author": "Michael Ratanapintha", "author_id": 1879, "author_profile": "https://Stackoverflow.com/users/1879", "pm_score": 3, "selected": true, "text": "attrib -r" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
37,529
<p>I'd like to pull a stream of PCM samples from a Mac's line-in or built-in mic and do a little live analysis (the exact nature doesn't pertain to this question, but it could be an FFT every so often, or some basic statistics on the sample levels, or what have you).</p> <p>What's a good fit for this? Writing an AudioUnit that just passes the sound through and incidentally hands it off somewhere for analysis? Writing a JACK-aware app and figuring out how to get it to play with the JACK server? Ecasound?</p> <p>This is a cheesy proof-of-concept hobby project, so simplicity of API is the driving factor (followed by reasonable choice of programming language).</p>
[ { "answer_id": 38543, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 3, "selected": false, "text": "AudioQueueNewInput" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3462/" ]
37,535
<p>I've got a bunch of FoxPro (VFP9) DBF files on my Ubuntu system, is there a library to open these in Python? I only need to read them, and would preferably have access to the memo fields too.</p> <p><strong>Update</strong>: Thanks @cnu, I used Yusdi Santoso's <a href="http://www.physics.ox.ac.uk/users/santoso/dbf.py.src" rel="noreferrer"><code>dbf.py</code></a> and it works nicely. One gotcha: The memo file name extension must be lower case, i.e. <code>.fpt</code>, not <code>.FPT</code> which was how the filename came over from Windows.</p>
[ { "answer_id": 37917, "author": "Anders Sandvig", "author_id": 1709, "author_profile": "https://Stackoverflow.com/users/1709", "pm_score": 4, "selected": false, "text": ".DBF" }, { "answer_id": 10254842, "author": "Steve Koch", "author_id": 868718, "author_profile": "...
2008/09/01
[ "https://Stackoverflow.com/questions/37535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
37,538
<p>How do I determine the size of my array in C? </p> <p>That is, the number of elements the array can hold?</p>
[ { "answer_id": 37539, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 12, "selected": true, "text": "int a[17];\nsize_t n = sizeof(a)/sizeof(a[0]);\n" }, { "answer_id": 37541, "author": "T Percival", "autho...
2008/09/01
[ "https://Stackoverflow.com/questions/37538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
37,551
<p>I have a problem with an application running on Fedora Core 6 with JDK 1.5.0_08.</p> <p>After some amount of uptime (usually some days) threads begin getting stuck in native methods.</p> <p>The threads are locked in something like this:</p> <pre><code>&quot;pool-2-thread-2571&quot; prio=1 tid=0x08dd0b28 nid=0x319e waiting for monitor entry [0xb91fe000..0xb91ff7d4] at java.lang.Class.getDeclaredConstructors0(Native Method) </code></pre> <p>or</p> <pre><code>&quot;pool-2-thread-2547&quot; prio=1 tid=0x75641620 nid=0x1745 waiting for monitor entry [0xbc7fe000..0xbc7ff554] at sun.misc.Unsafe.defineClass(Native Method) </code></pre> <p>Especially puzzling to me is this one:</p> <pre><code>&quot;HealthMonitor-10&quot; daemon prio=1 tid=0x0868d1c0 nid=0x2b72 waiting for monitor entry [0xbe5ff000..0xbe5ff4d4] at java.lang.Thread.dumpThreads(Native Method) at java.lang.Thread.getStackTrace(Thread.java:1383) </code></pre> <p>The threads remain stuck until the VM is restarted.</p> <p>Can anyone give me an idea as to what is happening here, what might be causing the native methods to block? The monitor entry address range at the top of each stuck thread is different. How can I figure out what is holding this monitor?</p>
[ { "answer_id": 177855, "author": "VoidPointer", "author_id": 23424, "author_profile": "https://Stackoverflow.com/users/23424", "pm_score": 1, "selected": false, "text": "\"Thread-0\" prio=5 tid=0x0100b060 nid=0x84c000 waiting for monitor entry [0xb0c8a000..0xb0c8ad90]\n at Deadlock$1....
2008/09/01
[ "https://Stackoverflow.com/questions/37551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3904/" ]
37,568
<p>How do I find duplicate addresses in a database, or better stop people already when filling in the form ? I guess the earlier the better?</p> <p>Is there any good way of abstracting street, postal code etc so that typos and simple attempts to get 2 registrations can be detected? like: </p> <pre><code>Quellenstrasse 66/11 Quellenstr. 66a-11 </code></pre> <p>I'm talking German addresses... Thanks!</p>
[ { "answer_id": 44897826, "author": "Sagar V", "author_id": 2427065, "author_profile": "https://Stackoverflow.com/users/2427065", "pm_score": 0, "selected": false, "text": "Quellenstrasse 66/11" }, { "answer_id": 44935403, "author": "kichik", "author_id": 492773, "auth...
2008/09/01
[ "https://Stackoverflow.com/questions/37568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/925/" ]
37,586
<p>Our application is interfacing with a lot of web services these days. We have our own package that someone wrote a few years back using UTL_HTTP and it generally works, but needs some hard-coding of the SOAP envelope to work with certain systems. I would like to make it more generic, but lack experience to know how many scenarios I would have to deal with. The variations are in what namespaces need to be declared and the format of the elements. We have to handle both simple calls with a few parameters and those that pass a large amount of data in an encoded string.</p> <p>I know that 10g has UTL_DBWS, but there are not a huge number of use-cases on-line. Is it stable and flexible enough for general use? <a href="http://stanford.edu/dept/itss/docs/oracle/10g/java.101/b12021/callouts.htm" rel="nofollow noreferrer">Documentation</a></p>
[ { "answer_id": 67977, "author": "Sten Vesterli", "author_id": 9363, "author_profile": "https://Stackoverflow.com/users/9363", "pm_score": 4, "selected": true, "text": "UTL_HTTP" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1895/" ]
37,591
<p>I would like to display details of an xml error log to a user in a winforms application and am looking for the best control to do the job.</p> <p>The error data contains all of the sever variables at the time that the error occurred. These have been formatted into an XML document that looks something to the effect of:</p> <pre><code>&lt;error&gt; &lt;serverVariables&gt; &lt;item&gt; &lt;value&gt; &lt;/item&gt; &lt;/serverVariables&gt; &lt;queryString&gt; &lt;item name=""&gt; &lt;value string=""&gt; &lt;/item&gt; &lt;/queryString&gt; &lt;/error&gt; </code></pre> <p>I would like to read this data from the string that it is stored in and display it to the user via a windows form in a useful way. XML Notepad does a cool job of formatting xml, but is not really was I am looking for since I would prefer to rather display item details in a <em>Name : string</em> format.</p> <p>Any suggestions or am I looking and a custom implementation?</p> <p>[EDIT] A section of the data that needs to be displayed:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;error host="WIN12" type="System.Web.HttpException" message="The file '' does not exist." source="System.Web" detail="System.Web.HttpException: The file '' does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at" time="2008-09-01T07:13:08.9171250+02:00" statusCode="404"&gt; &lt;serverVariables&gt; &lt;item name="ALL_HTTP"&gt; &lt;value string="HTTP_CONNECTION:close HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) " /&gt; &lt;/item&gt; &lt;item name="AUTH_TYPE"&gt; &lt;value string="" /&gt; &lt;/item&gt; &lt;item name="HTTPS"&gt; &lt;value string="off" /&gt; &lt;/item&gt; &lt;item name="HTTPS_KEYSIZE"&gt; &lt;value string="" /&gt; &lt;/item&gt; &lt;item name="HTTP_USER_AGENT"&gt; &lt;value string="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" /&gt; &lt;/item&gt; &lt;/serverVariables&gt; &lt;queryString&gt; &lt;item name="tid"&gt; &lt;value string="196" /&gt; &lt;/item&gt; &lt;/queryString&gt; &lt;/error&gt; </code></pre>
[ { "answer_id": 37612, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 0, "selected": false, "text": "DataGridView" }, { "answer_id": 37631, "author": "aku", "author_id": 1196, "author_profile": "https://Stack...
2008/09/01
[ "https://Stackoverflow.com/questions/37591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231/" ]
37,593
<p>What is the best source of free Vista style graphics for application development? I want <strong>32x32</strong> and <strong>16x16</strong> that I can use in a Winforms application.</p>
[ { "answer_id": 37596, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": true, "text": "Common7\\VS2008ImageLibrary" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2608/" ]
37,597
<p>TreeNodeCollection, like some of the other control collections in System.Windows.Forms, implements IEnumerable. Is there any design reason behind this or is it just a hangover from the days before generics?</p>
[ { "answer_id": 37609, "author": "Artem Tikhomirov", "author_id": 2313, "author_profile": "https://Stackoverflow.com/users/2313", "pm_score": 4, "selected": true, "text": "using System.Linq; \n... \nvar nodes = GetTreeNodeCollection().OfType<TreeNode>();\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2608/" ]
37,628
<p>What is reflection, and why is it useful?</p> <p>I'm particularly interested in Java, but I assume the principles are the same in any language.</p>
[ { "answer_id": 37632, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 12, "selected": true, "text": "Method method = foo.getClass().getMethod(\"doSomething\", null);\nmethod.invoke(foo, null);\n" }, { "answer_id": ...
2008/09/01
[ "https://Stackoverflow.com/questions/37628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142/" ]
37,644
<p>I have a set of Berkeley DB files on my Linux file system that I'd like to examine.</p> <p>What useful tools exist for getting a quick overview of the contents? I can write Perl scripts that use BDB modules for examining them, but I'm looking for some CLI utility to be able to take a look inside without having to start writing scripts.</p>
[ { "answer_id": 37655, "author": "David Crow", "author_id": 2783, "author_profile": "https://Stackoverflow.com/users/2783", "pm_score": 6, "selected": true, "text": "apt-get install db-util" }, { "answer_id": 19793412, "author": "strickli", "author_id": 1612703, "autho...
2008/09/01
[ "https://Stackoverflow.com/questions/37644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1951/" ]
37,649
<p>I have a MySQL table with coordinates, the column names are X and Y. Now I want to swap the column values in this table, so that X becomes Y and Y becomes X. The most apparent solution would be renaming the columns, but I don't want to make structure changes since I don't necessarily have permissions to do that.</p> <p>Is this possible to do with <b>UPDATE</b> in some way? <b>UPDATE table SET X=Y, Y=X</b> obviously won't do what I want.</p> <hr> <p>Edit: Please note that my restriction on permissions, mentioned above, effectively prevents the use of ALTER TABLE or other commands that change the table/database structure. Renaming columns or adding new ones are unfortunately not options.</p>
[ { "answer_id": 37657, "author": "fijter", "author_id": 3215, "author_profile": "https://Stackoverflow.com/users/3215", "pm_score": 2, "selected": false, "text": "" }, { "answer_id": 37737, "author": "mercutio", "author_id": 1951, "author_profile": "https://Stackoverfl...
2008/09/01
[ "https://Stackoverflow.com/questions/37649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/890/" ]
37,650
<p>What is the best way to implement, from a web page a download action using asp.net 2.0?</p> <p>Log files for a action are created in a directory called [Application Root]/Logs. I have the full path and want to provide a button, that when clicked will download the log file from the IIS server to the users local pc.</p>
[ { "answer_id": 37656, "author": "Martin", "author_id": 770, "author_profile": "https://Stackoverflow.com/users/770", "pm_score": 6, "selected": true, "text": "Response.ContentType = \"application/octet-stream\";\nResponse.AppendHeader(\"Content-Disposition\",\"attachment; filename=logfil...
2008/09/01
[ "https://Stackoverflow.com/questions/37650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3416/" ]
37,662
<p>I'm writing a Perl script and would like to use a n-ary tree data structure.</p> <p>Is there a good implementation that is available as source code (rather than part of a Perl library) ?</p>
[ { "answer_id": 38857, "author": "nohat", "author_id": 3101, "author_profile": "https://Stackoverflow.com/users/3101", "pm_score": 2, "selected": false, "text": " t\n / \\\n a d\n / \\ / \\\n b c e f\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
37,665
<p>When <strong>Eclipse</strong> creates a new file (<strong>.c</strong> or <strong>.h</strong> file) in a C project the editor always auto creates a <code>#define</code> at the top of the file like this: If the file is named 'myCFile.c' there will be a <code>#define</code> at the start of the file like this</p> <pre><code>#ifndef MYCFILE_C_ #define MYCFILE_C_ </code></pre> <p>I have seen other editors do this as well (Codewright and SlikEdit I think). The <code>#defines</code> don't seem to do anything for the editor as I can just delete them without any problem, and I can't think of a reason why <em>I</em> would want to use them. Does anyone know why they are there? </p>
[ { "answer_id": 38416, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 1, "selected": false, "text": "#pragma once\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2079/" ]
37,684
<p>I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match.</p> <p>How I can replace all the URL? I guess I should be using the <em>exec</em> command, but I did not really figure how to do it.</p> <pre><code>function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/i; return text.replace(exp,"&lt;a href='$1'&gt;$1&lt;/a&gt;"); } </code></pre>
[ { "answer_id": 37687, "author": "Sam Hasler", "author_id": 2541, "author_profile": "https://Stackoverflow.com/users/2541", "pm_score": 8, "selected": false, "text": ".museum" }, { "answer_id": 2166104, "author": "Travis", "author_id": 252828, "author_profile": "https:...
2008/09/01
[ "https://Stackoverflow.com/questions/37684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
37,696
<p>I have three tables <code>tag</code>, <code>page</code>, <code>pagetag</code></p> <p>With the data below</p> <p><strong><em>page</em></strong></p> <pre><code>ID NAME 1 page 1 2 page 2 3 page 3 4 page 4 </code></pre> <p><strong><em>tag</em></strong></p> <pre><code>ID NAME 1 tag 1 2 tag 2 3 tag 3 4 tag 4 </code></pre> <p><strong><em>pagetag</em></strong></p> <pre><code>ID PAGEID TAGID 1 2 1 2 2 3 3 3 4 4 1 1 5 1 2 6 1 3 </code></pre> <p>I would like to get a string containing the correspondent tag names for each page with SQL in a single query. This is my desired output.</p> <pre><code>ID NAME TAGS 1 page 1 tag 1, tag 2, tag 3 2 page 2 tag 1, tag 3 3 page 3 tag 4 4 page 4 </code></pre> <p>Is this possible with SQL?</p> <hr> <p>I am using MySQL. Nonetheless, I would like a database vendor independent solution if possible.</p>
[ { "answer_id": 37700, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 2, "selected": false, "text": "SELECT page_tag.id, page.name, group_concat(tags.name)\nFROM tag, page, page_tag\nWHERE page_tag.page_id = page.page_id AND p...
2008/09/01
[ "https://Stackoverflow.com/questions/37696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
37,702
<p>Sorry for this not being a "real" question, but Sometime back i remember seeing a post here about randomizing a randomizer randomly to generate truly random numbers, not just pseudo random. I dont see it if i search for it.</p> <p>Does anybody know about that article?</p>
[ { "answer_id": 37716, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 3, "selected": false, "text": "/dev/random" }, { "answer_id": 172268, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://St...
2008/09/01
[ "https://Stackoverflow.com/questions/37702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
37,731
<p>I seem right now to be embroiled in a debate with another programmer on this project who thinks that views have no merits. He proposes a system that PHP looks something like this:</p> <pre><code>$draw = new Draw; $nav = $draw-&gt;wideHeaderBox(). $draw-&gt;left(). $draw-&gt;image(). Image::get($image,60,array('id'=&gt;'header_image')). $draw-&gt;imageEnd(). $draw-&gt;leftEnd(). $draw-&gt;left(10). '&lt;div id="header_text"&gt;'. self::defaultSectionText(). '&lt;/div&gt;'. $draw-&gt;leftEnd(). </code></pre> <p>and so on (this is in the controller btw). Now his arguments for this actually make some sense, he claims that if there is a redesign all we need to do is change the HTML in one place and it changes everywhere automatically. For some reason however, this method still rubs me the wrong way, is there any merit to views over this method? I mean besides not having to retype HTML by hand.</p>
[ { "answer_id": 37768, "author": "Brian Warshaw", "author_id": 1344, "author_profile": "https://Stackoverflow.com/users/1344", "pm_score": 4, "selected": true, "text": "new Draw" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2594/" ]
37,732
<p>What is the RegEx pattern for DateTime (2008-09-01 12:35:45 ) ?</p> <p>I get this error:</p> <blockquote> <p>No ending delimiter '^' found</p> </blockquote> <p>Using:</p> <pre><code>preg_match('(?n:^(?=\d)((?&lt;day&gt;31(?!(.0?[2469]|11))|30(?!.0?2)|29(?(.0?2)(?=.{3,4}(1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|0?[1-9]|1\d|2[0-8])(?&lt;sep&gt;[/.-])(?&lt;month&gt;0?[1-9]|1[012])\2(?&lt;year&gt;(1[6-9]|[2-9]\d)\d{2})(?:(?=\x20\d)\x20|$))?(?&lt;time&gt;((0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$)', '2008-09-01 12:35:45'); </code></pre> <p>Gives this error: </p> <blockquote> <p>Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in E:\www\index.php on line 19</p> </blockquote>
[ { "answer_id": 37758, "author": "Tom", "author_id": 3715, "author_profile": "https://Stackoverflow.com/users/3715", "pm_score": 5, "selected": false, "text": "(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}) \n" }, { "answer_id": 37767, "author": "Greg Hewgill", "author_id": 8...
2008/09/01
[ "https://Stackoverflow.com/questions/37732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4013/" ]
37,743
<p>I'd like to find the different ways to solve a real life problem I had: imagine to have a contest, or a game, during which the users collect points. You have to build a query to show the list of users with the best "n" scores. </p> <p>I'm making an example to clarify. Let's say that this is the Users table, with the points earned:</p> <pre><code>UserId - Points 1 - 100 2 - 75 3 - 50 4 - 50 5 - 50 6 - 25 </code></pre> <p>If I want the top 3 scores, the result will be:</p> <pre><code>UserId - Points 1 - 100 2 - 75 3 - 50 4 - 50 5 - 50 </code></pre> <p>This can be realized in a view or a stored procedure, as you want. My target db is Sql Server. Actually I solved this, but I think there are different way to obtain the result... faster or more efficent than mine.</p>
[ { "answer_id": 37750, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 5, "selected": true, "text": "select * from users where points in\n(select distinct top 3 points from users order by points desc)\n" }, { "answer_id": ...
2008/09/01
[ "https://Stackoverflow.com/questions/37743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1178/" ]
37,759
<p>I have the following code in a web.config file of the default IIS site.</p> <pre><code>&lt;httpModules&gt; &lt;add type="MDL.BexWebControls.Charts.ChartStreamHandler,Charts" name="ChartStreamHandler"/&gt; &lt;/httpModules&gt; </code></pre> <p>Then when I setup and browse to a virtual directory I get this error</p> <p>Could not load file or assembly 'Charts' or one of its dependencies. The system cannot find the file specified.</p> <p>The virtual directory is inheriting the modules from the default web.config.</p> <p>How do you stop this inheritance?</p>
[ { "answer_id": 37762, "author": "John Owen", "author_id": 2471, "author_profile": "https://Stackoverflow.com/users/2471", "pm_score": 5, "selected": true, "text": "<location path=\".\" inheritInChildApplications=\"false\">\n <system.web>\n <httpModules>\n <add type=\"MDL.BexWebC...
2008/09/01
[ "https://Stackoverflow.com/questions/37759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2471/" ]
37,791
<p>At the moment my code (PHP) has too many SQL queries in it. eg...</p> <pre><code>// not a real example, but you get the idea... $results = $db-&gt;GetResults("SELECT * FROM sometable WHERE iUser=$userid"); if ($results) { // Do something } </code></pre> <p>I am looking into using stored procedures to reduce this and make things a little more robust, but I have some concerns..</p> <p>I have hundreds of different queries in use around the web site, and many of them are quite similar. How should I manage all these queries when they are removed from their context (the code that uses the results) and placed in a stored procedure on the database?</p>
[ { "answer_id": 38053, "author": "Gary Richardson", "author_id": 2506, "author_profile": "https://Stackoverflow.com/users/2506", "pm_score": 2, "selected": false, "text": "SELECT * FROM sometable WHERE iUser = ?\n" }, { "answer_id": 38186, "author": "Slacker", "author_id":...
2008/09/01
[ "https://Stackoverflow.com/questions/37791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4012/" ]
37,799
<p>Is it possible to use gcov for coverage testing of multi-threaded applications? </p> <p>I've set some trivial tests of our code-base up, but it would be nice to have some idea of the coverage we're achieving. If gcov isn't appropriate can anyone recommend an alternative tool (possible oprofile), ideally with some good documentation on getting started.</p>
[ { "answer_id": 38317, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 4, "selected": true, "text": "-fprofile-arcs -ftest-coverage" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2246/" ]
37,805
<p>I have a <code>List&lt;int&gt;</code> and a <code>List&lt;customObject&gt;</code>. The customObject class has an ID property. How can I get a <code>List&lt;customObject&gt;</code> containing only the objects where the ID property is in the <code>List&lt;int&gt;</code> using LINQ?</p> <p><strong>Edit</strong>: I accepted Konrads answer because it is easier/more intuitive to read.</p>
[ { "answer_id": 37807, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": false, "text": "var matches = from o in objList \n join i in intList on o.ID equals i\n select o;\n" ...
2008/09/01
[ "https://Stackoverflow.com/questions/37805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2257/" ]
37,809
<p>How can I go about generating a Friendly URL in C#? Currently I simple replace spaces with an underscore, but how would I go about generating URL's like Stack Overflow?</p> <p>For example how can I convert:</p> <blockquote> <p>How do I generate a Friendly URL in C#?</p> </blockquote> <p>Into</p> <blockquote> <p>how-do-i-generate-a-friendly-url-in-C</p> </blockquote>
[ { "answer_id": 37817, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 4, "selected": false, "text": "if (String.IsNullOrEmpty(title)) return \"\";\n\n// remove entities\ntitle = Regex.Replace(title, @\"&\\w+;\", \"\");\n// remov...
2008/09/01
[ "https://Stackoverflow.com/questions/37809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
37,822
<p>I have read that the iPhone SDK (part of Xcode 3) is restricted to Mac's with the intel chipset. Does this restriction apply to only the simulator part of the SDK or the complete shebang?</p> <p>I have a Powerbook G4 running Leopard and would very much like to do dev on it rather than fork out for a new machine.</p> <p>It is also worth clarifying that I am interested in development for personal reasons and therefore accept that I would need a certified platform to create a submission for the App Store. </p>
[ { "answer_id": 38577, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 1, "selected": false, "text": "xcodebuild" }, { "answer_id": 45592, "author": "Clokey", "author_id": 2438, "author_profile": "https://Stackove...
2008/09/01
[ "https://Stackoverflow.com/questions/37822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2438/" ]
37,830
<p>I want to show a chromeless modal window with a close button in the upper right corner. Is this possible?</p>
[ { "answer_id": 37878, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": true, "text": "<Window WindowStyle=\"None\">\n" }, { "answer_id": 37883, "author": "aku", "author_id": 1196, "author_...
2008/09/01
[ "https://Stackoverflow.com/questions/37830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2374/" ]
37,912
<p>How do you use the the org.springframework.ws.transport.jms.WebServiceMessageDrivenBean class from the Java Spring Framework - Spring-WS project?</p> <p>There is very little documentation or examples available on the web.</p>
[ { "answer_id": 92867, "author": "Keith Lyall", "author_id": 17719, "author_profile": "https://Stackoverflow.com/users/17719", "pm_score": 0, "selected": false, "text": "public class HelloWorldMessageDrivenBean extends WebServiceMessageDrivenBean {\n private static final long serialVer...
2008/09/01
[ "https://Stackoverflow.com/questions/37912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
37,920
<p>I have developed a COM component (dll) that implements an Edit() method displaying a WTL modal dialog.</p> <p>The complete interface to this COM component corresponds to a software standard used in the chemical process industry (CAPE-OPEN) and as a result this COM component is supposed to be usable by a range of 3rd party executables that are out of my control.</p> <p>My component works as expected in many of these EXEs, but for one in particular the Edit() method just hangs without the dialog appearing.</p> <p>However, if I make a call to <code>::MessageBox()</code> immediately before <code>DoModal()</code> the dialog displays and behaves correctly after first showing the MessageBox.</p> <p>I have a suspicion that the problem may be something to do with this particular EXE running as a 'hidden window application'.</p> <p>I have tried using both NULL and the return value from <code>::GetConsoleWindow()</code> as the dialog's parent, neither have worked.</p> <p>The dialog itself is an ATL/WTL CPropertySheetImpl.</p> <p>The parent application (EXE) in question is out of my control as it is developed by a (mildly hostile) 3rd party.</p> <p>I do know that I can successfully call <code>::MessageBox()</code> or display the standard Windows File Dialog from my COM component, and that after doing so I am then able to display my custom dialog. I'm just unable to display my custom dialog without first displaying a 'standard' dialog.</p> <p>Can anyone suggest how I might get it to display the dialog without first showing an unnecessary MessageBox? I know it is possible because I've seen this EXE display the dialogs from other COM components corresponding to the same interface.</p>
[ { "answer_id": 37943, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 1, "selected": false, "text": "MyDialog dialog(pParent);\ndialog.DoModal();\n" }, { "answer_id": 37954, "author": "dguaraglia", "author_id...
2008/09/01
[ "https://Stackoverflow.com/questions/37920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3229/" ]
37,929
<p>I am reviewing a big java application to see if there are any performance bottlenecks. The real problem is that I cannot pinpoint the performance issues to any single module. The whole application is slow as such.</p> <p>Is there some tool/technique I can use to help me out in this?</p>
[ { "answer_id": 39056, "author": "wvdschel", "author_id": 2018, "author_profile": "https://Stackoverflow.com/users/2018", "pm_score": 3, "selected": false, "text": "Java -Xprof" }, { "answer_id": 15366173, "author": "Riking", "author_id": 1210278, "author_profile": "ht...
2008/09/01
[ "https://Stackoverflow.com/questions/37929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
37,931
<p>The <a href="http://msdn.microsoft.com/en-us/library/y23b5415.aspx" rel="nofollow noreferrer">official guidelines</a> suggest that there can be very few practical uses for these. Does anyone have examples of where they've put them to good use?</p>
[ { "answer_id": 37938, "author": "Chris James", "author_id": 3193, "author_profile": "https://Stackoverflow.com/users/3193", "pm_score": 0, "selected": false, "text": "enum MyWeirdType {\nTypeA, TypeB, TypeC};\n\nswitch(value){\ncase MyWeirdType.TypeA:\n...\n" }, { "answer_id": 37...
2008/09/01
[ "https://Stackoverflow.com/questions/37931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3974/" ]
37,932
<p>I'd like to do the following and can't find an elegant way:</p> <ol> <li>Read an XML template into a <code>System.Xml.XmlDocument</code> </li> <li>Populate it with data from my UI </li> <li>Transform it with an <code>XSLT</code> I've written </li> <li>Apply a <code>CSS</code> Stylesheet </li> <li>Render it to a <code>WebBrowser</code> control </li> </ol> <p>I'm currently reading it from a file on disk, populating it, then saving it back out to disk after populating it. I reference the <code>XSLT</code> in the template, and the <code>CSS</code> in the <code>XSLT</code> and then use the <code>WebBrowser.Navigate([filename])</code> method to display the XML file.</p> <p>Obviously, when I come to deploy this app, it'll break horribly as the file won't exist on disk, and I won't be able to reference the <code>XSLT</code> and <code>CSS</code> files in the <code>XML</code> file as they'll be resources. I'm planning to include the template as a resource, but can't find a neat way to proceed from there.</p> <p>Any help much appreciated</p>
[ { "answer_id": 165236, "author": "rasx", "author_id": 22944, "author_profile": "https://Stackoverflow.com/users/22944", "pm_score": 0, "selected": false, "text": "void WireUpBrowserEvents()\n{\n\n HtmlElement table = this._browser.Document.GetElementById( \"UnitFormsTable\" );\n if...
2008/09/01
[ "https://Stackoverflow.com/questions/37932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019/" ]
37,956
<p>I would like to open a small video file and map every frames in memory (to apply some custom filter). I don't want to handle the video codec, I would rather let the library handle that for me.</p> <p>I've tried to use Direct Show with the SampleGrabber filter (using this sample <a href="http://msdn.microsoft.com/en-us/library/ms787867(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms787867(VS.85).aspx</a>), but I only managed to grab some frames (not every frames!). I'm quite new in video software programming, maybe I'm not using the best library, or I'm doing it wrong. </p> <p>I've pasted a part of my code (mainly a modified copy/paste from the msdn example), unfortunately it doesn't grabb the 25 first frames as expected...</p> <pre><code>[...] hr = pGrabber-&gt;SetOneShot(TRUE); hr = pGrabber-&gt;SetBufferSamples(TRUE); pControl-&gt;Run(); // Run the graph. pEvent-&gt;WaitForCompletion(INFINITE, &amp;evCode); // Wait till it's done. // Find the required buffer size. long cbBuffer = 0; hr = pGrabber-&gt;GetCurrentBuffer(&amp;cbBuffer, NULL); for( int i = 0 ; i &lt; 25 ; ++i ) { pControl-&gt;Run(); // Run the graph. pEvent-&gt;WaitForCompletion(INFINITE, &amp;evCode); // Wait till it's done. char *pBuffer = new char[cbBuffer]; hr = pGrabber-&gt;GetCurrentBuffer(&amp;cbBuffer, (long*)pBuffer); AM_MEDIA_TYPE mt; hr = pGrabber-&gt;GetConnectedMediaType(&amp;mt); VIDEOINFOHEADER *pVih; pVih = (VIDEOINFOHEADER*)mt.pbFormat; [...] } [...] </code></pre> <p>Is there somebody, with video software experience, who can advise me about code or other simpler library?</p> <p>Thanks</p> <p>Edit: Msdn links seems not to work (<a href="http://stackoverflow.uservoice.com/pages/general/suggestions/19963" rel="noreferrer">see the bug</a>)</p>
[ { "answer_id": 21258871, "author": "Bob", "author_id": 3154041, "author_profile": "https://Stackoverflow.com/users/3154041", "pm_score": 2, "selected": false, "text": "ThreadLibManager()\n{\n List<MyThreads> listOfActiveThreads;\n public AddThread(MyThreads);\n}\nYour thread class is s...
2008/09/01
[ "https://Stackoverflow.com/questions/37956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1578/" ]
37,969
<p><strong>Can anyone recommend a tool for quickly posting test messages onto a JMS queue?</strong></p> <p><strong>Description</strong>:</p> <ol> <li>The tool should allow the user to enter some data, perhaps an XML payload, and then submit it to a queue.</li> <li>I should be able to test consumer without producer.</li> </ol>
[ { "answer_id": 73737, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 2, "selected": false, "text": "from(\"file://someDirectory\").\n to(\"activemq:MyQueue\");\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2454/" ]
37,996
<p>We are using SourceForge Enterprise Edition 4.4 in one of our project.</p> <p>My question is, in CollabNet SFEE (SourceForge Enterprise Edition 4.4), how will we get attachments associated with an Artifacts Using SFEE SOAP API?</p> <p>We have made our own .net 2.0 client. We are not using .net SDK provided by Collabnet,</p>
[ { "answer_id": 187019, "author": "binco", "author_id": 19671, "author_profile": "https://Stackoverflow.com/users/19671", "pm_score": 0, "selected": false, "text": "/usr/local/sourceforge/sourceforge_home/integration/post-commit.py\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/37996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
38,005
<p>Now that <code>LINQ</code> to <code>SQL</code> is a little more mature, I'd like to know of any techniques people are using to create an <strong>n-tiered solution</strong> using the technology, because it does not seem that obvious to me.</p>
[ { "answer_id": 38330, "author": "Giovanni Galbo", "author_id": 4050, "author_profile": "https://Stackoverflow.com/users/4050", "pm_score": 0, "selected": false, "text": "var emps = from e in Employees\n join m in Employees\n on e.ManagerEmpID equals m.EmpID\...
2008/09/01
[ "https://Stackoverflow.com/questions/38005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4050/" ]
38,010
<p>When performing string concatentation of an existing string in the intern pool, is a new string entered into the intern pool or is a reference returned to the existing string in the intern pool? According to this article, String.Concat and StringBuilder will insert new string instances into the intern pool? </p> <p><a href="http://community.bartdesmet.net/blogs/bart/archive/2006/09/27/4472.aspx" rel="nofollow noreferrer">http://community.bartdesmet.net/blogs/bart/archive/2006/09/27/4472.aspx</a></p> <p>Can anyone explain how concatenation works with the intern pool?</p>
[ { "answer_id": 38040, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "String.IsInterned" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/38010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993/" ]
38,014
<p>I am facing problem with an Oracle Query in a .net 2.0 based windows application. I am using <code>System.Data.OracleClient</code> to connect to oracle database. Name of database is <code>myDB</code>. Below the the connection string I am using:</p> <pre><code>Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP) (HOST = 172.16.0.24)(PORT = 1522)))(CONNECT_DATA =(SERVICE_NAME = ORCL))); User ID=myDB;Password=myDB;Unicode=True </code></pre> <p>If I run the below query then it will given me wrong result (here wrong result means incorrect data. The data doesn't belongs to myDB):</p> <pre><code>SELECT ID, NAME FROM MyTempTable WHERE ID IN (10780, 10760, 11890) </code></pre> <p>But if I append the database name along with it the it is giving correct result:</p> <pre><code>SELECT ID, NAME FROM "myDB".MyTempTable WHERE ID IN (10780, 10760, 11890) </code></pre> <p>My limitation is that I cannot append the database name as this is a generic application and can run with any database on run time. Please help.</p>
[ { "answer_id": 38022, "author": "skolima", "author_id": 3205, "author_profile": "https://Stackoverflow.com/users/3205", "pm_score": 0, "selected": false, "text": "CONNECT_DATA=(SID=myDB)(SERVICE_NAME=ORCL)\n" }, { "answer_id": 6239631, "author": "Gary Myers", "author_id":...
2008/09/01
[ "https://Stackoverflow.com/questions/38014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
38,021
<p>How can I find the origins of conflicting DNS records?</p>
[ { "answer_id": 38025, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 1, "selected": false, "text": " NS51.DOMAINCONTROL.COM\n NS52.DOMAINCONTROL.COM\n" }, { "answer_id": 38028, "author": "Antti Kissaniemi", ...
2008/09/01
[ "https://Stackoverflow.com/questions/38021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319/" ]
38,027
<p>Both are mathematical values, however the float does have more precision. Is that the only reason for the error - the difference in precision? Or is there another potential (and more serious) problem?</p>
[ { "answer_id": 43486, "author": "smh", "author_id": 1077, "author_profile": "https://Stackoverflow.com/users/1077", "pm_score": 1, "selected": false, "text": "short -> 15 bits\nfloat -> 23 bits\nlong -> 31 bits\ndouble -> 52 bits\n" }, { "answer_id": 181446, "author": "Ch...
2008/09/01
[ "https://Stackoverflow.com/questions/38027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
38,035
<p>I'm building a basic search functionality, using LIKE (I'd be using fulltext but can't at the moment) and I'm wondering if MySQL can, on searching for a keyword (e.g. WHERE field LIKE '%word%') return 20 words either side of the keyword, as well?</p>
[ { "answer_id": 38188, "author": "JimmyJ", "author_id": 2083, "author_profile": "https://Stackoverflow.com/users/2083", "pm_score": 0, "selected": false, "text": "SELECT SUBSTRING(field_name, LOCATE('keyword', field_name) - chars_before, total_chars) FROM table_name WHERE field_name LIKE ...
2008/09/01
[ "https://Stackoverflow.com/questions/38035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/393028/" ]
38,037
<p>In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a <code>std::string</code>).<br> <a href="http://rapidxml.sourceforge.net/" rel="nofollow noreferrer">RapidXml</a> has been recommended to me, but I can't see how to retrieve the XML back as a text string.<br> (I could iterate over the nodes and attributes and build it myself, but surely there's a build in function that I am missing.)<br> Thank you.</p>
[ { "answer_id": 38413, "author": "Thomas Watnedal", "author_id": 4059, "author_profile": "https://Stackoverflow.com/users/4059", "pm_score": 4, "selected": true, "text": "#include <iostream>\n#include <sstream>\n#include \"rapidxml/rapidxml.hpp\"\n#include \"rapidxml/rapidxml_print.hpp\"\...
2008/09/01
[ "https://Stackoverflow.com/questions/38037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3590/" ]
38,039
<p>How do I find the start of the week (both Sunday and Monday) knowing just the current time in C#?</p> <p>Something like:</p> <pre><code>DateTime.Now.StartWeek(Monday); </code></pre>
[ { "answer_id": 38049, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 4, "selected": false, "text": "DateTime t = DateTime.Now;\nt -= new TimeSpan ((int) t.DayOfWeek, 0, 0, 0);\n" }, { "answer_id": 38051, "author": "...
2008/09/01
[ "https://Stackoverflow.com/questions/38039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
38,056
<p>The only <em>nice</em> way I've found is:</p> <pre><code>import sys import os try: os.kill(int(sys.argv[1]), 0) print "Running" except: print "Not running" </code></pre> <p>(<a href="http://www.unix.com/unix-advanced-expert-users/79267-trick-bash-scripters-check-if-process-running.html" rel="noreferrer">Source</a>)<br> But is this reliable? Does it work with every process and every distribution?</p>
[ { "answer_id": 38196, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 4, "selected": false, "text": "/proc" }, { "answer_id": 38230, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stac...
2008/09/01
[ "https://Stackoverflow.com/questions/38056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1531/" ]
38,057
<pre><code>@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List&lt; UglyProblem &gt; problems; } </code></pre> <p>I think it is pretty clear what I am trying to do. I expect @ManyToOne person to be inherited by UglyProblem class. But there will be an exception saying something like: "There is no such property found in UglyProblem class (mappedBy="person")".</p> <p>All I found is <a href="http://opensource.atlassian.com/projects/hibernate/browse/ANN-558" rel="noreferrer">this</a>. I was not able to find the post by Emmanuel Bernard explaining reasons behind this. </p> <hr> <blockquote> <p>Unfortunately, according to the Hibernate documentation "Properties from superclasses not mapped as @MappedSuperclass are ignored."</p> </blockquote> <p>Well I think this means that if I have these two classes:</p> <pre><code>public class A { private int foo; } @Entity public class B extens A { } </code></pre> <p>then field <code>foo</code> will not be mapped for class B. Which makes sense. But if I have something like this:</p> <pre><code>@Entity public class Problem { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } @Entity public class UglyProblem extends Problem { private int levelOfUgliness; public int getLevelOfUgliness() { return levelOfUgliness; } public void setLevelOfUgliness(int levelOfUgliness) { this.levelOfUgliness = levelOfUgliness; } } </code></pre> <p>I expect the class UglyProblem to have fileds <code>id</code> and <code>name</code> and both classes to be mapped using same table. (In fact, this is exactly what happens, I have just checked again). I have got this table:</p> <pre><code>CREATE TABLE "problem" ( "DTYPE" varchar(31) NOT NULL, "id" bigint(20) NOT NULL auto_increment, "name" varchar(255) default NULL, "levelOfUgliness" int(11) default NULL, PRIMARY KEY ("id") ) AUTO_INCREMENT=2; </code></pre> <p>Going back to my question:</p> <blockquote> <p>I expect @ManyToOne person to be inherited by UglyProblem class.</p> </blockquote> <p>I expect that because all other mapped fields are inherited and I do not see any reason to make this exception for ManyToOne relationships.</p> <hr> <p>Yeah, I saw that. In fact, I used Read-Only solution for my case. But my question was "Why..." :). I know that there is an explanation given by a member of hibernate team. I was not able to find it and that is why I asked.</p> <p>I want to find out the motivation of this design decision.</p> <p>(if you interested how I have faced this problem: I inherited a project built using hibernate 3. It was Jboss 4.0.something + hibernate was already there (you'd download it all together). I was moving this project to Jboss 4.2.2 and I found out that there are inherited mappings of "@OneToMany mappedBy" and it worked fine on old setup...)</p>
[ { "answer_id": 38992, "author": "David Crow", "author_id": 2783, "author_profile": "https://Stackoverflow.com/users/2783", "pm_score": 3, "selected": false, "text": "public interface Problem {\n public Person getPerson();\n}\n\npublic interface UglyProblem extends Problem {\n}\n" },...
2008/09/01
[ "https://Stackoverflow.com/questions/38057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4052/" ]
38,068
<p>Is there any shorthand way of defining and using generic definitions without having to keep repeating a particular generic description such that if there is a change I don't have to change all definitions/usages though out the codebase for example is something like this possible:</p> <pre><code>Typedef myGenDef = &lt; Object1, Object2 &gt;; HashMap&lt; myGenDef &gt; hm = new HashMap&lt; myGenDef &gt;(); for (Entry&lt; myGenDef &gt; ent : hm..entrySet()) { . . . } </code></pre>
[ { "answer_id": 38098, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 1, "selected": false, "text": "def map = new HashMap<complicated generic expression>();\n" }, { "answer_id": 38102, "author": "Shog9", ...
2008/09/01
[ "https://Stackoverflow.com/questions/38068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
38,074
<p>If you create an Oracle dblink you cannot directly access LOB columns in the target tables.</p> <p>For instance, you create a dblink with:</p> <pre><code>create database link TEST_LINK connect to TARGETUSER IDENTIFIED BY password using 'DATABASESID'; </code></pre> <p>After this you can do stuff like:</p> <pre><code>select column_a, column_b from data_user.sample_table@TEST_LINK </code></pre> <p>Except if the column is a LOB, then you get the error:</p> <pre><code>ORA-22992: cannot use LOB locators selected from remote tables </code></pre> <p>This is <a href="http://docs.oracle.com/cd/B10501_01/appdev.920/a96591/adl04mng.htm#98328" rel="noreferrer">a documented restriction</a>.</p> <p>The same page suggests you fetch the values into a local table, but that is... kind of messy:</p> <pre><code>CREATE TABLE tmp_hello AS SELECT column_a from data_user.sample_table@TEST_LINK </code></pre> <p>Any other ideas?</p>
[ { "answer_id": 14547653, "author": "user2015502", "author_id": 2015502, "author_profile": "https://Stackoverflow.com/users/2015502", "pm_score": 4, "selected": false, "text": "SELECT (select column_b from sample_table@TEST_LINK) AS column_b FROM DUAL\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/38074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2846/" ]
38,081
<p>I need to create a quick-n-dirty knob control in Visual Basic 2005 Express, the value of which is incremented/decremented by "grabbing" it with the mouse and moving the cursor up/down. Because the knob itself doesn't move, I need to keep tracking the mouse movement outside of the rectangle of the control.</p> <p>I use a <code>Label</code> with an <code>ImageList</code> to implement this (I have a list of 127 bitmaps representing the knob in various positions).</p> <p>Which events should I react to?</p>
[ { "answer_id": 14547653, "author": "user2015502", "author_id": 2015502, "author_profile": "https://Stackoverflow.com/users/2015502", "pm_score": 4, "selected": false, "text": "SELECT (select column_b from sample_table@TEST_LINK) AS column_b FROM DUAL\n" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/38081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
38,160
<p>Lets say I have a loop in Bash:</p> <pre><code>for foo in `some-command` do do-something $foo done </code></pre> <p><code>do-something</code> is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 <code>do-something</code>'s at once.</p> <p>The naive approach seems to be:</p> <pre><code>for foo in `some-command` do do-something $foo &amp; done </code></pre> <p>This will run <em>all</em> <code>do-something</code>s at once, but there are a couple downsides, mainly that do-something may also have some significant I/O which performing <em>all</em> at once might slow down a bit. The other problem is that this code block returns immediately, so no way to do other work when all the <code>do-something</code>s are finished.</p> <p>How would you write this loop so there are always X <code>do-something</code>s running at once?</p>
[ { "answer_id": 38166, "author": "skolima", "author_id": 3205, "author_profile": "https://Stackoverflow.com/users/3205", "pm_score": 4, "selected": false, "text": "make -jX" }, { "answer_id": 880864, "author": "Grumbel", "author_id": 28113, "author_profile": "https://S...
2008/09/01
[ "https://Stackoverflow.com/questions/38160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/163/" ]
38,181
<p>I have a basic understanding of mock and fake objects, but I'm not sure I have a feeling about when/where to use mocking - especially as it would apply to this scenario <a href="https://stackoverflow.com/questions/37375/how-do-i-unit-test-a-wcf-service"><strong>here</strong></a>.</p>
[ { "answer_id": 38260, "author": "Jan Soltis", "author_id": 3997, "author_profile": "https://Stackoverflow.com/users/3997", "pm_score": 8, "selected": false, "text": "sendInvitations(MailServer mailServer)" } ]
2008/09/01
[ "https://Stackoverflow.com/questions/38181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
38,190
<p>Is it possible to read a disk directly with .NET? By directly, I mean via the device bypassing the file system. I think I would go about this by opening the device some way &quot;\Device\Ide\IdeDeviceP2T0L0-1&quot; for example.</p> <p>If I can't open the device with a .NET API, knowing which Win32 API to use would be helpful.</p>
[ { "answer_id": 38275, "author": "Darryl Braaten", "author_id": 1834, "author_profile": "https://Stackoverflow.com/users/1834", "pm_score": 4, "selected": false, "text": "using System;\nusing System.Runtime.InteropServices;\nusing System.IO;\nusing Microsoft.Win32.SafeHandles;\n\nnamespac...
2008/09/01
[ "https://Stackoverflow.com/questions/38190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1834/" ]
38,193
<p>Is there an easy way to tell if a ruby script is already running and then handle it appropriately? For example: I have a script called really_long_script.rb. I have it cronned to run every 5 minutes. When it runs, I want to see if the previous run is still running and then stop the execution of the second script. Any ideas?</p>
[ { "answer_id": 38200, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 0, "selected": false, "text": "if ps aux | grep really_long_script.rb | grep -vq grep\nthen\n echo Script already running\nelse\n ruby really_...
2008/09/01
[ "https://Stackoverflow.com/questions/38193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4082/" ]
38,197
<p>The primary class in the <code>subprocess</code> module is name <code>Popen</code>, and represents a subprocess. <code>Popen</code> sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple like, say, <code>Subprocess</code>?</p>
[ { "answer_id": 38202, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": -1, "selected": false, "text": "subprocess" }, { "answer_id": 38206, "author": "dF.", "author_id": 3002, "author_profile": "https:...
2008/09/01
[ "https://Stackoverflow.com/questions/38197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1114/" ]
38,198
<p><code>celsius = (5.0/9.0) * (fahr-32.0);</code></p> <p>Is it just a development choice that the C developers decided upon or is there a reason to this? I believe a float is smaller than a double, so it might be to prevent overflows caused by not knowing what decimal format to use. Is that the reason, or am I overlooking something?</p>
[ { "answer_id": 38229, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 5, "selected": false, "text": "celsius = (5.0/9.0) * (fahr-32.0);\n" }, { "answer_id": 38234, "author": "hoyhoy", "author_id": 3499, "author...
2008/09/01
[ "https://Stackoverflow.com/questions/38198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]