qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
123,335
<p>what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed post size?</p>
[ { "answer_id": 10689080, "author": "Ahmed MANSOUR", "author_id": 1408361, "author_profile": "https://Stackoverflow.com/users/1408361", "pm_score": 2, "selected": false, "text": "<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->\n<Connector port=\"8009\" \n enableLooku...
2008/09/23
[ "https://Stackoverflow.com/questions/123335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13973/" ]
123,336
<p>How can you strip non-ASCII characters from a string? (in C#)</p>
[ { "answer_id": 123340, "author": "philcruz", "author_id": 3784, "author_profile": "https://Stackoverflow.com/users/3784", "pm_score": 10, "selected": true, "text": "string s = \"sรธme string\";\ns = Regex.Replace(s, @\"[^\\u0000-\\u007F]+\", string.Empty);\n" }, { "answer_id": 135...
2008/09/23
[ "https://Stackoverflow.com/questions/123336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3784/" ]
123,378
<p>Is there a good command-line UNIX charting / graphing / plotting tool out there? I'm looking for something that will plot xy points on an ASCII graph.</p> <p>Just to clarify, I'm looking for something that will output a graph in ASCII (like ascii-art style), so I can use it over an interactive shell session without needing X.</p>
[ { "answer_id": 123396, "author": "Palmin", "author_id": 5949, "author_profile": "https://Stackoverflow.com/users/5949", "pm_score": 8, "selected": true, "text": "gnuplot> set terminal dumb\nTerminal type set to 'dumb'\nOptions are 'feed 79 24'\ngnuplot> plot sin(x)\n\n 1 ++------------...
2008/09/23
[ "https://Stackoverflow.com/questions/123378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21339/" ]
123,387
<p>we're have a client that needs to get interactive messages from a server, from clients that are distributed around the world behind all kinds of firewalls with all kinds of ports closed. The only thing we can rely on is HTTP port 80 (and HTTPS 443).</p> <p>The design is basically modeled after XMPP (the Jabber protocol), using our client and IIS. The client issues GET requests to a .NET Handler; the handler holds the request open for a while looking for messages. If any messages arrive, they are immediately sent to the client; if not, after a timeout the connection is closed with a "no-data" response. The client immediately reopens the communication.</p> <p>Well, theoretically.</p> <p>What's actually happening is first, IIS can't handle more than about 100 simultaneous requests - others are all queued, and there can be a several minute lag between "connected" and IIS recognizing that the client called in. Second, about half the time the client times out without any response from the server (the client timeout is five minutes longer than the server's).</p> <p>POST always works. Other data served on the same web server works. Web services on the same server work. This is an out-of-the-box installation on Windows 2K3 Server.</p> <p>Is there a configuration option we're missing, or is there something else I should look at to address this?</p> <p>Thanks.</p>
[ { "answer_id": 136797, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 3, "selected": true, "text": "IHttpAsyncHandler" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/123387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22809/" ]
123,391
<p>I would like to know how to unload an assembly that is loaded into the main AppDomain.</p> <p>I have the following code:</p> <pre><code>var assembly = Assembly.LoadFrom( FilePathHere ); </code></pre> <p>I need/want to be able to unload this assembly when I am done.</p> <p>Thanks for your help.</p>
[ { "answer_id": 123465, "author": "Khoth", "author_id": 20686, "author_profile": "https://Stackoverflow.com/users/20686", "pm_score": 3, "selected": false, "text": "DynamicMethod" }, { "answer_id": 666312, "author": "Nipun", "author_id": 79323, "author_profile": "https...
2008/09/23
[ "https://Stackoverflow.com/questions/123391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14164/" ]
123,394
<p>I know I can do this:</p> <pre><code>IDateTimeFactory dtf = MockRepository.GenerateStub&lt;IDateTimeFactory&gt;(); dtf.Now = new DateTime(); DoStuff(dtf); // dtf.Now can be called arbitrary number of times, will always return the same value dtf.Now = new DateTime()+new TimeSpan(0,1,0); // 1 minute later DoStuff(dtf); //ditto from above </code></pre> <p>What if instead of <strong>IDateTimeFactory.Now</strong> being a property it is a method <strong>IDateTimeFactory.GetNow()</strong>, how do I do the same thing?</p> <p>As per Judah's suggestion below I have rewritten my SetDateTime helper method as follows:</p> <pre><code> private void SetDateTime(DateTime dt) { Expect.Call(_now_factory.GetNow()).Repeat.Any(); LastCall.Do((Func&lt;DateTime&gt;)delegate() { return dt; }); } </code></pre> <p>but it still throws "The result for ICurrentDateTimeFactory.GetNow(); has already been setup." errors.</p> <p>Plus its still not going to work with a stub....</p>
[ { "answer_id": 123515, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 0, "selected": false, "text": "using (mocks.Record())\n{\n Expect.Call(s.GetSomething()).Return(\"ABC\"); // 1st call will return ABC\n Exp...
2008/09/23
[ "https://Stackoverflow.com/questions/123394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
123,401
<p>Using jQuery, how do you bind a click event to a table cell (below, <code>class="expand"</code>) that will change the <code>image src</code> (which is in the clicked cell - original will be plus.gif, alternating with minus.gif) and <code>hide/show</code> the row immediately below it based on whether that row has a class of <code>hide</code>. (show it if it has a class of "hide" and hide if it does not have a class of "hide"). I am flexible with changing ids and classes in the markup.</p> <p>Thanks</p> <p>Table rows</p> <pre><code>&lt;tr&gt; &lt;td class="expand"&gt;&lt;img src="plus.gif"/&gt;&lt;/td&gt; &lt;td&gt;Data1&lt;/td&gt;&lt;td&gt;Data2&lt;/td&gt;&lt;td&gt;Data3&lt;/td&gt; &lt;/tr&gt; &lt;tr class="show hide"&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt;Data4&lt;/td&gt;&lt;td&gt;Data5&lt;/td&gt;&lt;td&gt;Data6&lt;/td&gt; &lt;/tr&gt; </code></pre>
[ { "answer_id": 123518, "author": "neuroguy123", "author_id": 12529, "author_profile": "https://Stackoverflow.com/users/12529", "pm_score": 5, "selected": true, "text": "$(document).ready(function(){ \n $('.expand').click(function() {\n if( $(this).hasClass('hidden') )\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/123401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
123,480
<p>We are using Zabbix for services monitoring.</p> <p>There are some essential monitoring configured. I want to have timeline of version strings of my service along with this monitorings. That would give me opportunity to see that upgrading to this version altered overall error-count.</p> <p>Is it possible? </p>
[ { "answer_id": 395338, "author": "James Cape", "author_id": 41044, "author_profile": "https://Stackoverflow.com/users/41044", "pm_score": 0, "selected": false, "text": "zabbix_agentd.conf" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/123480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/844/" ]
123,489
<p>I am using REPLACE in an SQL view to remove the spaces from a property number. The function is setup like this REPLACE(pin, ' ', ''). On the green-screen the query looked fine. In anything else we get the hex values of the characters in the field. I am sure it is an encoding thing, but how do I fix it?</p> <p>Here is the statement I used to create the view:</p> <pre><code>CREATE VIEW RLIC2GIS AS SELECT REPLACE(RCAPIN, ' ', '') AS RCAPIN13 , RLICNO, RONAME, ROADR1, ROADR2, ROCITY, ROSTAT, ROZIP1, ROZIP2, RGRID, RRADR1, RRADR2, RANAME, RAADR1, RAADR2, RACITY, RASTAT, RAZIP1, RAZIP2, REGRES, RPENDI, RBLDGT, ROWNOC, RRCODE, RROOMS, RUNITS, RTUNIT, RPAID, RAMTPD, RMDYPD, RRFUSE, RNUMCP, RDATCP, RINSP, RCAUKY, RCAPIN, RAMTYR, RYREXP, RDELET, RVARIA, RMDYIN, RDTLKI, ROPHN1, ROPHN2, ROCOM1, ROCOM2, RAPHN1, RAPHN2, RACOM1, RACOM2, RNOTES FROM RLIC2 </code></pre> <p>UPDATE: I posted the answer below.</p>
[ { "answer_id": 123784, "author": "Mike Wills", "author_id": 2535, "author_profile": "https://Stackoverflow.com/users/2535", "pm_score": 3, "selected": true, "text": "CREATE VIEW RLIC2GIS AS \nSELECT CONCAT(SUBSTR(RCAPIN,1,3),CONCAT(SUBSTR(RCAPIN,5,2), ...
2008/09/23
[ "https://Stackoverflow.com/questions/123489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2535/" ]
123,499
<p>I've got the directive</p> <pre><code>&lt;VirtualHost *&gt; &lt;Location /&gt; AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users &lt;Limit GET&gt; Require valid-user &lt;/Limit&gt; &lt;/Location&gt; WSGIScriptAlias / /some/script.wsgi WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25 WSGIProcessGroup mywsgi ServerName some.example.org &lt;/VirtualHost&gt; </code></pre> <p>I'd like to know in the /some/script.wsgi</p> <pre><code>def application(environ, start_response): start_response('200 OK', [ ('Content-Type', 'text/plain'), ]) return ['Hello'] </code></pre> <p>What user is logged in.</p> <p>How do I do that?</p>
[ { "answer_id": 123526, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 5, "selected": true, "text": "WSGIPassAuthorization On" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/123499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19435/" ]
123,503
<p>I'm writing an iPhone app with Cocoa in xcode. I can't find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can I find good info?</p> <p>Thanks!</p>
[ { "answer_id": 123590, "author": "jblocksom", "author_id": 20626, "author_profile": "https://Stackoverflow.com/users/20626", "pm_score": 2, "selected": false, "text": "UIImagePickerController" }, { "answer_id": 127155, "author": "Airsource Ltd", "author_id": 18017, "a...
2008/09/23
[ "https://Stackoverflow.com/questions/123503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
123,504
<p>In wxWidgets, how can you find the pixels per inch on a wxDC? I'd like to be able to scale things by a real world number like inches. That often makes it easier to use the same code for printing to the screen and the printer.</p>
[ { "answer_id": 123590, "author": "jblocksom", "author_id": 20626, "author_profile": "https://Stackoverflow.com/users/20626", "pm_score": 2, "selected": false, "text": "UIImagePickerController" }, { "answer_id": 127155, "author": "Airsource Ltd", "author_id": 18017, "a...
2008/09/23
[ "https://Stackoverflow.com/questions/123504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
123,506
<p>I have a ASP.NET application running on a remote web server and I just started getting this error:</p> <pre><code>Method not found: 'Void System.Collections.Generic.ICollection`1..ctor()'. </code></pre> <p>I disassembled the code in the DLL and it seems like the compiler is incorrectly optimizing the code. (Note that Set is a class that implements a set of unique objects. It inherits from IEnumerable.) This line:</p> <pre><code>Set&lt;int&gt; set = new Set&lt;int&gt;(); </code></pre> <p>Is compiled into this line:</p> <pre><code>Set&lt;int&gt; set = (Set&lt;int&gt;) new ICollection&lt;CalendarModule&gt;(); </code></pre> <p>The CalendarModule class is a totally unrelated class!! Has anyone ever noticed .NET incorrectly compiling code like this before?</p> <p><strong>Update #1:</strong> This problem seems to be introduced by Microsoft's <a href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" rel="nofollow noreferrer">ILMerge</a> tool. We are currently investigating how to overcome it.</p> <p><strong>Update #2:</strong> We found two ways to solve this problem so far. We don't quite understand what the underlying problem is, but both of these fix it:</p> <ol> <li><p>Turn off optimization.</p></li> <li><p>Merge the assemblie with ILMerge on a different machine.</p></li> </ol> <p>So we are left wondering if the build machine is misconfigured somehow (which is strange considering that we have been using the machine to build releases for over a year now) or if it is some other problem.</p>
[ { "answer_id": 123607, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 1, "selected": false, "text": "System.Collections.Generic.HashSet<T>" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/123506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10475/" ]
123,529
<p>A site I'm working on has Flash headers (using <a href="http://code.google.com/p/swfobject/" rel="noreferrer">swfobject</a> to embed them). Now I'm required to code in a bit of HTML that's supposed to overlap the Flash movie.</p> <p>I've tried setting z-index on the Flash element's container and the (absolutely positioned) div but it keeps "vanishing" behind the Flash movie. </p> <p>I'm hoping for a CSS solution, but if there's a bit of JS magic that will do the trick, I'm up for it.</p> <p><strong>Update:</strong> Thanks, setting wmode to "transparent" mostly fixed it. Only Safari/Mac still hid the div behind the flash on first show. When I'd switch to another app and back it would be in front. I was able to fix this by setting the div's initial styles to <code>display: none;</code> and make it visible via JS half a second after the page has loaded.</p>
[ { "answer_id": 397349, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "s1.addParam(\"wmode\",\"transparent\");\n" }, { "answer_id": 6933950, "author": "Nassim Chikh", "author_id": 8...
2008/09/23
[ "https://Stackoverflow.com/questions/123529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9438/" ]
123,557
<p>I need to select a bunch of data into a temp table to then do some secondary calculations; To help make it work more efficiently, I would like to have an IDENTITY column on that table. I know I could declare the table first with an identity, then insert the rest of the data into it, but is there a way to do it in 1 step?</p>
[ { "answer_id": 123644, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 8, "selected": true, "text": "SELECT *, IDENTITY( int ) AS idcol\n INTO #newtable\n FROM oldtable\n" }, { "answer_id": 123735, "author": ...
2008/09/23
[ "https://Stackoverflow.com/questions/123557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19305/" ]
123,558
<p>Is it possible to disable a trigger for a batch of commands and then enable it when the batch is done?</p> <p>I'm sure I could drop the trigger and re-add it but I was wondering if there was another way.</p>
[ { "answer_id": 123566, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 7, "selected": true, "text": "DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }\nON { object_name | DATABASE | ALL SERVER } [ ; ]\n" ...
2008/09/23
[ "https://Stackoverflow.com/questions/123558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
123,559
<p>I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:</p> <ul> <li><code>1-234-567-8901</code></li> <li><code>1-234-567-8901 x1234</code></li> <li><code>1-234-567-8901 ext1234</code></li> <li><code>1 (234) 567-8901</code></li> <li><code>1.234.567.8901</code></li> <li><code>1/234/567/8901</code></li> <li><code>12345678901</code></li> </ul> <p>I'll answer with my current attempt, but I'm hoping somebody has something better and/or more elegant.</p>
[ { "answer_id": 123565, "author": "Nicholas Trandem", "author_id": 765, "author_profile": "https://Stackoverflow.com/users/765", "pm_score": 4, "selected": false, "text": "^\\d?(?:(?:[\\+]?(?:[\\d]{1,3}(?:[ ]+|[\\-.])))?[(]?(?:[\\d]{3})[\\-/)]?(?:[ ]+)?)?(?:[a-zA-Z2-9][a-zA-Z0-9 \\-.]{6,}...
2008/09/23
[ "https://Stackoverflow.com/questions/123559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/765/" ]
123,585
<p>I installed a ASP.Net website on a Windows 2008 server, which is by default using IIS7. The website seems to work fine, but the post backs on my forms do not work. After a few hours of debugging, I realized that when I manually try to hit the WebResource.axd file in my browser (e.g. I type <a href="http://www.domain.com/WebResource.axd" rel="nofollow noreferrer">http://www.domain.com/WebResource.axd</a> in the address bar), I get a HTTP 403 error (Access Denied). </p> <p>I'm not quite sure where to look next and my Windows 2008 security knowledge is limited. How do I go about giving access to that file?</p>
[ { "answer_id": 331832, "author": "Enes", "author_id": 2921654, "author_profile": "https://Stackoverflow.com/users/2921654", "pm_score": 2, "selected": false, "text": "<handlers>" }, { "answer_id": 69806548, "author": "Jeff", "author_id": 3128942, "author_profile": "ht...
2008/09/23
[ "https://Stackoverflow.com/questions/123585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2013/" ]
123,598
<p>I have an Enum called Status defined as such:</p> <pre><code>public enum Status { VALID("valid"), OLD("old"); private final String val; Status(String val) { this.val = val; } public String getStatus() { return val; } } </code></pre> <p>I would like to access the value of <code>VALID</code> from a JSTL tag. Specifically the <code>test</code> attribute of the <code>&lt;c:when&gt;</code> tag. E.g.</p> <pre><code>&lt;c:when test="${dp.status eq Status.VALID"&gt; </code></pre> <p>I'm not sure if this is possible.</p>
[ { "answer_id": 130002, "author": "IaCoder", "author_id": 17337, "author_profile": "https://Stackoverflow.com/users/17337", "pm_score": 5, "selected": false, "text": "<% pageContext.setAttribute(\"old\", Status.OLD); %>\n" }, { "answer_id": 368526, "author": "Alexander Vasilje...
2008/09/23
[ "https://Stackoverflow.com/questions/123598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
123,632
<pre><code>devenv mysolution.sln /build "Release|Win32" /project myproject </code></pre> <p>When building from the command line, it seems I have the option of doing a <code>/build</code> or <code>/rebuild</code>, but no way of saying I want to do "project only" (i.e. not build or rebuild the specified project's dependencies as well). Does anyone know of a way?</p>
[ { "answer_id": 123649, "author": "Ben Straub", "author_id": 1319, "author_profile": "https://Stackoverflow.com/users/1319", "pm_score": 2, "selected": false, "text": "devenv" }, { "answer_id": 123651, "author": "Xian", "author_id": 4642, "author_profile": "https://Sta...
2008/09/23
[ "https://Stackoverflow.com/questions/123632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
123,639
<p>Suppose I use the [RemoteClass] tag to endow a custom Flex class with serialization intelligence. </p> <p>What happens when I need to change my object (add a new field, remove a field, rename a field, etc)?</p> <p>Is there a design pattern for handling this in an elegant way?</p>
[ { "answer_id": 327306, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 2, "selected": false, "text": "java:\npublic class User {\n public Long id;\n public String firstName;\n public String lastName;\n}\n\nas3:\npubl...
2008/09/23
[ "https://Stackoverflow.com/questions/123639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1750627/" ]
123,648
<p>I know that a SQL Server full text index can not index more than one table. But, I have relationships in tables that I would like to implement full text indexes on.</p> <p>Take the 3 tables below...</p> <pre><code>Vehicle Veh_ID - int (Primary Key) FK_Atr_VehicleColor - int Veh_Make - nvarchar(20) Veh_Model - nvarchar(50) Veh_LicensePlate - nvarchar(10) Attributes Atr_ID - int (Primary Key) FK_Aty_ID - int Atr_Name - nvarchar(50) AttributeTypes Aty_ID - int (Primary key) Aty_Name - nvarchar(50) </code></pre> <p>The Attributes and AttributeTypes tables hold values that can be used in drop down lists throughout the application being built. For example, Attribute Type of "Vehicle Color" with Attributes of "Black", "Blue", "Red", etc...</p> <p>Ok, so the problem comes when a user is trying to search for a "Blue Ford Mustang". So what is the best solution considering that tables like Vehicle will get rather large?</p> <p>Do I create another field in the "Vehicle" table that is "Veh Color" that holds the text value of what is selected in the drop down in addition to "FK Atr VehicleColor"?</p> <p>Or, do I drop "FK Atr VehicleColor" altogether and add "Veh Color"? I can use text value of "Veh Color" to match against "Atr Name" when the drop down is populated in an update form. With this approach I will have to handle if Attributes are dropped from the database.</p> <p>-- Note: could not use underscore outside of code view as everything between two underscores is <em>italicized</em>.</p>
[ { "answer_id": 123814, "author": "Cowan", "author_id": 17041, "author_profile": "https://Stackoverflow.com/users/17041", "pm_score": 0, "selected": false, "text": "SELECT \n Vehicle.VehID, ..., Color.Atr_Name AS ColorName \nFROM\n Vehicle \nLEFT OUTER JOIN Attributes AS Color ON (Vehic...
2008/09/23
[ "https://Stackoverflow.com/questions/123648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/576/" ]
123,657
<p>I would like to know if there is some way to share a variable or an object between two or more Servlets, I mean some "standard" way. I suppose that this is not a good practice but is a easier way to build a prototype.</p> <p>I don't know if it depends on the technologies used, but I'll use Tomcat 5.5</p> <hr> <p>I want to share a Vector of objects of a simple class (just public attributes, strings, ints, etc). My intention is to have a static data like in a DB, obviously it will be lost when the Tomcat is stopped. (it's just for Testing)</p>
[ { "answer_id": 123696, "author": "yalestar", "author_id": 2177, "author_profile": "https://Stackoverflow.com/users/2177", "pm_score": 1, "selected": false, "text": "getSession().setAttribute(\"thing\", object);\n" }, { "answer_id": 123785, "author": "William", "author_id"...
2008/09/23
[ "https://Stackoverflow.com/questions/123657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19689/" ]
123,661
<p>Consider a <em>hypothetical</em> method of an object that does stuff for you:</p> <pre><code>public class DoesStuff { BackgroundWorker _worker = new BackgroundWorker(); ... public void CancelDoingStuff() { _worker.CancelAsync(); //todo: Figure out a way to wait for BackgroundWorker to be cancelled. } } </code></pre> <p>How can one wait for a BackgroundWorker to be done?</p> <hr> <p>In the past people have tried:</p> <pre><code>while (_worker.IsBusy) { Sleep(100); } </code></pre> <p>But <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1819196&amp;SiteID=1" rel="noreferrer">this deadlocks</a>, because <code>IsBusy</code> is not cleared until after the <code>RunWorkerCompleted</code> event is handled, and that event can't get handled until the application goes idle. The application won't go idle until the worker is done. (Plus, it's a busy loop - disgusting.)</p> <p>Others have add suggested kludging it into:</p> <pre><code>while (_worker.IsBusy) { Application.DoEvents(); } </code></pre> <p>The problem with that is that is <code>Application.DoEvents()</code> causes messages currently in the queue to be processed, which cause re-entrancy problems (.NET isn't re-entrant).</p> <p>I would hope to use some solution involving Event synchronization objects, where the code <strong>waits</strong> for an event - that the worker's <code>RunWorkerCompleted</code> event handlers sets. Something like:</p> <pre><code>Event _workerDoneEvent = new WaitHandle(); public void CancelDoingStuff() { _worker.CancelAsync(); _workerDoneEvent.WaitOne(); } private void RunWorkerCompletedEventHandler(sender object, RunWorkerCompletedEventArgs e) { _workerDoneEvent.SetEvent(); } </code></pre> <p>But I'm back to the deadlock: the event handler can't run until the application goes idle, and the application won't go idle because it's waiting for an Event.</p> <p>So how can you wait for an BackgroundWorker to finish?</p> <hr> <p><strong>Update</strong> People seem to be confused by this question. They seem to think that I will be using the BackgroundWorker as:</p> <pre><code>BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += MyWork; worker.RunWorkerAsync(); WaitForWorkerToFinish(worker); </code></pre> <p>That is <em>not</em> it, that is <em>not</em> what I'm doing, and that is <em>not</em> what is being asked here. If that were the case, there would be no point in using a background worker.</p>
[ { "answer_id": 123684, "author": "Seb Nilsson", "author_id": 2429, "author_profile": "https://Stackoverflow.com/users/2429", "pm_score": 2, "selected": false, "text": "private void RunWorkerCompletedEventHandler(sender object, RunWorkerCompletedEventArgs e)\n{\n if(e.Cancelled)\n {...
2008/09/23
[ "https://Stackoverflow.com/questions/123661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
123,672
<p>In <a href="http://msdn.microsoft.com/en-us/library/ms155365%28SQL.90%29.aspx" rel="nofollow noreferrer">this MSDN article</a>, MS explains how to specify other delimiters besides commas for csv-type exports from SSRS 2005, however, literal tab characters are stripped by the config file parser, and it doesn't appear that MS has provided a workaround.<br> <a href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=357527" rel="nofollow noreferrer">This entry</a> on Microsoft Connect seems to confirm this.<br> Has anyone developed a way to export tab-delimited files from SSRS 2005?<br> Or perhaps developed an open-source custom renderer to get the job done? </p> <p>Note: I've heard of manually appending <code>&amp;rc:FieldDelimiter=%09</code> via URL access, but that's not an acceptable workaround for my users and doesn't appear to work anyways.</p>
[ { "answer_id": 124523, "author": "Leo Moore", "author_id": 6336, "author_profile": "https://Stackoverflow.com/users/6336", "pm_score": 1, "selected": false, "text": "use tempdb\ngo\ncreate view vw_bcpMasterSysobjects\nas\n select\n name = '\"' + name + '\"' ,\n crdate = '\"' ...
2008/09/23
[ "https://Stackoverflow.com/questions/123672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19239/" ]
123,718
<p>How can i check to see if a static class has been declared? ex Given the class</p> <pre><code>class bob { function yippie() { echo "skippie"; } } </code></pre> <p>later in code how do i check:</p> <pre><code>if(is_a_valid_static_object(bob)) { bob::yippie(); } </code></pre> <p>so i don't get: Fatal error: Class 'bob' not found in file.php on line 3</p>
[ { "answer_id": 123731, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 3, "selected": false, "text": "bool class_exists( string $class_name [, bool $autoload ]" }, { "answer_id": 123815, "author": "Peter Bai...
2008/09/23
[ "https://Stackoverflow.com/questions/123718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
123,726
<p>How to disable standard ASP.NET handling of 401 response code (redirecting to login page) for AJAX/JSON requests?</p> <p>For web-pages it's okay, but for AJAX I need to get right 401 error code instead of good looking 302/200 for login page.</p> <p><strong>Update</strong>: There are several solutions from Phil Haack, PM of ASP.NET MVC - <a href="http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspx" rel="noreferrer">http://haacked.com/archive/2011/10/04/prevent-forms-authentication-login-page-redirect-when-you-donrsquot-want.aspx</a></p>
[ { "answer_id": 126985, "author": "Troels Thomsen", "author_id": 20138, "author_profile": "https://Stackoverflow.com/users/20138", "pm_score": 1, "selected": false, "text": "FilterAttribute" }, { "answer_id": 130314, "author": "Troels Thomsen", "author_id": 20138, "aut...
2008/09/23
[ "https://Stackoverflow.com/questions/123726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12045/" ]
123,758
<p>Let's say I have the following <code>class X</code> where I want to return access to an internal member:</p> <pre><code>class Z { // details }; class X { std::vector&lt;Z&gt; vecZ; public: Z&amp; Z(size_t index) { // massive amounts of code for validating index Z&amp; ret = vecZ[index]; // even more code for determining that the Z instance // at index is *exactly* the right sort of Z (a process // which involves calculating leap years in which // religious holidays fall on Tuesdays for // the next thousand years or so) return ret; } const Z&amp; Z(size_t index) const { // identical to non-const X::Z(), except printed in // a lighter shade of gray since // we're running low on toner by this point } }; </code></pre> <p>The two member functions <code>X::Z()</code> and <code>X::Z() const</code> have identical code inside the braces. This is duplicate code <strong>and can cause maintenance problems for long functions with complex logic</strong>. </p> <p>Is there a way to avoid this code duplication?</p>
[ { "answer_id": 123765, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 7, "selected": true, "text": "class X\n{\n std::vector<Z> vecZ;\n\npublic:\n const Z& z(size_t index) const\n {\n // same really-really-really lon...
2008/09/23
[ "https://Stackoverflow.com/questions/123758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6386/" ]
123,773
<p>I will choose Java as an example, most people know it, though every other OO language was working as well.</p> <p>Java, like many other languages, has interface inheritance and implementation inheritance. E.g. a Java class can inherit from another one and every method that has an implementation there (assuming the parent is not abstract) is inherited, too. That means the interface is inherited and the implementation for this method as well. I can overwrite it, but I don't have to. If I don't overwrite it, I have inherited the implementation.</p> <p>However, my class can also "inherit" (not in Java terms) just an interface, without implementation. Actually interfaces are really named that way in Java, they provide interface inheritance, but without inheriting any implementation, since all methods of an interface have no implementation.</p> <p>Now there was this <a href="http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html" rel="noreferrer">article, saying it's better to inherit interfaces than implementations</a>, you may like to read it (at least the first half of the first page), it's pretty interesting. It avoids issues like the <a href="http://en.wikipedia.org/wiki/Fragile_base_class" rel="noreferrer">fragile base class problem</a>. So far this makes all a lot of sense and many other things said in the article make a lot of sense to me.</p> <p>What bugs me about this, is that implementation inheritance means <strong>code reuse</strong>, one of the most important properties of OO languages. Now if Java had no classes (like James Gosling, the godfather of Java has wished according to this article), it solves all problems of implementation inheritance, but how would you make code reuse possible then?</p> <p>E.g. if I have a class Car and Car has a method move(), which makes the Car move. Now I can sub-class Car for different type of cars, that are all cars, but are all specialized versions of Car. Some may move in a different way, these need to overwrite move() anyway, but most would simply keep the inherited move, as they move alike just like the abstract parent Car. Now assume for a second that there are only interfaces in Java, only interfaces may inherit from each other, a class may implement interfaces, but all classes are always final, so no class can inherit from any other class.</p> <p>How would you avoid that when you have an Interface Car and hundred Car classes, that you need to implement an identical move() method for each of them? What concepts for code reuse other than implementation inheritance exist in the the OO world?</p> <p>Some languages have Mixins. Are Mixins the answer to my question? I read about them, but I cannot really imagine how Mixins would work in a Java world and if they can really solve the problem here.</p> <p>Another idea was that there is a class that only implements the Car interface, let's call it AbstractCar, and implements the move() method. Now other cars implement the Car interface as well, internally they create an instance of AbstractCar and they implement their own move() method by calling move() on their internal abstract Car. But wouldn't this be wasting resources for nothing (a method calling just another method - okay, JIT could inline the code, but still) and using extra memory for keeping internal objects, you wouldn't even need with implementation inheritance? (after all every object needs more memory than just the sum of the encapsulated data) Also isn't it awkward for a programmer to write dummy methods like</p> <pre><code>public void move() { abstractCarObject.move(); } </code></pre> <p>?</p> <p>Anyone can imagine a better idea how to avoid implementation inheritance and still be able to re-use code in an easy fashion?</p>
[ { "answer_id": 123800, "author": "Xian", "author_id": 4642, "author_profile": "https://Stackoverflow.com/users/4642", "pm_score": 2, "selected": false, "text": "public class Car\n{\n private ICar _car;\n\n public void Move() {\n _car.Move();\n }\n}\n" }, { "answer_id": 124...
2008/09/23
[ "https://Stackoverflow.com/questions/123773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15809/" ]
123,776
<p>I have a page that has an iframe</p> <p>From one of the pages within the iframe I want to look back and make a panel on the default page invisible because it is overshadowing a popup</p> <p>I tried using Parent.FindControl but it does not seem to be working. I am positive I have the right id in the findcontrol because I used Firebug to inspect the panel and I copied the id from there</p> <p>Does anyone know what I am missing?</p>
[ { "answer_id": 124102, "author": "cllpse", "author_id": 20946, "author_profile": "https://Stackoverflow.com/users/20946", "pm_score": 2, "selected": false, "text": "<body>\n <input type=\"text\" id=\"accessme\" value=\"Not Accessed\" />\n ...\n</body>\n" }, { "answer_id": 1...
2008/09/23
[ "https://Stackoverflow.com/questions/123776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
123,781
<p>Is there a way to tell SQL Server 2008 Express to log every query (including each and every SELECT Query!) into a file?</p> <p>It's a Development machine, so the negative side effects of logging Select-Queries are not an issue.</p> <p>Before someone suggests using the SQL Profiler: This is not available in Express (does anyone know if it's available in the Web Edition?) and i'm looking for a way to log queries even when I am away.</p>
[ { "answer_id": 17819485, "author": "Dmytriy Voloshyn", "author_id": 1255305, "author_profile": "https://Stackoverflow.com/users/1255305", "pm_score": 5, "selected": false, "text": "SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]\nFROM sys.dm_exec_query_stats AS deqs\nCROS...
2008/09/23
[ "https://Stackoverflow.com/questions/123781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
123,783
<p>Many websites have the concept of sending messages from user to user. When you send a message to another user, the message would show up in their inbox. You could respond to the message, and it would show up as a new entry in that message thread. </p> <p>You should be able to see if you've read a given message already, and messages that have got a new response should be able to be at the top.</p> <p>How would you design the classes (or tables or whatever) to support such a system?</p>
[ { "answer_id": 123799, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": true, "text": "user\n id\n name\n\nmessages\n id\n to_user_id\n from_user_id\n title\n date\n\nmessage_post\n id\n message_id\n user_id\n messa...
2008/09/23
[ "https://Stackoverflow.com/questions/123783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076/" ]
123,809
<p>If my code throws an exception, sometimes - not everytime - the jsf presents a blank page. Iยดm using facelets for layout. A similar error were reported at this <a href="http://forums.sun.com/thread.jspa?messageID=10237827" rel="nofollow noreferrer">Sun forumnยดs post</a>, but without answers. Anyone else with the same problem, or have a solution? ;)</p> <p>Due to some requests. Here follow more datails:</p> <p>web.xml</p> <pre><code> &lt;error-page&gt; &lt;exception-type&gt;com.company.ApplicationResourceException&lt;/exception-type&gt; &lt;location&gt;/error.faces&lt;/location&gt; &lt;/error-page&gt; </code></pre> <p>And the stack related to jsf is printed after the real exception:</p> <pre><code>####&lt;Sep 23, 2008 5:42:55 PM GMT-03:00&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;comp141&gt; &lt;AdminServer&gt; &lt;[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'&gt; &lt;&lt;WLS Kernel&gt;&gt; &lt;&gt; &lt;&gt; &lt;1222202575662&gt; &lt;BEA-101107&gt; &lt;[weblogic.servlet.internal.WebAppServletContext@6d46b9 - appName: 'ControlPanelEAR', name: 'ControlPanelWeb', context-path: '/Web'] Problem occurred while serving the error page. javax.servlet.ServletException: viewId:/error.xhtml - View /error.xhtml could not be restored. at javax.faces.webapp.FacesServlet.service(FacesServlet.java:249) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:525) at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:261) at weblogic.servlet.internal.ForwardAction.run(ForwardAction.java:22) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.ErrorManager.handleException(ErrorManager.java:144) at weblogic.servlet.internal.WebAppServletContext.handleThrowableFromInvocation(WebAppServletContext.java:2201) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2053) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) at weblogic.work.ExecuteThread.run(ExecuteThread.java:172) javax.faces.application.ViewExpiredException: viewId:/error.xhtml - View /error.xhtml could not be restored. at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:180) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124) </code></pre> <p>Iยดm using the jsf version <code>Mojarra 1.2_09</code>, <code>richfaces 3.2.1.GA</code> and <code>facelets 1.1.13</code>.</p> <p>Hope some help :(</p>
[ { "answer_id": 4972670, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 1, "selected": false, "text": "error.jsp" }, { "answer_id": 14159539, "author": "Christophe Roussy", "author_id": 657427, "aut...
2008/09/23
[ "https://Stackoverflow.com/questions/123809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21370/" ]
123,826
<p>I have a local mercurial repository with some site-specific changes in it. What I would like to do is set a couple files to be un-commitable so that they aren't automatically committed when I do an <code>hg commit</code> with no arguments.</p> <p>Right now, I'm doing complicated things with <code>mq</code> and guards to achieve this, pushing and popping and selecting guards to prevent my changes (which are checked into an mq patch) from getting committed.</p> <p>Is there an easier way to do this? I'm sick of reading the help for all the <code>mq</code> commands every time I want to commit a change that doesn't include my site-specific changes.</p>
[ { "answer_id": 123943, "author": "Toni Ruลพa", "author_id": 6267, "author_profile": "https://Stackoverflow.com/users/6267", "pm_score": 2, "selected": false, "text": ".hgignore" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/123826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6160/" ]
123,838
<p>Our clients will be uploading images to be printed on their documents and we have been asked to come up with a way to get the resolution of the image in order to warn them if the image has too low of a resolution and will look pixalated in the end-product</p> <p>If it comes to it we could also go with the dimensions if anyone knows how to get those but the resolution would be preferred</p> <p>Thank you</p>
[ { "answer_id": 123854, "author": "Xian", "author_id": 4642, "author_profile": "https://Stackoverflow.com/users/4642", "pm_score": 5, "selected": true, "text": "Image newImage = Image.FromFile(\"SampImag.jpg\");\nnewImage.HorizontalResolution\n" }, { "answer_id": 123869, "auth...
2008/09/23
[ "https://Stackoverflow.com/questions/123838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
123,842
<p>Am I missing something or is there truly no alternative (yet, I hope) to SVCUTIL.EXE for generating WCF Web service proxies? </p>
[ { "answer_id": 411791, "author": "flq", "author_id": 51428, "author_profile": "https://Stackoverflow.com/users/51428", "pm_score": 2, "selected": false, "text": "DuplexChannelFactory<IServerWithCallback> cf = \n new DuplexChannelFactory<IServerWithCallback>(\n new Callb...
2008/09/23
[ "https://Stackoverflow.com/questions/123842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536/" ]
123,862
<p>I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception.</p> <p>What would be the best way to implement a wrapper method that doesn't throw an exception except if the server wasn't available for at least one minute?</p>
[ { "answer_id": 123901, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 2, "selected": false, "text": "//Create Timer\n//Start Timer\nbool connected = false;\n\nwhile (!connected)\n\n try {\n //Connect To DB\n\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/123862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686/" ]
123,918
<p>System.IO.BinaryReader reads values in a little-endian format.</p> <p>I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find that dealing with this on the client side is awkward, particularly for unsigned values.</p> <pre><code>UInt32 length = (UInt32)IPAddress.NetworkToHostOrder(reader.ReadInt32()); </code></pre> <p>is the only way I've come up with to get a correct unsigned value out of the stream, but this seems both awkward and ugly, and I have yet to test if that's just going to clip off high-order values so that I have to do fun BitConverter stuff.</p> <p>Is there some way I'm missing short of writing a wrapper around the whole thing to avoid these ugly conversions on every read? It seems like there should be an endian-ness option on the reader to make things like this simpler, but I haven't come across anything.</p>
[ { "answer_id": 155297, "author": "Nick", "author_id": 1490, "author_profile": "https://Stackoverflow.com/users/1490", "pm_score": 4, "selected": true, "text": "/// <summary>\n/// Utilities for reading big-endian files\n/// </summary>\npublic class BigEndianReader\n{\n public BigEndian...
2008/09/23
[ "https://Stackoverflow.com/questions/123918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21374/" ]
123,920
<p>I'm writing by own blogging engine in PHP with a MYSQL backend database. MY question is: How would you go about making user comments and blog posts include newlines wherever they are appropriate?</p> <p>For example, if a user hits the return key in the message/comments box how would this translate into a new line that would show in the browser when the comment is viewed?</p>
[ { "answer_id": 123937, "author": "Gavin M. Roy", "author_id": 13203, "author_profile": "https://Stackoverflow.com/users/13203", "pm_score": 3, "selected": false, "text": "<br />" }, { "answer_id": 123944, "author": "Jim", "author_id": 8427, "author_profile": "https://...
2008/09/23
[ "https://Stackoverflow.com/questions/123920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
123,927
<p>I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to.</p> <p>I might explore using Nullsoft or MSI for install, but since I'm mostly familiar with .NET I initially plan to try either custom .NET installer or setup component on .NET.</p> <p>Is it possible to determine the drive letter of a USB flash drive on Windows using .NET? How?</p>
[ { "answer_id": 123948, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 5, "selected": true, "text": "from driveInfo in DriveInfo.GetDrives()\nwhere driveInfo.DriveType == DriveType.Removable && driveInfo.IsReady\nselect ...
2008/09/23
[ "https://Stackoverflow.com/questions/123927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124/" ]
123,936
<p>Some of my colleagues use special comments on their bug fixes, for example:</p> <pre><code>// 2008-09-23 John Doe - bug 12345 // &lt;short description&gt; </code></pre> <p>Does this make sense?<br> Do you comment bug fixes in a special way?</p> <p>Please let me know.</p>
[ { "answer_id": 123965, "author": "henriksen", "author_id": 6181, "author_profile": "https://Stackoverflow.com/users/6181", "pm_score": 2, "selected": false, "text": "// Glenn F. Henriksen (<email@company.no) - 2008-09-23\n// <Short description>\n" }, { "answer_id": 123977, "a...
2008/09/23
[ "https://Stackoverflow.com/questions/123936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2012356/" ]
123,945
<p>I have a Excel macro that generates a this error whenever it gets input of a specific format. Does anyone knows <strong>in general</strong> what an <em>advise flag</em> is OR where can I find information on this type of error? Thanks</p> <blockquote> <p>Runtime error -2147221503 (80040001): Automation error, Invalid advise flags</p> </blockquote>
[ { "answer_id": 123965, "author": "henriksen", "author_id": 6181, "author_profile": "https://Stackoverflow.com/users/6181", "pm_score": 2, "selected": false, "text": "// Glenn F. Henriksen (<email@company.no) - 2008-09-23\n// <Short description>\n" }, { "answer_id": 123977, "a...
2008/09/23
[ "https://Stackoverflow.com/questions/123945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
123,958
<p>In python is it possible to get or set a logical directory (as opposed to an absolute one).</p> <p>For example if I have:</p> <pre><code>/real/path/to/dir </code></pre> <p>and I have</p> <pre><code>/linked/path/to/dir </code></pre> <p>linked to the same directory.</p> <p>using os.getcwd and os.chdir will always use the absolute path</p> <pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; os.chdir('/linked/path/to/dir') &gt;&gt;&gt; print os.getcwd() /real/path/to/dir </code></pre> <p>The only way I have found to get around this at all is to launch 'pwd' in another process and read the output. However, this only works until you call os.chdir for the first time.</p>
[ { "answer_id": 123985, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 5, "selected": true, "text": "os.getcwd()" }, { "answer_id": 27951538, "author": "radtek", "author_id": 2023392, "author_profile": "ht...
2008/09/23
[ "https://Stackoverflow.com/questions/123958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3051/" ]
123,976
<p>What is the best way to encrypt an URL with parameters in Java?</p>
[ { "answer_id": 124036, "author": "Internet Friend", "author_id": 18037, "author_profile": "https://Stackoverflow.com/users/18037", "pm_score": 0, "selected": false, "text": "java.net.URLEncoder.encode" }, { "answer_id": 970876, "author": "Denis", "author_id": 52472, "...
2008/09/23
[ "https://Stackoverflow.com/questions/123976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1408/" ]
123,979
<p>I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like:</p> <pre><code>var clipName = "barLeft42" </code></pre> <p>which is held inside another movie clip called 'thing'.</p> <p>I have been able to get hold of a reference using:</p> <pre><code>var movieClip = Eval( "_root.thing." + clipName ) </code></pre> <p>But that feels bad - is there a better way?</p>
[ { "answer_id": 124010, "author": "Ronnie", "author_id": 193, "author_profile": "https://Stackoverflow.com/users/193", "pm_score": 3, "selected": true, "text": "_root.thing[ \"barLeft42\" ]\n" }, { "answer_id": 125290, "author": "fenomas", "author_id": 10651, "author_p...
2008/09/23
[ "https://Stackoverflow.com/questions/123979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21214/" ]
123,986
<p>I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers).</p> <p>is it possible to check that specific USB card is inserted on windows using .NET 2.0? how?</p> <p>if I find it through WMI, can I somehow determine which drive letter the USB drive is on?</p>
[ { "answer_id": 124149, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 5, "selected": true, "text": "Console.WriteLine(\"Manufacturer: {0}\", queryObj[\"Manufacturer\"]);\n...\nConsole.WriteLine(\" Name: {0}\", c[\"N...
2008/09/23
[ "https://Stackoverflow.com/questions/123986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124/" ]
123,994
<p>I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being passed via the QueryString. Is there any way to handle this server side?</p> <p>Example:</p> <pre><code>http://localhost:3399/Base64.aspx?VLTrap=VkxUcmFwIHNldCB0byAiRkRTQT8+PE0iIHBsdXMgb3IgbWludXMgNSBwZXJjZW50Lg== </code></pre> <p>Produces:</p> <pre><code>VkxUcmFwIHNldCB0byAiRkRTQT8 PE0iIHBsdXMgb3IgbWludXMgNSBwZXJjZW50Lg== </code></pre> <p>People have suggested URLEncoding the querystring:</p> <pre><code>System.Web.HttpUtility.UrlEncode(yourString) </code></pre> <p>I can't do that as I have no control over the calling routine (which is working fine with other languages).</p> <p>There was also the suggestion of replacing spaces with a plus sign:</p> <pre><code>Request.QueryString["VLTrap"].Replace(" ", "+"); </code></pre> <p>I had though of this but my concern with it, and I should have mentioned this to start, is that I don't know what <em>other</em> characters might be malformed in addition to the plus sign.</p> <p><strong><em>My main goal is to intercept the QueryString before it is run through the decoder.</em></strong></p> <p>To this end I tried looking at Request.QueryString.toString() but this contained the same malformed information. Is there any way to look at the raw QueryString <em>before</em> it is URLDecoded?</p> <p>After further testing it appears that .Net expects everything coming in from the QuerString to be URL encoded but the browser does not automatically URL encode GET requests.</p>
[ { "answer_id": 124014, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 0, "selected": false, "text": "Request.QueryString[\"VLTrap\"].Replace(\" \", \"+\");\n" }, { "answer_id": 124027, "author": "Troels Thom...
2008/09/23
[ "https://Stackoverflow.com/questions/123994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7819/" ]
123,999
<p>Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the <strong>viewport</strong>)?</p> <p>(The question refers to Firefox.)</p>
[ { "answer_id": 125106, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 10, "selected": true, "text": "function elementInViewport(el) {\n var top = el.offsetTop;\n var left = el.offsetLeft;\n var width = el.offsetWidth;\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/123999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21290/" ]
124,005
<p>I have an SSIS package that copies the data in a table from one SQL Server 2005 to another SQL Server 2005. I do this with a "Data Flow" task. In the package config file I expose the destination table name.</p> <p>Problem is when I change the destination table name in the config file (via notepad) I get the following error "vs_needsnewmetadata". I think I understand the problem... the destination table column mapping is fixed when I first set up the package.</p> <p>Question: what's the easiest way to do the above with an ssis package? </p> <p>I've read online about setting up the metadata programmatically and all but I'd like to avoid this. Also I wrote a C# console app that does everything just fine... all tables etc are specified in the app.config ... but apparently this solution isn't good enough.</p>
[ { "answer_id": 124461, "author": "ctrlShiftBryan", "author_id": 6161, "author_profile": "https://Stackoverflow.com/users/6161", "pm_score": 0, "selected": false, "text": "INSERT INTO server1.dbo.database1.table1(id,name)\nSELECT id, name FROM server2.dbo.database1.table1\n" }, { ...
2008/09/23
[ "https://Stackoverflow.com/questions/124005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
124,031
<p>Using MS SQL Server Management Studio 2005 - To Restore a Database:</p> <ul> <li>Restore Database</li> <li><code>(*) From Device:</code></li> <li>Click "<code>...</code>" Button</li> <li><code>Backup media: File</code> </li> <li>Click "<code>Add</code>" Button</li> <li>Popup Window: "<code>Locate Backup File</code>"</li> </ul> <p>That window Defaults to <code>C:\Program Files\Microsoft SQL Server\MSSQL.1\Backup</code></p> <p>How do I configure MS SQL Server Management Studio to look in <code>D:\data\databases\</code><br> instead of looking in <code>C:\Program Files\Microsoft SQL Server\MSSQL.1\Backup</code> ?</p>
[ { "answer_id": 124106, "author": "henriksen", "author_id": 6181, "author_profile": "https://Stackoverflow.com/users/6181", "pm_score": 5, "selected": true, "text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.1\\MSSQLServer\\BackupDirectory" }, { "answer_...
2008/09/23
[ "https://Stackoverflow.com/questions/124031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12923/" ]
124,035
<p>I recently converted a ruby library to a gem, which seemed to break the command line usability</p> <p>Worked fine as a library</p> <pre><code> $ ruby -r foobar -e 'p FooBar.question' # =&gt; "answer" </code></pre> <p>And as a gem, irb knows how to require a gem from command-line switches</p> <pre><code> $ irb -rubygems -r foobar irb(main):001:0&gt; FooBar.question # =&gt; "answer" </code></pre> <p>But the same fails for ruby itself:</p> <pre><code> $ ruby -rubygems -r foobar -e 'p FooBar.question' ruby: no such file to load -- foobar (LoadError) </code></pre> <p>must I now do this, which seems ugly: </p> <pre><code> ruby -rubygems -e 'require "foobar"; p FooBar.question' # =&gt; "answer" </code></pre> <p>Or is there a way to make the 2 switches work?</p> <p><em>Note</em>: I know the gem could add a bin/program for every useful method but I don't like to pollute the command line namespace unnecessarily</p>
[ { "answer_id": 124069, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 4, "selected": true, "text": "ruby -rubygems -r /usr/lib/ruby/gems/myhelpfulclass-0.0.1/lib/MyHelpfulClass -e \"puts MyHelpfulClass\"\n" }, { "...
2008/09/23
[ "https://Stackoverflow.com/questions/124035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4615/" ]
124,066
<p>I've found a similar question on stack overflow, but it didn't really answer the question I have. I need to make sure that my asp.net application is formatting the date dd/mm/yyyy the same as my SQL Server 2005.</p> <p>How do I verify the date culture (if that's what it's called) of the server matches how I've programmed my app? Are there specific database settings and OS settings? Is it table-specific? I don't want to transpose my days and months.</p> <p>thank you</p>
[ { "answer_id": 124208, "author": "Jorge Alves", "author_id": 6195, "author_profile": "https://Stackoverflow.com/users/6195", "pm_score": 0, "selected": false, "text": "string sqlCmd = @\"SELECT *\n FROM MyTable\n WHERE MyDateField = CONVERT(datetime, '{0}', 101)\";\n\n// assuming myD...
2008/09/23
[ "https://Stackoverflow.com/questions/124066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5433/" ]
124,067
<p>In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# <code>System.Text.StringBuilder</code> and Java <code>java.lang.StringBuilder</code>.</p> <p>Does php (4 or 5; I'm interested in both) share this limitation? If so, are there similar solutions to the problem available?</p>
[ { "answer_id": 124084, "author": "paan", "author_id": 2976, "author_profile": "https://Stackoverflow.com/users/2976", "pm_score": -1, "selected": false, "text": "$a=\"hello \";\n$b=\"world\";\necho $a.$b;\n" }, { "answer_id": 124109, "author": "Peter Bailey", "author_id":...
2008/09/23
[ "https://Stackoverflow.com/questions/124067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21388/" ]
124,076
<p>When I use traceroute, I often see abbreviations in the hostnames along the route, such as "ge", "so", "ic", "gw", "bb" etc. I can guess "bb" means backbone.</p> <p>Does anyone know what any these strings abbreviate, or know any other common abbreviations?</p>
[ { "answer_id": 23001209, "author": "Tech", "author_id": 3521618, "author_profile": "https://Stackoverflow.com/users/3521618", "pm_score": 0, "selected": false, "text": "so = sonet, pos = packet over sonet\nxe= ten gigabit\nge= gigabit" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19214/" ]
124,079
<p>I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. </p> <p>I've tried developing and benchmarking various Ruby scripts to process these files, and always end up with glacial results. </p> <p>What would you do in Ruby to make this not so dog slow?</p>
[ { "answer_id": 124088, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "counts = {}\ncounts.default = 0\n\nARGF.each_line do |line|\n if line =~ %r{GET /ongoing/When/\\d\\d\\dx/(\\d\\d\\d\\d...
2008/09/23
[ "https://Stackoverflow.com/questions/124079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21275/" ]
124,096
<p>I tend to implement UI functionality using fairly self-documenting void doSomething() methods, i.e. if the user presses this button then perform this action then enable this list box, disable that button, etc. Is this the best approach? Is there a better pattern for general UI management i.e. how to control when controls are enabled/disabled/etc. etc. depending on user input?</p> <p>Often I feel like I'm veering towards the 'big class that does everything' anti-pattern as so much seems to interact with the 'main' form class. Often, even if I'm including private state variables in the class that have been implemented using a relatively modular design, I'm still finding it grows so quickly it's ridiculous.</p> <p>So could people give me some good advice towards producing quality, testable, decoupled WinForms design without falling into these traps?</p>
[ { "answer_id": 124119, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 0, "selected": false, "text": "class Form1 : Form\n { \n void Button1_Click\n { \n Program.DoCommand1();\n }\n }\n\n\nstatic class Pr...
2008/09/23
[ "https://Stackoverflow.com/questions/124096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3394/" ]
124,108
<p>I am trying to mock-up an API and am using separate apps within Django to represent different web services. I would like App A to take in a link that corresponds to App B and parse the <code>json</code> response. </p> <p>Is there a way to dynamically construct the url to App B so that I can test the code in development and not change to much before going into production? The problem is that I can't use localhost as part of a link. </p> <p>I am currently using urllib, but eventually I would like to do something less hacky and better fitting with the web services <code>REST</code> paradigm.</p>
[ { "answer_id": 124119, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 0, "selected": false, "text": "class Form1 : Form\n { \n void Button1_Click\n { \n Program.DoCommand1();\n }\n }\n\n\nstatic class Pr...
2008/09/23
[ "https://Stackoverflow.com/questions/124108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1227001/" ]
124,118
<p>We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?</p>
[ { "answer_id": 139790, "author": "Christopher G. Lewis", "author_id": 13532, "author_profile": "https://Stackoverflow.com/users/13532", "pm_score": 3, "selected": true, "text": "cscript %SystemDrive%\\inetpub\\AdminScripts\\adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1\n" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
124,123
<p>Imagine I have the folling XML file:</p> <p>&lt;a&gt;before&lt;b&gt;middle&lt;/b&gt;after&lt;/a&gt;</p> <p>I want to convert it into something like this:</p> <p>&lt;a&gt;beforemiddleafter&lt;/a&gt;</p> <p>In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv ./directory/* .", but for xml nodes.</p> <p>I'd like to do this in using unix command line tools. I've been trying with xmlstarlet, which is a powerful command line XML manipulator. I tried doing something like this, but it doesn't work</p> <p>echo "&lt;a&gt;before&lt;b&gt;middle&lt;/b&gt;after&lt;/a&gt;" | xmlstarlet ed -m "//b/*" ".."</p> <p>Update: XSLT templates are fine, since they can be called from the command line.</p> <p>My goal here is 'remove the links from an XHTML page', in other words replace where the link was, with the contents of the link tag.</p>
[ { "answer_id": 124215, "author": "Rahul", "author_id": 16308, "author_profile": "https://Stackoverflow.com/users/16308", "pm_score": 2, "selected": false, "text": "<xsl:template match=\"a\"><a><xsl:apply-templates /></a></xsl:template>\n\n<xsl:template match=\"a/b\"><xsl:value-of select=...
2008/09/23
[ "https://Stackoverflow.com/questions/124123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161922/" ]
124,143
<p>I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions.<br/> <strong>What is the main reason of the difference between Java and C# in throwing exceptions?</strong><br/> In Java the signature of a method that throws an exception has to use the "throws" keyword, while in C# you don't know in compilation time if an exception could be thrown.</p>
[ { "answer_id": 124173, "author": "Derek Slager", "author_id": 18636, "author_profile": "https://Stackoverflow.com/users/18636", "pm_score": 4, "selected": false, "text": "using" }, { "answer_id": 124175, "author": "noah", "author_id": 12034, "author_profile": "https:/...
2008/09/23
[ "https://Stackoverflow.com/questions/124143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68336/" ]
124,148
<p>Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue:</p> <pre><code>int i = 4; ... if (i == 10) doStuff(); </code></pre> <p>Later on you figure that you want the variable <em>i</em> to be either defined or undefined, so you change the above instantiation to:</p> <pre><code>Integer i = null; </code></pre> <p>Now the equality check fails.</p> <p>Is it good Java practise to always use the primitive wrapper classes? It obviously would get some bugs out of the way early, but what are the downsides to this? Does it impact performance or the application's memory footprint? Are there any sneaky gotchas?</p>
[ { "answer_id": 124196, "author": "Michael Deardeuff", "author_id": 4931, "author_profile": "https://Stackoverflow.com/users/4931", "pm_score": 5, "selected": true, "text": "(i == 10)" }, { "answer_id": 124202, "author": "tim_yates", "author_id": 6509, "author_profile"...
2008/09/23
[ "https://Stackoverflow.com/questions/124148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8683/" ]
124,166
<p>What is the best way to make a <code>&lt;div&gt;</code> fade away after a given amount of time (without using some of the JavaScript libraries available).</p> <p>I'm looking for a very lightweight solution not requiring a huge JavaScript library to be sent to the browser.</p>
[ { "answer_id": 124294, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 2, "selected": false, "text": "var TimeToFade = 200.0;\n\nfunction fade(eid)\n{\n var element = document.getElementById(eid);\n if(element == n...
2008/09/23
[ "https://Stackoverflow.com/questions/124166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16440/" ]
124,167
<p>Please explain to me why the very last <code>echo</code> statement is blank? I expect that <code>XCODE</code> is incremented in the while loop to a value of 1:</p> <pre><code>#!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "Status WARN: No messages from SMcli" exit $STATE_WARNING else echo "$OUTPUT"|while read NAME IP1 IP2 STATUS do if [ "$STATUS" != "Optimal" ] then echo "CRIT: $NAME - $STATUS" echo $((++XCODE)) else echo "OK: $NAME - $STATUS" fi done fi echo $XCODE </code></pre> <p>I've tried using the following statement instead of the <code>++XCODE</code> method</p> <pre><code>XCODE=`expr $XCODE + 1` </code></pre> <p>and it too won't print outside of the while statement. I think I'm missing something about variable scope here, but the ol' man page isn't showing it to me.</p>
[ { "answer_id": 124211, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": " #!/bin/bash\n OUTPUT=\"name1 ip ip status\"\n+export XCODE=0;\n if [ -z \"$OUTPUT\" ]\n----\n\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/124167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14230/" ]
124,170
<p>I'm doing a sitemap producer in Object Pascal and need a good function or lib to emulate the <a href="http://php.net/manual/en/function.parse-url.php" rel="nofollow noreferrer">parse_url</a> function on PHP.</p> <p>Does anyone know of any good ones?</p>
[ { "answer_id": 124200, "author": "Armin Ronacher", "author_id": 19990, "author_profile": "https://Stackoverflow.com/users/19990", "pm_score": 0, "selected": false, "text": " ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?\n 12 3 4 5 6 7 8 ...
2008/09/23
[ "https://Stackoverflow.com/questions/124170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8167/" ]
124,171
<p>I'd be very grateful if you could compare the winning <a href="http://www.cs.ucsd.edu/~sorourke/wf.pl" rel="nofollow noreferrer">Oโ€™Rourke's Perl solution</a> to <a href="http://effbot.org/zone/wide-finder.htm" rel="nofollow noreferrer">Lundh's Python solution</a>, as I don't know Perl good enough to understand what's going on there. More specifically I'd like to know what gave Perl version 3x advantage: algorithmic superiority, quality of C extensions, other factors?</p> <p><a href="http://www.tbray.org/ongoing/When/200x/2007/10/30/WF-Results" rel="nofollow noreferrer">Wide Finder: Results</a></p>
[ { "answer_id": 13300315, "author": "Mario Roy", "author_id": 1810910, "author_profile": "https://Stackoverflow.com/users/1810910", "pm_score": 2, "selected": false, "text": "Script....: baseline1 baseline2 wf_mce1 wf_mce2 wf_mce3 wf_mmap\nCold cache: 1.674 1.370 1.252 ...
2008/09/23
[ "https://Stackoverflow.com/questions/124171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20310/" ]
124,205
<p>I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In <code>MySQL</code> I would use <code>SHOW TABLES LIKE "Datasheet%"</code>, but in <code>T-SQL</code> this throws an error (it tries to look for a <code>SHOW</code> stored procedure and fails).</p> <p>Is this possible, and if so, how?</p>
[ { "answer_id": 124216, "author": "Mladen", "author_id": 21404, "author_profile": "https://Stackoverflow.com/users/21404", "pm_score": 3, "selected": false, "text": "select * from information_schema.columns\nwhere table_name = 'yourTableName'\n" }, { "answer_id": 124220, "auth...
2008/09/23
[ "https://Stackoverflow.com/questions/124205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21402/" ]
124,210
<p>In order to help my team write testable code, I came up with this simple list of best practices for making our C# code base more testable. (Some of the points refer to limitations of Rhino Mocks, a mocking framework for C#, but the rules may apply more generally as well.) Does anyone have any best practices that they follow?</p> <p>To maximize the testability of code, follow these rules:</p> <ol> <li><p><strong>Write the test first, then the code.</strong> Reason: This ensures that you write testable code and that every line of code gets tests written for it.</p></li> <li><p><strong>Design classes using dependency injection.</strong> Reason: You cannot mock or test what cannot be seen.</p></li> <li><p><strong>Separate UI code from its behavior using Model-View-Controller or Model-View-Presenter.</strong> Reason: Allows the business logic to be tested while the parts that can't be tested (the UI) is minimized.</p></li> <li><p><strong>Do not write static methods or classes.</strong> Reason: Static methods are difficult or impossible to isolate and Rhino Mocks is unable to mock them.</p></li> <li><p><strong>Program off interfaces, not classes.</strong> Reason: Using interfaces clarifies the relationships between objects. An interface should define a service that an object needs from its environment. Also, interfaces can be easily mocked using Rhino Mocks and other mocking frameworks.</p></li> <li><p><strong>Isolate external dependencies.</strong> Reason: Unresolved external dependencies cannot be tested.</p></li> <li><p><strong>Mark as virtual the methods you intend to mock.</strong> Reason: Rhino Mocks is unable to mock non-virtual methods.</p></li> </ol>
[ { "answer_id": 125600, "author": "zadam", "author_id": 410357, "author_profile": "https://Stackoverflow.com/users/410357", "pm_score": 3, "selected": false, "text": "// ShouldExpectMethodCallWithVariable\nint value = 5;\nvar mock = new Mock<IFoo>();\n\nmock.Expect(x => x.Duplicate(value)...
2008/09/23
[ "https://Stackoverflow.com/questions/124210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10475/" ]
124,240
<p>Been using <strong>PHP/MySQL</strong> for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using <code>mysql_fetch_object()</code> vs <code>mysql_fetch_assoc()</code> / <code>mysql_fetch_array()</code>.</p>
[ { "answer_id": 124262, "author": "Steve Paulo", "author_id": 9414, "author_profile": "https://Stackoverflow.com/users/9414", "pm_score": 2, "selected": false, "text": "mysql_fetch_array()" }, { "answer_id": 124270, "author": "rami", "author_id": 9629, "author_profile"...
2008/09/23
[ "https://Stackoverflow.com/questions/124240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2227/" ]
124,250
<p>Anybody know a nice way to restart a mongrel cluster via capistrano in a "rolling" style, eg, one mongrel at a time. Would be great to have a bit of wait time in there as well for each, to let the mongrel load the rails app up as well. </p> <p>I've done some searching, and haven't found too much, so looking for help before I dive into the mongrel_cluster gem myself.</p> <p>Thanks!</p>
[ { "answer_id": 124962, "author": "Dan Udey", "author_id": 21450, "author_profile": "https://Stackoverflow.com/users/21450", "pm_score": 1, "selected": false, "text": "#!/bin/bash\nfor PIDFILE in /tmp/mongrel.*; do\n PID=$(cat ${PIDFILE})\n kill ${PID}\n ${RUN_MONGREL_CMD} ${PID}\n sl...
2008/09/23
[ "https://Stackoverflow.com/questions/124250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14873/" ]
124,266
<p>What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.</p> <pre><code>$sortedObjectArary = sort($unsortedObjectArray, $Object-&gt;weight); </code></pre> <p>Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there might be something useful there, but I don't see anything elegant or obvious.</p>
[ { "answer_id": 124283, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 7, "selected": true, "text": "function compare_weights($a, $b) { \n if($a->weight == $b->weight) {\n return 0;\n } \n return ($a->we...
2008/09/23
[ "https://Stackoverflow.com/questions/124266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8880/" ]
124,269
<p>What is the simplest SOAP example using Javascript?</p> <p>To be as useful as possible, the answer should:</p> <ul> <li>Be functional (in other words actually work)</li> <li>Send at least one parameter that can be set elsewhere in the code</li> <li>Process at least one result value that can be read elsewhere in the code</li> <li>Work with most modern browser versions</li> <li>Be as clear and as short as possible, without using an external library</li> </ul>
[ { "answer_id": 124663, "author": "Constantin", "author_id": 20310, "author_profile": "https://Stackoverflow.com/users/20310", "pm_score": 1, "selected": false, "text": "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns:xsd=\"http://www.w3.org/20...
2008/09/23
[ "https://Stackoverflow.com/questions/124269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15985/" ]
124,291
<p>I need to do some simple timezone calculation in mod_perl. DateTime isn't an option. What I need to do is easily accomplished by setting $ENV{TZ} and using localtime and POSIX::mktime, but under a threaded MPM, I'd need to make sure only one thread at a time was mucking with the environment. (I'm not concerned about other uses of localtime, etc.)</p> <p>How can I use a mutex or other locking strategy to serialize (in the non-marshalling sense) access to the environment? The <a href="http://perl.apache.org/docs/2.0/api/APR/ThreadMutex.html" rel="nofollow noreferrer">docs</a> I've looked at don't explain well enough how I would create a mutex for just this use. Maybe there's something I'm just not getting about how you create mutexes in general.</p> <p>Update: yes, I am aware of the need for using Env::C to set TZ.</p>
[ { "answer_id": 125010, "author": "pjf", "author_id": 19422, "author_profile": "https://Stackoverflow.com/users/19422", "pm_score": 1, "selected": false, "text": "{\n local $ENV{TZ} = whatever_I_need_it_to_be();\n\n # Do calculations here.\n}\n" }, { "answer_id": 125533, ...
2008/09/23
[ "https://Stackoverflow.com/questions/124291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17389/" ]
124,295
<p>Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locations? I tried creating the assembly with the dll the project built in SQL, and while it did add the assembly, it did not create the procedures out of the assembly. Has anyone figured out how to do this in SQL directly, without using Visual Studio?</p>
[ { "answer_id": 124528, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 4, "selected": true, "text": "create assembly [YOUR_ASSEMBLY]\nfrom '(PATH_TO_DLL)'\n" }, { "answer_id": 2874274, "author": "Grhm", "...
2008/09/23
[ "https://Stackoverflow.com/questions/124295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4539/" ]
124,296
<p>Let's say that I have a widget that displays summary information about how many posts or comments that I have on a site.</p> <p>What's the cleanest way to persist this information across controllers? </p> <p>Including the instance variables in the application controller seems like a bad idea. Having a before filter that loads the data for each controller smells like code duplication. </p> <p>Do I have to use a plugin like the Cells Plugin (<a href="http://cells.rubyforge.org/" rel="nofollow noreferrer">http://cells.rubyforge.org/</a>) or is there a simpler way of doing it?</p>
[ { "answer_id": 128626, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "def load_sidebar\n @posts = Post.find(:all)\nend\n" }, { "answer_id": 129246, "author": "jdl", "author_id": 9...
2008/09/23
[ "https://Stackoverflow.com/questions/124296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
124,299
<p>So I'm using hibernate and working with an application that manages time. What is the best way to deal with times in a 24 hour clock?</p> <p>I do not need to worry about TimeZone issues at the beginning of this application but it would be best to ensure that this functionality is built in at the beginning.</p> <p>I'm using hibernate as well, just as an fyi</p>
[ { "answer_id": 125025, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 0, "selected": false, "text": "java.util.Date" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1129162/" ]
124,313
<p>I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that is performing web-service updates simultaneously when they get updates from PayPal as well.</p> <p>Here is a basic diagram of the database tables involved.</p> <pre><code>// table "package" // columns packageID, policyID, other data... // // table "insurancepolicy" // columns policyID, coverageAmount, other data... </code></pre> <p>Here is a basic diagram of what I want to do:</p> <pre><code>using (SqlConnection conn = new SqlConnection(...)) { sqlTransaction sqlTrans = conn.BeginTransaction(IsolationLevel.RepeatableRead); // Calls a stored procedure that checks if the foreign key in the transaction table has a value. if (PackageDB.HasInsurancePolicy(packageID, conn)) { sqlTrans.Commit(); return false; } // Insert row in foreign table. int policyID = InsurancePolicyDB.Insert(coverageAmount, conn); if (policyID &lt;= 0) { sqlTrans.Rollback(); return false; } // Assign foreign key to parent table. If this fails, roll back everything. bool assigned = PackageDB.AssignPolicyID(packageID, policyID, conn); if (!assigned) { sqlTrans.Rollback(); return false; } } </code></pre> <p>If there are two (or more) threads (or processes or applications) doing this at the same time, I want the first thread to lock the "package" row while it has no policyID, until the policy is created and the policyID is assigned to the package table. Then the lock would be released after the policyID is assigned to the package table. It is my hope that the other thread which is calling this same code will pause when it reads the package row to make sure it doesn't have a policyID first. When the first transaction's lock is released, it is my hope that the second transaction will see the policyID is there and therefore return without inserting any rows into the policy table.</p> <p>Note: Because of the CRUD database design, each the stored procedures involved either Read (select), Create (insert), or Update.</p> <p>Is this the right use of RepeatableRead transaction isolation?</p> <p>Thanks.</p>
[ { "answer_id": 124763, "author": "Constantin", "author_id": 20310, "author_profile": "https://Stackoverflow.com/users/20310", "pm_score": 2, "selected": true, "text": "insert into Policy" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16454/" ]
124,325
<p>I'm trying to grasp the concept of .NET Generics and actually use them in my own code but I keep running into a problem.</p> <p>Can someone try to explain to me why the following setup does not compile?</p> <pre><code>public class ClassA { ClassB b = new ClassB(); public void MethodA&lt;T&gt;(IRepo&lt;T&gt; repo) where T : ITypeEntity { b.MethodB(repo); } } public class ClassB { IRepo&lt;ITypeEntity&gt; repo; public void MethodB(IRepo&lt;ITypeEntity&gt; repo) { this.repo = repo; } } </code></pre> <p>I get the following error:<br> cannot convert from IRepo&lt;'T> to IRepo&lt;'ITypeEntity></p> <p>MethodA gets called with a IRepo&lt;'DetailType> object parameter where DetailType inherits from ITypeEntity.</p> <p>I keep thinking that this should compile as I'm constraining T within MethodA to be of type ITypeEntity.</p> <p>Any thoughts or feedback would be extremely helpful.</p> <p>Thanks.</p> <p><b>Edit:</b> Nick R has a great suggestion but unfortunately in my context, I don't have the option of making ClassA Generic. ClassB could be though.</p>
[ { "answer_id": 124388, "author": "Smashery", "author_id": 14902, "author_profile": "https://Stackoverflow.com/users/14902", "pm_score": 0, "selected": false, "text": "Class<B>" }, { "answer_id": 124418, "author": "Nick Randell", "author_id": 5932, "author_profile": "h...
2008/09/23
[ "https://Stackoverflow.com/questions/124325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384853/" ]
124,326
<p>JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"?</p> <p>This works:</p> <pre><code>var foo = function() { return 1; }; foo.baz = "qqqq"; </code></pre> <p>At this point, <code>foo()</code> calls the function, and <code>foo.baz</code> has the value "qqqq".</p> <p>However, if you do the property assignment part first, how do you subsequently assign a function to the variable?</p> <pre><code>var bar = { baz: "qqqq" }; </code></pre> <p>What can I do now to arrange for <code>bar.baz</code> to have the value "qqqq" <em>and</em> <code>bar()</code> to call the function?</p>
[ { "answer_id": 124359, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": -1, "selected": false, "text": "var three = 3;\nthree = 4;\nassert(three === 3);\n" }, { "answer_id": 124387, "author": "Kent Fredric", "author...
2008/09/23
[ "https://Stackoverflow.com/questions/124326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11543/" ]
124,332
<p>I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like </p> <pre><code>P = C^d % n = 62^65 % 133 </code></pre> <p>Now that is really the only calculations that ill be doing. I have tried using Matt McCutchen's BigInteger Library, but I am getting a lot of compiler errors during linking, such as:</p> <pre><code>encryption.o(.text+0x187):encryption.cpp: undefined reference to `BigInteger::BigInteger(int)' encryption.o(.text+0x302):encryption.cpp: undefined reference to `operator&lt;&lt;(std::ostream&amp;, BigInteger const&amp;)' encryption.o(.text$_ZNK10BigIntegermlERKS_[BigInteger::operator*(BigInteger const&amp;) const]+0x63):encryption.cpp: undefined reference to `BigInteger::multiply(BigInteger const&amp;, BigInteger const&amp;)' </code></pre> <p>So I was wondering what would be the best way to go about handling the really big integers that come out of the RSA Algorithm.</p> <p>I heard that a possibility would be to declare your variables as a double long, so...</p> <pre><code>long long decryptedCharacter; </code></pre> <p>but I'm not sure exactly how big of an integer that can store.</p> <hr> <p>Well for example, I try to compile and run the following program using dev C++:</p> <pre><code>#include iostream #include "bigint\BigIntegerLibrary.hh" using namespace std; int main() { BigInteger a = 65536; cout &lt;&lt; (a * a * a * a * a * a * a * a); return 0; } </code></pre> <p>then I get those errors.</p> <p>Derek, I thought that by including the <code>BigIntegerLibrary.hh</code> file, that the compiler would go through and compile all the necessary files that it will use.</p> <p>How should I try and compile the program above in order to resolve the linking errors?</p>
[ { "answer_id": 124345, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 2, "selected": false, "text": "#include <stdio.h>\n\nint main(void) {\n printf(\"%d\\n\", sizeof(long long));\n\n return 0;\n}\n" }, { "ans...
2008/09/23
[ "https://Stackoverflow.com/questions/124332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
124,336
<p>I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type will have additional functionality that the parent doesn't offer which is in its self not fundamentally sound. But is there some way to do this? Here is a code example to so I can better explain what I"m asking.</p> <pre><code>public class SomeBaseClass { public string GetBaseClassName {get;set;} public bool BooleanEvaluator {get;set;} } public class SomeDerivedClass : SomeBaseClass { public void Insert(SqlConnection connection) { //...random connection stuff cmd.Parameters["IsItTrue"].Value = this.BooleanEvalutar; //... } } public static void Main(object[] args) { SomeBaseClass baseClass = new SomeBaseClass(); SomeDerivedClass derClass = (SomeDerivedClass)baseClass; derClass.Insert(new sqlConnection()); } </code></pre> <p>I know this seems goofy but is there any way to accomplish something of this sort?</p>
[ { "answer_id": 124429, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 3, "selected": false, "text": "SomeBaseClass class = new SomeBaseClass();\nSomeDerivedClass derClass = (SomeDerivedClass)class; \n" }, { "answer_i...
2008/09/23
[ "https://Stackoverflow.com/questions/124336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13688/" ]
124,358
<p>Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the existing application?</p> <p>I defined the models, I defined controllers and views. They all work well.</p> <p>Now the boss comes asking for a Winforms client and I am hoping I can reuse the models and the controllers (provided I put them in different assemblies) and not reuse just the views (ASPX views).</p> <p>Can this be done? How?</p>
[ { "answer_id": 124452, "author": "zadam", "author_id": 410357, "author_profile": "https://Stackoverflow.com/users/410357", "pm_score": 4, "selected": true, "text": "public interface IRuntimeContext\n{\n void TransferTo(string destination);\n}\n" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1796/" ]
124,360
<p>I know there are several plugins that do asynchronous processing. Which one is the best one and why?</p> <p>The ones I know about are:</p> <ul> <li><a href="http://backgroundrb.rubyforge.org/" rel="noreferrer">BackgrounDRb</a></li> </ul>
[ { "answer_id": 125968, "author": "Olly", "author_id": 1174, "author_profile": "https://Stackoverflow.com/users/1174", "pm_score": 3, "selected": false, "text": "script/runner" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9594/" ]
124,374
<p>I need to recursively search directories and replace a string (say <a href="http://development:port/URI" rel="nofollow noreferrer">http://development:port/URI</a>) with another (say <a href="http://production:port/URI" rel="nofollow noreferrer">http://production:port/URI</a>) in all the files where ever it's found. Can anyone help?</p> <p>It would be much better if that script can print out the files that it modified and takes the search/replace patterns as input parameters.</p> <p>Regards.</p>
[ { "answer_id": 124404, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": true, "text": "find . -type f | xargs grep -l development | xargs perl -i.bak -p -e 's(http://development)(http://production)g'\n" }, { ...
2008/09/23
[ "https://Stackoverflow.com/questions/124374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1408/" ]
124,378
<p>I'm running my workstation on Server 2008 and a few servers in Hyper-V VM's on that server. I connect to my corporate LAN using VPN from the main OS (the host) but my VM's aren't seeing the servers in the corporate LAN. Internet and local access to my home network work fine. Each of the VMs has one virtual network adapter. </p> <p>What should I try to make it work?</p> <p>Maybe I need to provide more details, please ask if needed.</p> <p><strong>More details:</strong></p> <ul> <li>cannot start multiple VPN connections </li> <li>not using NAT through the host</li> <li>VM gets IP address from the home network router (DHCP)</li> </ul>
[ { "answer_id": 129541, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 2, "selected": false, "text": "route ADD 10.0.0.0 MASK 255.0.0.0 192.168.1.30\n" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21420/" ]
124,392
<p>I am calling a PHP-Script belonging to a MySQL/PHP web application using FF3. I run XAMPP on localhost. All I get is this:</p> <blockquote> <p>Connection Interrupted<br> The connection to the server was reset while the page was loading. The network link was interrupted while negotiating a connection. Please try again.</p> </blockquote>
[ { "answer_id": 6134271, "author": "DevByStarlight", "author_id": 735533, "author_profile": "https://Stackoverflow.com/users/735533", "pm_score": 3, "selected": false, "text": "Parent: child process exited with status 3221225477 -- Restarting" }, { "answer_id": 12046674, "auth...
2008/09/23
[ "https://Stackoverflow.com/questions/124392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
124,396
<p>Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back? Succinctly, does raising a Error on any callback or validation make it such that no change at all occurs in the database for that verb action?</p>
[ { "answer_id": 124489, "author": "Michael Deardeuff", "author_id": 4931, "author_profile": "https://Stackoverflow.com/users/4931", "pm_score": 1, "selected": false, "text": "Student.transaction do\n Course.transaction do\n course.enroll(student)\n student.units += course.units\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/124396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
124,405
<p>I am writing some code and trying to speed it up using SIMD intrinsics SSE2/3. My code is of such nature that I need to load some data into an XMM register and act on it many times. When I'm looking at the assembler code generated, it seems that GCC keeps flushing the data back to the memory, in order to reload something else in XMM0 and XMM1. I am compiling for x86-64 so I have 15 registers. Why is GCC using only two and what can I do to ask it to use more? Is there any way that I can "pin" some value in a register? I added the "register" keyword to my variable definition, but the generated assembly code is identical.</p>
[ { "answer_id": 72275425, "author": "Peter Cordes", "author_id": 224132, "author_profile": "https://Stackoverflow.com/users/224132", "pm_score": 0, "selected": false, "text": "int" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18308/" ]
124,411
<p>But here's an example:</p> <pre><code>Dim desiredType as Type if IsNumeric(desiredType) then ... </code></pre> <p><strong>EDIT:</strong> I only know the Type, not the Value as a string.</p> <p>Ok, so unfortunately I have to cycle through the TypeCode.</p> <p>But this is a nice way to do it:</p> <pre><code> if ((desiredType.IsArray)) return 0; switch (Type.GetTypeCode(desiredType)) { case 3: case 6: case 7: case 9: case 11: case 13: case 14: case 15: return 1; } ;return 0; </code></pre>
[ { "answer_id": 124443, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 5, "selected": false, "text": "Type.GetTypeCode()" }, { "answer_id": 124477, "author": "Jorge Ferreira", "author_id": 6508, "author_pr...
2008/09/23
[ "https://Stackoverflow.com/questions/124411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
124,417
<p>I want to write a query like this:</p> <pre><code>SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o </code></pre> <p>But this isn't how the <code>MAX</code> function works, right? It is an aggregate function so it expects a single parameter and then returns the MAX of all rows. </p> <p>Does anyone know how to do it my way?</p>
[ { "answer_id": 124441, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 7, "selected": false, "text": "SELECT\n o.OrderId,\n CASE WHEN o.NegotiatedPrice > o.SuggestedPrice THEN o.NegotiatedPrice \n ELSE o.Suggeste...
2008/09/23
[ "https://Stackoverflow.com/questions/124417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
124,453
<p>I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data layer, but since I can't predict how the entity objects are going to be used some of its collections are lazy loaded, or I should say fail to load once the session is closed.</p> <p>Why did they not design it so that it would automatically re-open the session, or have sessions always stay open?</p>
[ { "answer_id": 125021, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 2, "selected": false, "text": "lazy=false" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
124,455
<p>I've got a Lua program that seems to be slower than it ought to be. I suspect the issue is that I'm adding values to an associative array one at a time and the table has to allocate new memory each time. </p> <p>There did seem to be a table.setn function, but it fails under Lua 5.1.3:</p> <pre><code>stdin:1: 'setn' is obsolete stack traceback: [C]: in function 'setn' stdin:1: in main chunk [C]: ? </code></pre> <p>I gather from the Google searching I've done that this function was depreciated in Lua 5.1, but I can't find what (if anything) replaced the functionality.</p> <p>Do you know how to pre-size a table in Lua?</p> <p>Alternatively, is there some other way to avoid memory allocation when you add an object to a table?</p>
[ { "answer_id": 124536, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 3, "selected": false, "text": "void lua_createtable (lua_State *L, int narr, int nrec);\n" }, { "answer_id": 146902, "author": "Community", ...
2008/09/23
[ "https://Stackoverflow.com/questions/124455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
124,457
<p>I have limited experience with .net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to:</p> <p>"Register the following as a startup script:"</p> <pre><code>Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upperAbbrMonths) { this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames); } return Array.indexOf(this._upperAbbrMonths, this._toUpper(value)); }; </code></pre> <p>So how do I do this? Do I add the script to the bottom of my aspx file?</p>
[ { "answer_id": 124470, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 4, "selected": true, "text": "string str = @\"Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { \n if (!this._upperAbbrMonths) { \n ...
2008/09/23
[ "https://Stackoverflow.com/questions/124457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
124,462
<p>Is there a way in PHP to make asynchronous HTTP calls? I don't care about the response, I just want to do something like <code>file_get_contents()</code>, but not wait for the request to finish before executing the rest of my code. This would be super useful for setting off "events" of a sort in my application, or triggering long processes.</p> <p>Any ideas?</p>
[ { "answer_id": 124557, "author": "Internet Friend", "author_id": 18037, "author_profile": "https://Stackoverflow.com/users/18037", "pm_score": 5, "selected": false, "text": "wget" }, { "answer_id": 2258567, "author": "Christian Davรฉn", "author_id": 12534, "author_prof...
2008/09/23
[ "https://Stackoverflow.com/questions/124462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10680/" ]
124,492
<p>I need a short code snippet to get a directory listing from an HTTP server.</p> <p>Thanks</p>
[ { "answer_id": 124498, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "HtmlDocument doc = new HtmlDocument();\ndoc.Load(strURL);\nforeach(HtmlNode link in doc.DocumentElement.SelectNodes(\...
2008/09/23
[ "https://Stackoverflow.com/questions/124492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
124,585
<p>This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no class should have more than x fields" won't help. </p> <p>Moving on, the problem came to fruition when I forgot to check one of the fields for equality. Therefore, my equals method was incorrect. Then I thought to use reflection:</p> <pre><code>--code removed because it was too distracting-- </code></pre> <p>The purpose of this post isn't necessarily to refactor the code (this isn't even the code I am using), but instead to get input on whether or not this is a good idea. </p> <p><strong>Pros:</strong></p> <ul> <li>If a new field is added, it is automatically included<br> </li> <li>The method is much more terse than 30 if statements</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>If a new field is added, it is automatically included, sometimes this is undesirable</li> <li>Performance: This has to be slower, I don't feel the need to break out a profiler</li> <li>Whitelisting certain fields to ignore in the comparison is a little ugly<br></li> </ul> <p>Any thoughts?</p>
[ { "answer_id": 124598, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 5, "selected": true, "text": "equals()" }, { "answer_id": 124640, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https...
2008/09/23
[ "https://Stackoverflow.com/questions/124585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402777/" ]
124,604
<p>Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?</p>
[ { "answer_id": 4294670, "author": "user502515", "author_id": 502515, "author_profile": "https://Stackoverflow.com/users/502515", "pm_score": 2, "selected": false, "text": "s/whatever/somethingelse/e" } ]
2008/09/23
[ "https://Stackoverflow.com/questions/124604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
124,606
<p>I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like:</p> <pre> $sql = sqlf("SELECT * FROM Users WHERE name= :1 AND email= :2",'Big "John"','bj@example.com') ; </pre> <p>For various reasons, I cannot use prepared statements, but I would like to emulate them. The problem that I run into is with queries like</p> <pre> $sql = sqlf("SELECT * FROM Users WHERE id IN (:1)",array(1,2,3) ); </pre> <p>My code works, but it fails with empty arrays, e.g. the following throws a mysql error:</p> <pre> SELECT * FROM Users WHERE id IN (); </pre> <p>Does anyone have any suggestions? How should I translate and empty array into sql that can be injected into an IN clause? Substituting NULL will not work. </p>
[ { "answer_id": 124635, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 0, "selected": false, "text": "SELECT * FROM Users WHERE id IN ();\nSELECT * FROM Users WHERE a = 7 AND id IN ();\nSELECT * FROM Users WHERE id IN () O...
2008/09/23
[ "https://Stackoverflow.com/questions/124606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20512/" ]
124,615
<p>Lets say I have a class that stores user information complete with getters and setters, and it is populated with data from an XML file. How would I iterate over all of the instances of that class like you would do with java beans and tag libraries?</p>
[ { "answer_id": 124783, "author": "Ta01", "author_id": 7280, "author_profile": "https://Stackoverflow.com/users/7280", "pm_score": 0, "selected": false, "text": "List<YourClass> myObjects = SomeMagicMethodThatGetsAllInstancesOfThatClassAndAddsThemtoTheCollection();\nforeach (YourClass ins...
2008/09/23
[ "https://Stackoverflow.com/questions/124615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2066/" ]
124,630
<p>I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code:</p> <pre><code>public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new MemoryImageSource(width, height, pixels, 0, width); Toolkit tk = Toolkit.getDefaultToolkit(); return tk.createImage(mis); } </code></pre> <p><em>Is it possible to achieve the same result using classes from the ImageIO package(s) so I don't have to use the AWT Toolkit?</em></p> <p>Toolkit.getDefaultToolkit() does not seem to be 100% reliable and will sometimes throw an AWTError, whereas the ImageIO classes should always be available, which is why I'm interested in changing my method.</p>
[ { "answer_id": 124957, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 2, "selected": false, "text": "// Capture whole screen\nRectangle region = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());\nBufferedImage...
2008/09/24
[ "https://Stackoverflow.com/questions/124630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1119/" ]
124,638
<p>I found an article on getting active tcp/udp connections on a machine.</p> <p><a href="http://www.codeproject.com/KB/IP/iphlpapi.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/IP/iphlpapi.aspx</a></p> <p>My issue however is I need to be able to determine active connections remotely - to see if a particular port is running or listening without tampering with the machine.</p> <p>Is this possible?</p> <p>Doesn't seem like it natively, otherwise it could pose a security issue. The alternative would be to query a remoting service which could then make the necessary calls on the local machine.</p> <p>Any thoughts?</p>
[ { "answer_id": 124641, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 2, "selected": false, "text": "telnet google.com 80\n" } ]
2008/09/24
[ "https://Stackoverflow.com/questions/124638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]