qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
185,448
<p>Imagine in the Global.asax.cs file I had an instance class as a private field. Let's say like this:</p> <pre><code>private MyClass _myClass = new MyClass(); </code></pre> <p>And I had a static method on Global called GetMyClass() that gets the current HttpApplication and returns that instance.</p> <pre><code>publ...
[ { "answer_id": 185670, "author": "Kevin Dostalek", "author_id": 22732, "author_profile": "https://Stackoverflow.com/users/22732", "pm_score": 2, "selected": false, "text": "public SomeClassType SomeProperty\n{\n get\n {\n if (HttpContext.Current.Cache[\"SomeKey\"] == null)\n...
2008/10/09
[ "https://Stackoverflow.com/questions/185448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14642/" ]
185,451
<p>What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?</p>
[ { "answer_id": 169969, "author": "Alex B", "author_id": 23643, "author_profile": "https://Stackoverflow.com/users/23643", "pm_score": 8, "selected": false, "text": "flock(1) #!/bin/bash\n\n(\n # Wait for lock on /var/lock/.myscript.exclusivelock (fd 200) for 10 seconds\n flock -x -w 10...
2008/10/09
[ "https://Stackoverflow.com/questions/185451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
185,461
<p>I would like MATLAB to tell me if I have an input file (.m file) that contains some variables with their numbers (i.e., <code>a = 5</code>, <code>b = 6</code>, <code>c = 7</code>) so that I can then use that .m file in another program (main .m file) that uses these variables to calculate <code>S = a + b + c</code>. ...
[ { "answer_id": 185469, "author": "Scottie T", "author_id": 6688, "author_profile": "https://Stackoverflow.com/users/6688", "pm_score": 2, "selected": false, "text": "% File: inputs.m\na = 5;\nb = 6;\nc = 7;\n % File: main.m\ninputs;\nS = a + b + c;\n" }, { "answer_id": 185660, ...
2008/10/09
[ "https://Stackoverflow.com/questions/185461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
185,463
<p>I have a view that supports landscape and portrait viewing, with the controls all moving around when you switch from one to the other. I'm currently doing this by setting the .center of each one of my controls when the user rotates the phone. The problem is that this is tedious, and requires a lot of code, and seems...
[ { "answer_id": 401061, "author": "Ed Marty", "author_id": 36007, "author_profile": "https://Stackoverflow.com/users/36007", "pm_score": 1, "selected": false, "text": "UIView UILabel UIView ViewDidLoad CGRect" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044/" ]
185,474
<p>I have a connection string being passed to a function, and I need to create a DbConnection based object (i.e. SQLConnection, OracleConnection, OLEDbConnection etc) based on this string.</p> <p>Is there any inbuilt functionality to do this, or any 3rd party libraries to assist. We are not necessarily building this ...
[ { "answer_id": 185482, "author": "Eric Tuttleman", "author_id": 25677, "author_profile": "https://Stackoverflow.com/users/25677", "pm_score": 4, "selected": false, "text": "DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory(myDriverClass);\nDbConnection dbConnection = d...
2008/10/09
[ "https://Stackoverflow.com/questions/185474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
185,483
<p>How do I prevent my users from accessing directly pages meant for ajax calls only?</p> <p>Passing a key during ajax call seems like a solution, whereas access without the key will not be processed. But it is also easy to fabricate the key, no? Curse of View Source...</p> <p>p/s: Using Apache as webserver.</p> <p>...
[ { "answer_id": 185562, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 6, "selected": true, "text": " if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {\n //Request identified as ajax request\n }\n" }, ...
2008/10/09
[ "https://Stackoverflow.com/questions/185483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15345/" ]
185,487
<p>Assuming I have three tables : TableA (key, value) TableB (key, value) TableC (key, value)</p> <p>and I want to return a value for all keys. If the key exists in TableC return that value else if the key exists in B return that value else return the value from table A</p> <p>The best I have come up with so far is</...
[ { "answer_id": 185509, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 0, "selected": false, "text": "SELECT key, value, 2 AS priority\nFROM TableA\nUNION\nSELECT key, value, 1 AS priority\nFROM TableB\nUNION\nSELEC...
2008/10/09
[ "https://Stackoverflow.com/questions/185487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6819/" ]
185,510
<p>Is it possible to do something like this?</p> <pre><code>var pattern = /some regex segment/ + /* comment here */ /another segment/; </code></pre> <p>Or do I have to use new <code>RegExp()</code> syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise.</p...
[ { "answer_id": 185529, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 9, "selected": true, "text": "var segment_part = \"some bit of the regexp\";\nvar pattern = new RegExp(\"some regex segment\" + /*comment here */\n ...
2008/10/09
[ "https://Stackoverflow.com/questions/185510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17964/" ]
185,520
<p>I have months stored in SQL Server as 1,2,3,4,...12. I would like to display them as January,February etc. Is there a function in SQL Server like MonthName(1) = January? I am trying to avoid a CASE statement, if possible.</p>
[ { "answer_id": 185548, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 8, "selected": true, "text": "SELECT DATENAME(month, DATEADD(month, @mydate-1, CAST('2008-01-01' AS datetime)))\n" }, { "answer_id": 185...
2008/10/09
[ "https://Stackoverflow.com/questions/185520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
185,521
<p>I run into similar codes like this all the time in aspx pages:</p> <pre><code>&lt;asp:CheckBox Runat="server" ID="myid" Checked='&lt;%# DataBinder.Eval(Container.DataItem, "column").Equals(1) %&gt;'&gt; </code></pre> <p>I was wondering what other objects I have access to inside of that &lt;%# %> tag. How come Data...
[ { "answer_id": 185612, "author": "Fung", "author_id": 8280, "author_profile": "https://Stackoverflow.com/users/8280", "pm_score": 4, "selected": true, "text": "<%#DirectCast(Container.DataItem, DataRow)(\"some_column\")%>\n <%#((DataRow)Container.DataItem)[\"some_column\"].ToString()%>\n...
2008/10/09
[ "https://Stackoverflow.com/questions/185521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10088/" ]
185,524
<p>I'm trying to build the example described at <a href="http://support.microsoft.com/kb/178749/EN-US/" rel="nofollow noreferrer">http://support.microsoft.com/kb/178749/EN-US/</a> in order to build an application that programatically accesses Excel using Automation. I have Visual C++ 2005/Visual Studio 2005. Some of...
[ { "answer_id": 186009, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 1, "selected": false, "text": ".tlh .tlh .tli CComPtr<>" }, { "answer_id": 186029, "author": "jmatthias", "author_id": 2768, "author_pro...
2008/10/09
[ "https://Stackoverflow.com/questions/185524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965047/" ]
185,533
<p>I've been looking at the <a href="http://www.getdropbox.com/install?os=mac" rel="noreferrer">DropBox</a> Mac client and I'm currently researching implementing a similar interface for a different service. </p> <p>How exactly do they interface with finder like this? I highly doubt these objects represented in the fo...
[ { "answer_id": 7158576, "author": "Wim Leers", "author_id": 80305, "author_profile": "https://Stackoverflow.com/users/80305", "pm_score": 2, "selected": false, "text": "inotify FSEvents django-storages" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3415/" ]
185,536
<p>By default it seems that objects are drawn front to back. I am drawing a 2-D UI object and would like to create it back to front. For example I could create a white square first then create a slightly smaller black square on top of it thus creating a black pane with a white border. <a href="http://gpwiki.org/index...
[ { "answer_id": 189915, "author": "AlanKley", "author_id": 8761, "author_profile": "https://Stackoverflow.com/users/8761", "pm_score": 6, "selected": true, "text": "glDepthFunc(GL_NEVER); // Ignore depth values (Z) to cause drawing bottom to top\n glEnable (GL_DEPTH_TEST); // Enabl...
2008/10/09
[ "https://Stackoverflow.com/questions/185536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761/" ]
185,559
<p>I would like to remove the domain/computer information from a login id in C#. So, I would like to make either "Domain\me" or "Domain\me" just "me". I could always check for the existence of either, and use that as the index to start the substring...but I am looking for something more elegant and compact.</p> <p>W...
[ { "answer_id": 185572, "author": "BoltBait", "author_id": 20848, "author_profile": "https://Stackoverflow.com/users/20848", "pm_score": 2, "selected": false, "text": " string[] domainuser;\n string Auth_User = Request.ServerVariables[\"AUTH_USER\"].ToString().ToLower(); \n domai...
2008/10/09
[ "https://Stackoverflow.com/questions/185559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18449/" ]
185,569
<p>This is an age-old question where given a table with attributes 'type', 'variety' and 'price', that you fetch the record with the minimum price for each type there is.</p> <p>In SQL, we can do <a href="http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/" rel="noreferrer">this<...
[ { "answer_id": 185647, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 4, "selected": false, "text": "Table.minimum(:price, :group => :type)\n" }, { "answer_id": 186219, "author": "François Beausoleil", "author_...
2008/10/09
[ "https://Stackoverflow.com/questions/185569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
185,573
<p>I couldn't really find this in Rails documentation but it seems like <strong>'mattr_accessor'</strong> is the <strong>Module</strong> corollary for <strong>'attr_accessor'</strong> (getter &amp; setter) in a normal Ruby <strong>class</strong>.</p> <p>Eg. in a class</p> <pre><code>class User attr_accessor :name ...
[ { "answer_id": 185632, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 9, "selected": true, "text": "mattr_accessor cattr_accessor reader _writer attr_accessor cattr/mattr_accessor module Config\n mattr_accessor :hostname\n m...
2008/10/09
[ "https://Stackoverflow.com/questions/185573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6048/" ]
185,575
<p>In bash the ampersand (&amp;) can be used to run a command in the background and return interactive control to the user before the command has finished running. Is there an equivalent method of doing this in Powershell?</p> <p>Example of usage in bash:</p> <pre><code> sleep 30 &amp; </code></pre>
[ { "answer_id": 6459716, "author": "Dustin Getz", "author_id": 20003, "author_profile": "https://Stackoverflow.com/users/20003", "pm_score": 5, "selected": false, "text": "ps2> start-job {start-sleep 20}\n PS> notepad $profile #edit init script -- added these lines\nfunction beep { write-...
2008/10/09
[ "https://Stackoverflow.com/questions/185575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5769/" ]
185,584
<p>Does there exist a parser that generates an AST/parse tree at runtime? Kind of like a library that would accept a string of EBNF grammar or something analogous and spit out a data structure? </p> <ul> <li>I'm aware of antlr, jlex and their ilk. They generate source code which could do this. (like to skip the compil...
[ { "answer_id": 185662, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "{syntax: while (condition) do code}\nwhile (condition, code) => // actual execution\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23648/" ]
185,594
<p>What data structure does the following declaration specify?</p> <pre><code> List&lt;ArrayList&gt;[] myArray; </code></pre> <p>I think it should declare an array where each element is a <code>List</code> (e.g., a <code>LinkedList</code> or an <code>ArrayList</code>) and require that each <code>List</code> contain <...
[ { "answer_id": 185619, "author": "Mark", "author_id": 26310, "author_profile": "https://Stackoverflow.com/users/26310", "pm_score": 3, "selected": false, "text": "List<List<ArrayList>> someListArray;\n" }, { "answer_id": 185627, "author": "Draemon", "author_id": 26334, ...
2008/10/09
[ "https://Stackoverflow.com/questions/185594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19685/" ]
185,606
<p>I wonder if this would be doable ? To insert an array into one field in the database.</p> <p>For instance I have a title, I want to have that title with only one id, but it's going to be bilingually used on the website.</p> <p>It feels a bit unnecessary to make another table to have their global ids and then anoth...
[ { "answer_id": 185625, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 5, "selected": true, "text": "$title = serialize($array);\n $title = unserialize($mysql_data);\n $title = base64_encode(serialize($array) );\n$title = unseria...
2008/10/09
[ "https://Stackoverflow.com/questions/185606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671/" ]
185,621
<p>Has anybody been successful in integrating the Enterprise Library v4.0 with SharePoint WSS 3.0? I created a very simple .ASPX page. It's only purpose will to be to connect to an Oracle database and display some values in a DropDownList. But right now, all it does is displays Hello World. I've added the necessary...
[ { "answer_id": 189353, "author": "Cruiser", "author_id": 16971, "author_profile": "https://Stackoverflow.com/users/16971", "pm_score": 1, "selected": false, "text": "<SharePoint><SafeMode> <system.web><compilation> <system.web><customErrors>" }, { "answer_id": 191055, "author...
2008/10/09
[ "https://Stackoverflow.com/questions/185621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1082/" ]
185,624
<p>I have a function that is declared and defined in a header file. This is a problem all by itself. When that function is not inlined, every translation unit that uses that header gets a copy of the function, and when they are linked together there are duplicated. I "fixed" that by making the function inline, but I'm ...
[ { "answer_id": 189162, "author": "paercebal", "author_id": 14089, "author_profile": "https://Stackoverflow.com/users/14089", "pm_score": 8, "selected": true, "text": "void doSomething()\n{\n static int value ;\n}\n inline void doSomething()\n{\n static int value ;\n}\n static void do...
2008/10/09
[ "https://Stackoverflow.com/questions/185624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13562/" ]
185,652
<p>I have a UIImageView and the objective is to scale it down proportionally by giving it either a height or width. </p> <pre><code>UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3092/2915896504_a88b69c9de.jpg"]]]; UIImageView *imageVi...
[ { "answer_id": 185788, "author": "user26359", "author_id": 26359, "author_profile": "https://Stackoverflow.com/users/26359", "pm_score": 0, "selected": false, "text": "image.center = [[imageView window] center];\n" }, { "answer_id": 185911, "author": "Chris Lundie", "auth...
2008/10/09
[ "https://Stackoverflow.com/questions/185652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
185,661
<p>I'd like to know if Flash/AS3 has any nice way to convert an AS3 'Date' object to/from rfc-850 timestamp format (as used by HTTP date and last-modified).</p> <p>This question is very similar to <a href="https://stackoverflow.com/questions/17017/how-do-i-parse-and-convert-datetimes-to-the-rfc-3339-date-time-format">...
[ { "answer_id": 186080, "author": "aaaidan", "author_id": 26331, "author_profile": "https://Stackoverflow.com/users/26331", "pm_score": 3, "selected": true, "text": "Date Date Date() timezone Date /**\n * Converts an RFC string to a Date object.\n */\nfunction fromRFC802(date:String):Date...
2008/10/09
[ "https://Stackoverflow.com/questions/185661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26331/" ]
185,664
<p>I'm trying to create a user control that allows users to make something like the following:</p> <pre><code> &lt;uc1:MyControl id="controlThing" runat="server"&gt; &lt;uc1:BoundColumn id="column1" Column="Name" runat="server" /&gt; &lt;uc1:CheckBoxBoundColumn id="column2" Column="Selector" runat="server" /...
[ { "answer_id": 185687, "author": "nyxtom", "author_id": 19753, "author_profile": "https://Stackoverflow.com/users/19753", "pm_score": 0, "selected": false, "text": "<mycontrol id=\"control1\" runat=\"server\">\n <templateitem id=\"bleh1\" runat=\"server\" />\n <templateitem id=\"bl...
2008/10/09
[ "https://Stackoverflow.com/questions/185664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19753/" ]
185,680
<p>How do I define nested class in Java Script. </p> <p>Here is the code snippet I have:</p> <pre><code>objA = new TestA(); function TestB () { this.testPrint = function () { print ( " Inside testPrint " ); } } function TestA () { var myObjB = new TestB(); } </code></pre> <p>Now I am trying to acces...
[ { "answer_id": 185695, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 2, "selected": false, "text": "var objA = {\n myObjB: {\n testPrint: function(){\n print(\"Inside test print\");\n }\n }\n...
2008/10/09
[ "https://Stackoverflow.com/questions/185680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
185,681
<p>How to parse the DOM and determine what row is selected in an ASP.NET <code>ListView</code>? I'm able to interact with the DOM via the <code>HtmlElement</code> in Silverlight, but I have not been able to locate a property indicating the row is selected.</p> <p>For reference, this managed method works fine for an ASP...
[ { "answer_id": 185897, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 0, "selected": false, "text": "HtmlElement elem = HtmlPage.Document.GetElementById(\"testSelect\");\nint index = Convert.ToInt32(elem.GetProperty(\"select...
2008/10/09
[ "https://Stackoverflow.com/questions/185681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21410/" ]
185,690
<p>I'm using the <a href="http://www.componentace.com/zlib_.NET.htm" rel="noreferrer">zlib.NET</a> library to try and inflate files that are compressed by zlib (on a Linux box, perhaps). Here's what I'm doing:</p> <pre><code>zlib.ZInputStream zinput = new zlib.ZInputStream(File.Open(path, FileMode.Open, FileAcces...
[ { "answer_id": 185736, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "int Read(buffer, offset, length) int Read() length" }, { "answer_id": 185924, "author": "Brendan Kowitz", ...
2008/10/09
[ "https://Stackoverflow.com/questions/185690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
185,697
<p>Input: A positive integer K and a big text. The text can actually be viewed as word sequence. So we don't have to worry about how to break down it into word sequence.<br> Output: The most frequent K words in the text.</p> <p>My thinking is like this. </p> <ol> <li><p>use a Hash table to record all words' frequency...
[ { "answer_id": 19460906, "author": "Shawn", "author_id": 165835, "author_profile": "https://Stackoverflow.com/users/165835", "pm_score": 0, "selected": false, "text": "List<Set<String>> Map<String, Integer> TreeMap<Integer, Set<String>> public class WordFrequencyCounter {\n private st...
2008/10/09
[ "https://Stackoverflow.com/questions/185697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
185,698
<p>I have a directory with several subdirectories with files.<br> How can I copy all files in the subdirectories to a new location?<br></p> <p><strong>Edit:</strong> I do not want to copy the directories, just the files...</p> <p>As this is still on XP, I chose the below solution:</p> <pre><code> for /D %S IN ("src\...
[ { "answer_id": 185703, "author": "Eric Tuttleman", "author_id": 25677, "author_profile": "https://Stackoverflow.com/users/25677", "pm_score": 2, "selected": false, "text": "XCOPY /E SrcDir\\*.* DestDir\\\n FOR /D %s IN (SrcDir\\*) DO @XCOPY /E %s DestDir\\%~ns\\\n" }, { "answer_i...
2008/10/09
[ "https://Stackoverflow.com/questions/185698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
185,747
<p>I am trying to convert an <code>int</code> into three <code>bytes</code> representing that <code>int</code> (big endian).</p> <p>I'm sure it has something to do with bit-wise and and bit shifting. But I have no idea how to go about doing it.</p> <p>For example:</p> <pre><code>int myInt; // some code byte b1, b...
[ { "answer_id": 185763, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": " byte b1 = (myInt & 0xff);\n myInt >>= 8;\n byte b2 = (myInt & 0xff);\n myInt >>= 8;\n byte b3 = (myInt & 0xf...
2008/10/09
[ "https://Stackoverflow.com/questions/185747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
185,778
<p>I am using trigger_error to "throw" errors in a custom class. My problem is that trigger_error prints out the line number where trigger_error was called. For example, given the following code:</p> <pre><code>01 &lt;?php 02 class Test { 03 function doAction() { 04 $this-&gt;doSubA...
[ { "answer_id": 185817, "author": "Rob Howard", "author_id": 3528, "author_profile": "https://Stackoverflow.com/users/3528", "pm_score": 0, "selected": false, "text": "__LINE__ test(__LINE__)" }, { "answer_id": 1145375, "author": "Andrew Moore", "author_id": 26210, "au...
2008/10/09
[ "https://Stackoverflow.com/questions/185778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26210/" ]
185,780
<p>I'm adding repeating events to a Cocoa app I'm working on. I have repeat every day and week fine because I can define these mathematically (3600*24*7 = 1 week). I use the following code to modify the date:</p> <pre><code>[NSDate dateWithTimeIntervalSinceNow:(3600*24*7*(weeks))] </code></pre> <p>I know how many mon...
[ { "answer_id": 186104, "author": "mmalc", "author_id": 23233, "author_profile": "https://Stackoverflow.com/users/23233", "pm_score": 6, "selected": true, "text": "NSDate *today = [NSDate date];\n\nNSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]...
2008/10/09
[ "https://Stackoverflow.com/questions/185780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13069/" ]
185,781
<p>I read an interesting DailyWTF post today, <a href="http://thedailywtf.com/Articles/Out-of-All-the-Possible-Answers.aspx" rel="noreferrer">"Out of All The Possible Answers..."</a> and it interested me enough to dig up the original <a href="http://forums.thedailywtf.com/forums/t/10030.aspx" rel="noreferrer">forum pos...
[ { "answer_id": 185920, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 5, "selected": true, "text": "def RangeLCM(first, last):\n factors = range(first, last+1)\n for i in range(0, len(factors)):\n if factors[...
2008/10/09
[ "https://Stackoverflow.com/questions/185781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20840/" ]
185,804
<p>I created an app for a small business. Some of the employees in the office can not see the form correctly. The reason is they have their DPI setting set to above 96dpi. Does anybody know of a way to control this?</p> <p>For all of you who have experience with winforms apps, how do you control your form layout so ...
[ { "answer_id": 202172, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 6, "selected": false, "text": "AutoScaleMode ScaleMode.Dpi CurrentDpiSetting / 96 Form.Scale() ScaleControl() ScaleControl ScaleControl() public class M...
2008/10/09
[ "https://Stackoverflow.com/questions/185804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21325/" ]
185,836
<p>Does anyone know if it possible to define the equivalent of a "java custom class loader" in .NET?</p> <p><strong>To give a little background:</strong></p> <p>I am in the process of developing a new programming language that targets the CLR, called "Liberty". One of the features of the language is its ability to de...
[ { "answer_id": 185856, "author": "Scott Wisniewski", "author_id": 1737192, "author_profile": "https://Stackoverflow.com/users/1737192", "pm_score": 7, "selected": true, "text": "System.Reflection.Emit System.AppDomain Main System.AppDomain TypeResolve using System;\nusing System.Collecti...
2008/10/09
[ "https://Stackoverflow.com/questions/185836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737192/" ]
185,844
<p>What is the best way to initialize a private, static data member in C++? I tried this in my header file, but it gives me weird linker errors:</p> <pre><code>class foo { private: static int i; }; int foo::i = 0; </code></pre> <p>I'm guessing this is because I can't initialize a private member from out...
[ { "answer_id": 185848, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 10, "selected": true, "text": "class foo\n{\n private:\n static int i;\n};\n int foo::i = 0;\n static int i bool char char8_t char16_t char...
2008/10/09
[ "https://Stackoverflow.com/questions/185844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
185,862
<p>I am starting my first independent for profit venture. I am having a hard time deciding what language to use. I want to write my app in Perl, but I don't think it will be simple enough to compile. If I don't write it in Perl I will write it in C++.</p> <p>The application will have many features, including <a href="h...
[ { "answer_id": 187707, "author": "Axeman", "author_id": 11289, "author_profile": "https://Stackoverflow.com/users/11289", "pm_score": 1, "selected": false, "text": "map" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21204/" ]
185,883
<p>Using the Qt Visual studio integration, adding a new Qt class adds two separate moc.exe generated files - one for debug and one for release (and one for any other configuration currently existing). Yet the two eventual generated files seem to be identical.</p> <p>On the other hand when adding a UI class, the uic.ex...
[ { "answer_id": 185925, "author": "David Dibben", "author_id": 5022, "author_profile": "https://Stackoverflow.com/users/5022", "pm_score": 3, "selected": false, "text": "class Test : public QObject\n{\n Q_OBJECT\npublic:\n Test(); \npublic slots:\n\n#ifndef DEBUG\n ...
2008/10/09
[ "https://Stackoverflow.com/questions/185883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
185,893
<p>I have a production server running with the following flag: -<strong>XX:+HeapDumpOnOutOfMemoryError</strong></p> <p>Last night it generated a java-38942.hprof file when our server encountered a heap error. It turns out that the developers of the system knew of the flag but no way to get any useful information from ...
[ { "answer_id": 185926, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 6, "selected": false, "text": "jhat -port 7401 -J-Xmx4G dump.hprof jhat" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
185,899
<p>Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one.</p>
[ { "answer_id": 1531795, "author": "Adam Matan", "author_id": 51197, "author_profile": "https://Stackoverflow.com/users/51197", "pm_score": 9, "selected": false, "text": "$ printf Cat > foo\n$ printf Dog > bar\n $ ln foo foo-hard\n$ ln -s bar bar-soft\n ls -lrS\nlrwxr-xr-x 1 user staff...
2008/10/09
[ "https://Stackoverflow.com/questions/185899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
185,934
<p>It appears that in PHP objects are passed by reference. Even assignment operators do not appear to be creating a copy of the Object.</p> <p>Here's a simple, contrived proof:</p> <pre><code>&lt;?php class A { public $b; } function set_b($obj) { $obj-&gt;b = "after"; } $a = new A(); $a-&gt;b = "before"; $c =...
[ { "answer_id": 185938, "author": "Leo", "author_id": 20689, "author_profile": "https://Stackoverflow.com/users/20689", "pm_score": 4, "selected": false, "text": "$a = clone $b;\n" }, { "answer_id": 185939, "author": "Eran Galperin", "author_id": 10585, "author_profile...
2008/10/09
[ "https://Stackoverflow.com/questions/185934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
185,936
<p>How can I delete the contents of a local folder in Python?</p> <p>The current project is for Windows, but I would like to see *nix also.</p>
[ { "answer_id": 185941, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 10, "selected": true, "text": "import os, shutil\nfolder = '/path/to/folder'\nfor filename in os.listdir(folder):\n file_path = os.path.join(fol...
2008/10/09
[ "https://Stackoverflow.com/questions/185936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
185,937
<p>I ran into an interesting (and very frustrating) issue with the <code>equals()</code> method today which caused what I thought to be a well tested class to crash and cause a bug that took me a very long time to track down. </p> <p>Just for completeness, I wasn't using an IDE or debugger - just good old fashioned te...
[ { "answer_id": 185942, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 9, "selected": true, "text": "equals() Object public boolean equals(Object other);\n Object public boolean equals(Book other) equals() ArrayList equals() co...
2008/10/09
[ "https://Stackoverflow.com/questions/185937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10583/" ]
185,947
<p>As a programming exercise, I've written a Ruby snippet that creates a class, instantiates two objects from that class, monkeypatches one object, and relies on method_missing to monkeypatch the other one.</p> <p>Here's the deal. This works as intended:</p> <pre><code>class Monkey def chatter puts "I am a ch...
[ { "answer_id": 185969, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 8, "selected": true, "text": "define_method define_method method_missing :define_method :screech define_method def method_missing(m)\n puts \"No #{m}, so...
2008/10/09
[ "https://Stackoverflow.com/questions/185947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21493/" ]
185,952
<p>I know this can be done in IE by creating an ActiveX object, but how do I do it in FF. The navigator.plugins['Adobe Acrobat'] object lets me know if it's installed or not, but it doesn't contain the version number. Any ideas?</p>
[ { "answer_id": 186312, "author": "Allen Pike", "author_id": 26398, "author_profile": "https://Stackoverflow.com/users/26398", "pm_score": 3, "selected": false, "text": "navigator.plugins[n].name n \"Adobe PDF Plug-In for Firefox and Netscape\"" }, { "answer_id": 277084, "auth...
2008/10/09
[ "https://Stackoverflow.com/questions/185952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16319/" ]
185,965
<p>What is the best way to create a custom title for pages in a Rails app without using a plug-in?</p>
[ { "answer_id": 185973, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 4, "selected": false, "text": "content_for" }, { "answer_id": 185978, "author": "Alan", "author_id": 17205, "author_profile": "https://S...
2008/10/09
[ "https://Stackoverflow.com/questions/185965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
185,966
<pre><code>&lt;div id="myDiv"&gt; &lt;a&gt;...&lt;/a&gt; &lt;a&gt;...&lt;/a&gt; &lt;a&gt;...&lt;/a&gt; &lt;a&gt;...&lt;/a&gt; &lt;a&gt;...&lt;/a&gt; &lt;a&gt;...&lt;/a&gt; &lt;/div&gt; </code></pre> <p>If you wanted to select the 2nd, 3rd and 4th <code>a</code> tags in the above example, ...
[ { "answer_id": 186018, "author": "Alexander Prokofyev", "author_id": 11256, "author_profile": "https://Stackoverflow.com/users/11256", "pm_score": 8, "selected": true, "text": "$(\"#myDiv a\").slice(1, 4)\n" }, { "answer_id": 186034, "author": "paxdiablo", "author_id": 14...
2008/10/09
[ "https://Stackoverflow.com/questions/185966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
185,967
<p><em>Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost any database which has a JDBC driver that can detect foreign-key associations.</em> </p> <hr> <p>Querying PostgreSQL data dictionary for foreign-keys and relationship between tables is very straightforward, but how c...
[ { "answer_id": 21501326, "author": "Joe Pineda", "author_id": 21258, "author_profile": "https://Stackoverflow.com/users/21258", "pm_score": 2, "selected": false, "text": "SELECT '\"' || Source.TABLE_NAME || '\" -> \"' \n || Destiny.TABLE_NAME || '\";' AS For_GraphViz\nFROM dba_...
2008/10/09
[ "https://Stackoverflow.com/questions/185967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/861/" ]
185,972
<p>In javascript, we can do:</p> <pre><code>["a string", 10, {x : 1}, function() {}].push("another value"); </code></pre> <p>What is the Scala equivalent?</p>
[ { "answer_id": 188235, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 6, "selected": true, "text": "List Vector Vector(\"a string\", 10, Map(\"x\" -> 1), ()=>()) + \"another value\"\n Vector[Any] Array(1, 2, 3, 4) ...
2008/10/09
[ "https://Stackoverflow.com/questions/185972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20689/" ]
185,983
<p>My friend accidentally bought a laptop with Windows Vista Home Basic Edition. He figured out how to install IIS on it, but it doesn't seem to have either the management console or the admin tools. Is there any way for him to configure a site or import an IIS 6 config file?</p> <p>EDIT: "Windows Vista Home Edition" ...
[ { "answer_id": 186163, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 0, "selected": false, "text": "%SystemRoot%\\system32\\inetsrv\\iis.msc iis.msc" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/185983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682/" ]
186,004
<p>Specifically, I want to listen to when programs are run and record information such as: timestamp, executable, windows name and user.</p>
[ { "answer_id": 186149, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 1, "selected": false, "text": "Select * from Win32_Process Win32_Process Const NORMAL_PRIORITY = 32\nConst LOW_PRIORITY = 64\nConst REALTIME_PRIORITY = 128...
2008/10/09
[ "https://Stackoverflow.com/questions/186004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24416/" ]
186,015
<p>I have had to do this several times, usually when trying to find in what files a variable or a function is used.</p> <p>I remember using xargs with grep in the past to do this, but I am wondering if there are any easier ways.</p>
[ { "answer_id": 186020, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 6, "selected": true, "text": "grep -r REGEX .\n ." }, { "answer_id": 186043, "author": "Darren Greaves", "author_id": 151, "author_prof...
2008/10/09
[ "https://Stackoverflow.com/questions/186015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25910/" ]
186,024
<pre><code>(function() { //codehere } )(); </code></pre> <p>What is special about this kind of syntax? What does ()(); imply?</p>
[ { "answer_id": 186030, "author": "Geoff", "author_id": 10427, "author_profile": "https://Stackoverflow.com/users/10427", "pm_score": 5, "selected": false, "text": "function name (){...}\nname();\n" }, { "answer_id": 186186, "author": "artificialidiot", "author_id": 7988, ...
2008/10/09
[ "https://Stackoverflow.com/questions/186024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21572/" ]
186,035
<p>I have a simple "accordion" type page containing a list of H3 headers and DIV content boxes (each H3 is followed by a DIV). On this page I start with all DIVs hidden. When a H3 is clicked the DIV directly below (after) is revealed with jQuery's <a href="http://jquery.com/api/#slideDown" rel="nofollow noreferrer">"...
[ { "answer_id": 186036, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 0, "selected": false, "text": "$('div#accordion> div').addClass('hideme');\n .hideme { display: none; }\n div.hideme { display: block; }\n <script type...
2008/10/09
[ "https://Stackoverflow.com/questions/186035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
186,037
<p>Is there any way to validate the width and height of image when uploaded? using javascript of server side ? like jsp, aspx etc?</p>
[ { "answer_id": 186067, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "getHeight getWidth BufferedImage" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25368/" ]
186,044
<p>I was developing a web page, where I was laying out a board for a Chess-like game, along with a couple of piece trays. It's all done using HTML (with jQuery for dynamic updating as the game is played). Somewhere I'd got the notion that using absolute positioning of elements within a page was considered a bad practic...
[ { "answer_id": 186058, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 8, "selected": true, "text": "<div id=\"parentDIV\" style=\"position:relative\">\n <div id=\"childDIV\" style=\"position:absolute;left:20px;top:20px;\">\n ...
2008/10/09
[ "https://Stackoverflow.com/questions/186044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2193/" ]
186,062
<p>Can I create a Controller that simply returns an image asset?</p> <p>I would like to route this logic through a controller, whenever a URL such as the following is requested:</p> <pre><code>www.mywebsite.com/resource/image/topbanner </code></pre> <p>The controller will look up <code>topbanner.png</code> and send ...
[ { "answer_id": 186133, "author": "Ian Suttle", "author_id": 19421, "author_profile": "https://Stackoverflow.com/users/19421", "pm_score": 3, "selected": false, "text": "string pathToFile = @\"C:\\Documents and Settings\\some_path.jpg\";\nbyte[] imageData = File.ReadAllBytes(pathToFile);\...
2008/10/09
[ "https://Stackoverflow.com/questions/186062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23341/" ]
186,071
<p>I've been profiling some queries in an application I'm working on, and I came across a query that was retrieving more rows than necessary, the result set being trimmed down in the application code.</p> <p>Changing a LEFT JOIN to an INNER JOIN trimmed the result set to just what was needed, and presumably would also...
[ { "answer_id": 186519, "author": "mike", "author_id": 19217, "author_profile": "https://Stackoverflow.com/users/19217", "pm_score": -1, "selected": false, "text": "SELECT SQL_NO_CACHE `contacts`.*, ...\n ANALYZE TABLE t1, t2;\nOPTIMIZE TABLE t1, t2;\n" }, { "answer_id": 188517, ...
2008/10/09
[ "https://Stackoverflow.com/questions/186071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10585/" ]
186,077
<p>I'd like to create a sparse file such that all-zero blocks don't take up actual disk space until I write data to them. Is it possible?</p>
[ { "answer_id": 193015, "author": "titaniumdecoy", "author_id": 18091, "author_profile": "https://Stackoverflow.com/users/18091", "pm_score": 4, "selected": false, "text": "#include <stdio.h>\n#include <string.h>\n#include <fcntl.h>\n#include <unistd.h>\n\nvoid create_file_with_hole(void)...
2008/10/09
[ "https://Stackoverflow.com/questions/186077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10184/" ]
186,082
<p>In my webapplication (C#, .Net 3.5), made up of a <em>core</em> class library (containing the business logic, data layer and a couple of utility classes), a windows service project, a webservice project and the website project, I have a couple of static classes in the <em>core</em> library used by all other projects...
[ { "answer_id": 195763, "author": "Cem Catikkas", "author_id": 3087, "author_profile": "https://Stackoverflow.com/users/3087", "pm_score": 0, "selected": false, "text": "public class Log\n{\n public static void debug(Object o, String message)\n {\n System.out.println(o + \" [...
2008/10/09
[ "https://Stackoverflow.com/questions/186082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16440/" ]
186,084
<p>Just this - How do you add a timer to a C# console application? It would be great if you could supply some example coding.</p>
[ { "answer_id": 186086, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 6, "selected": false, "text": "using System; \nusing System.Threading; \npublic static class Program \n{ \n public static void Main() \n { \n Conso...
2008/10/09
[ "https://Stackoverflow.com/questions/186084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
186,094
<p>I'm setting up a simple SQLite database to hold sensor readings. The tables will look something like this:</p> <pre><code>sensors - id (pk) - name - description - units sensor_readings - id (pk) - sensor_id (fk to sensors) - value (actual sensor value stored here) - time (date/time the sensor...
[ { "answer_id": 186337, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "time sensor_readings_old sensor_readings" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10428/" ]
186,096
<p>Is there a simple and lightweight program to search over a text file and replace a string with regex?</p>
[ { "answer_id": 186116, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 2, "selected": false, "text": "sed -e 's/foo/bar/g' input.txt > output.txt\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
186,099
<p>I many times have to work with directories containing hundreds of thousands of files, doing text matching, replacing and so on. If I go the standard route of, say</p> <pre><code>grep foo * </code></pre> <p>I get the too many files error message, so I end up doing</p> <pre><code>for i in *; do grep foo $i; done </...
[ { "answer_id": 186167, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 0, "selected": false, "text": "for i in *; do\n grep foo $i\ndone\n find ../path/ | xargs grep foo\n" }, { "answer_id": 186171, "author"...
2008/10/09
[ "https://Stackoverflow.com/questions/186099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
186,106
<p>I am new to web programming and have been exploring issues related to web security.</p> <p>I have a form where the user can post two types of data - lets call them &quot;safe&quot; and &quot;unsafe&quot; (from the point of view of sql).</p> <p>Most places recommend storing both parts of the data in database after sa...
[ { "answer_id": 186184, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 1, "selected": false, "text": "$db->Execute(\"insert into foo(x,y,z) values (?,?,?)\", array($one, $two, $three));\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
186,108
<p>In a vxWorks Real-Time process, you can pass environment variables as one of the parameter of the <strong>main</strong> routine.</p> <p>How do you use the environment variables in the kernel context?</p>
[ { "answer_id": 186124, "author": "LeopardSkinPillBoxHat", "author_id": 22489, "author_profile": "https://Stackoverflow.com/users/22489", "pm_score": 3, "selected": true, "text": "putenv \"<VARIABLE NAME>=<VALUE>\"\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
186,125
<p>I would like to use a secure SSL login on my website! I have not used SSL before, so I am looking for some good reading. Can anyone tell me where I can find some sample code of SSL snippets or page code. (Not too technical)</p> <ul> <li>I do have a static IP</li> <li>My host is set-up to handle SSL Pages. </li> </...
[ { "answer_id": 186138, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 2, "selected": false, "text": "if($requireSSL && $_SERVER['SERVER_PORT'] != 443) \n{\n header(\"HTTP/1.1 301 Moved Permanently\");\n header(\"Locat...
2008/10/09
[ "https://Stackoverflow.com/questions/186125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
186,131
<p>He're an interesting problem that looks for the most Pythonic solution. Suppose I have a list of mappings <code>{'id': id, 'url': url}</code>. Some <code>id</code>s in the list are duplicate, and I want to create a new list, with all the duplicates removed. I came up with the following function:</p> <pre><code>def ...
[ { "answer_id": 186295, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 3, "selected": true, "text": "def unique_mapping(mappings):\n return dict((m['id'], m) for m in mappings).values()\n def unique_mapping(mappings):\n ...
2008/10/09
[ "https://Stackoverflow.com/questions/186131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
186,160
<p>I have a table in the database that I'm retrieving using LINQ to SQL, and as a part of my processing I want to add to this list, then update the database with the new items + any changes I've made.</p> <p>What I thought I could do was this:</p> <pre><code>var list = (from item in db.Table select item)....
[ { "answer_id": 186221, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 4, "selected": true, "text": "Item item;\nif (needNewOne)\n{\n item = new Item();\n db.InsertOnSubmit(item);\n}\nelse\n{\n item = list[i...
2008/10/09
[ "https://Stackoverflow.com/questions/186160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
186,196
<p>At the moment I check in all my files (including dll's, VS solution files, images, etc). I often need to checkout these files to a staging server or to a another developer and so having these files there means the project is setup there all ready to go.</p> <p>Whats the best practice here?</p> <p>EDIT: If I don't ...
[ { "answer_id": 186253, "author": "Sietse", "author_id": 6400, "author_profile": "https://Stackoverflow.com/users/6400", "pm_score": 1, "selected": false, "text": "mvn eclipse:eclipse mvn eclipse:clean" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23230/" ]
186,202
<p>What is the most elegant way to solve this:</p> <ul> <li>open a file for reading, but only if it is not already opened for writing</li> <li>open a file for writing, but only if it is not already opened for reading or writing</li> </ul> <p>The built-in functions work like this</p> <pre><code>&gt;&gt;&gt; path = r"...
[ { "answer_id": 186300, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": 0, "selected": false, "text": "import time\nclass ExclusiveFile(file):\n openFiles = {}\n fileLocks = []\n\n class FileNotExclusiveException(Except...
2008/10/09
[ "https://Stackoverflow.com/questions/186202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19166/" ]
186,207
<p>I've seen that a Processor Pack is available for Visual Studio 6, however it appears to only be available for users with SP5 and I am already using SP6:</p> <p><em>In addition, the Visual C++ Processor Pack (VCPP) was removed from Service Pack 6. If you have the VCPP installed, installing SP6 will remove it from yo...
[ { "answer_id": 3918513, "author": "b w", "author_id": 4126, "author_profile": "https://Stackoverflow.com/users/4126", "pm_score": 2, "selected": false, "text": "latest HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\ServicePacks" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15669/" ]
186,208
<p>What Latex styles do you use and where do you find them?</p> <p>The reason I'm asking this is that it seems that some 99.9999% of all styles on the internet are copies of each other and of a <a href="http://www.tug.org/texshowcase/ps_s_1b.pdf" rel="noreferrer">physics exam paper</a></p> <p>However, when you try to...
[ { "answer_id": 186452, "author": "Will Robertson", "author_id": 4161, "author_profile": "https://Stackoverflow.com/users/4161", "pm_score": 4, "selected": true, "text": "\\newcommand\\catalogueEntry[4]{%\n \\parbox[t]{0.23\\linewidth}{\\textbf{#1}}%\n \\hfill\n \\parbox[t]{0.23\\linew...
2008/10/09
[ "https://Stackoverflow.com/questions/186208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445049/" ]
186,211
<p>I am using Windows 2003. I have mapped a web application into a virtual directory. This is built on framework 1.1 When i try to browse to the default page i get a error as </p> <p>Description: An error occurred during the processing of a configuration file required to service this request. Please review the specifi...
[ { "answer_id": 186452, "author": "Will Robertson", "author_id": 4161, "author_profile": "https://Stackoverflow.com/users/4161", "pm_score": 4, "selected": true, "text": "\\newcommand\\catalogueEntry[4]{%\n \\parbox[t]{0.23\\linewidth}{\\textbf{#1}}%\n \\hfill\n \\parbox[t]{0.23\\linew...
2008/10/09
[ "https://Stackoverflow.com/questions/186211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
186,232
<p>I want to use implicit linking in my project , and nmake really wants a .def file . The problem is , that this is a class , and I don't know what to write in the exports section . Could anyone point me in the right direction ?</p> <p>The error message is the following :</p> <p><strong>NMAKE : U1073: don't know ho...
[ { "answer_id": 186240, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "__declspec(dllexport)" }, { "answer_id": 186834, "author": "xtofl", "author_id": 6610, "author_profil...
2008/10/09
[ "https://Stackoverflow.com/questions/186232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
186,237
<p>I've got a "Schroedinger's Cat" type of problem here -- my program (actually the test suite for my program, but a program nonetheless) is crashing, but only when built in release mode, and only when launched from the command line. Through caveman debugging (ie, nasty printf() messages all over the place), I have de...
[ { "answer_id": 186247, "author": "David Dibben", "author_id": 5022, "author_profile": "https://Stackoverflow.com/users/5022", "pm_score": 6, "selected": false, "text": "int* p;\n....\nif (p == 0) { // do stuff }\n" }, { "answer_id": 186269, "author": "Franci Penov", "auth...
2008/10/09
[ "https://Stackoverflow.com/questions/186237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
186,244
<p>One of the major advantages with Javascript is said to be that it is a prototype based language. </p> <p>But what does it mean that Javascript is prototype based, and why is that an advantage?</p>
[ { "answer_id": 186368, "author": "artificialidiot", "author_id": 7988, "author_profile": "https://Stackoverflow.com/users/7988", "pm_score": 3, "selected": false, "text": "myobject.prototype=unkownobject;\nmyobject.newproperty=1;\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1918/" ]
186,277
<p>In the company where I work we have major releases twice every year. Extensive testing (automated and manual) is done the weeks before. The automated tests produce logfiles, the results of the manual tests are written down in test plans (Word documents). As you can imagine this results in a lot of different files t...
[ { "answer_id": 186532, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 2, "selected": false, "text": "1" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26395/" ]
186,307
<p>A project I'm working on will pull XML from a web-server and build a data store from it. The data will have certain core fields but needs to be extendable... for example I have a and later might want to have which adds extra fields.</p> <p>In the Flex app, I don't want the central data store to be working on XML ...
[ { "answer_id": 186991, "author": "Raleigh Buckner", "author_id": 1153, "author_profile": "https://Stackoverflow.com/users/1153", "pm_score": 2, "selected": false, "text": "package {\n\n public class Foo{\n\n public function Foo(barparam1:String, barparam2:uint, barparam3:String, bar...
2008/10/09
[ "https://Stackoverflow.com/questions/186307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
186,311
<p>I have a list of Date objects, and a target Date. I want to find the date in the list that's nearest to the target date, but only dates that are before the target date.</p> <p>Example: 2008-10-1 2008-10-2 2008-10-4</p> <p>With a target date of 2008-10-3, I want to get 2008-10-2</p> <p>What is the best way to do i...
[ { "answer_id": 186318, "author": "Sietse", "author_id": 6400, "author_profile": "https://Stackoverflow.com/users/6400", "pm_score": 2, "selected": false, "text": "private Date getDateNearest(List<Date> dates, Date targetDate){\n for (Date date : dates) {\n if (date.compareTo(targetDa...
2008/10/09
[ "https://Stackoverflow.com/questions/186311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6400/" ]
186,313
<p>I'm using the Scriptaculous library to slap an appealing UI on an application which helps an enduser build lists. Let's say its for pizza creation.</p> <p>To fill out an order, you drag a size of pizza from the pizza palette into the orders droppable. Once it is put in there, it gets replaced with a new div which...
[ { "answer_id": 187094, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<table border=\"1\" cellpadding=\"5\">\n<tr>\n <td valign=\"top\">\n <ul id='fList' style='bo...
2008/10/09
[ "https://Stackoverflow.com/questions/186313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15046/" ]
186,314
<p>I am debugging a large, complex web page that has a lot of JavaScript, JQuery, Ajax and so on. Somewhere in that code I am getting a rouge request (I think it is an empty img) that calls the root of the server. I know it is not in the html or the css and am pretty convinced that somewhere in the JavaScript code th...
[ { "answer_id": 195652, "author": "Vincent Robert", "author_id": 268, "author_profile": "https://Stackoverflow.com/users/268", "pm_score": 1, "selected": false, "text": "$(document).bind('beforeSend', function(event, request, ajaxOptions)\n{\n // Will be called before every jQuery AJAX ...
2008/10/09
[ "https://Stackoverflow.com/questions/186314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3893/" ]
186,316
<p>I'm looking at creating a server in python that I can run, and will work as an SSH server. This will then let different users login, and act as if they'd logged in normally, but only had access to one command.</p> <p>I want to do this so that I can have a system where I can add users to without having to create a s...
[ { "answer_id": 189452, "author": "Jean-Paul Calderone", "author_id": 18243, "author_profile": "https://Stackoverflow.com/users/18243", "pm_score": 4, "selected": true, "text": "ISession.openShell IConchUser ISession openShell ISession.openShell openShell IProcessProtocol makeConnection I...
2008/10/09
[ "https://Stackoverflow.com/questions/186316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20010/" ]
186,328
<p>Which is generally fastest when reading/comparing row info from a DataTable?</p> <pre><code>'assume dt as datatable' 'method 1' dim i as int32 for i = 0 to dt.rows.count - 1 .... next 'method 2' dim row as datarow for each row in dt.rows .... next </code></pre> <p>And if there's a difference, in what circ...
[ { "answer_id": 186363, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 4, "selected": true, "text": "for each row in dt.rows\n// expands to:\nIEnumerator e = dt.rows.GetEnumerator()\nwhile e.MoveNext()\n row = e....
2008/10/09
[ "https://Stackoverflow.com/questions/186328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17235/" ]
186,338
<p>Everything I read about better PHP coding practices keeps saying don't use <code>require_once</code> because of speed.</p> <p>Why is this?</p> <p>What is the proper/better way to do the same thing as <code>require_once</code>? If it matters, I'm using PHP&nbsp;5.</p>
[ { "answer_id": 186386, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 8, "selected": true, "text": "require_once include_once *_once *_once if (!defined('MyIncludeName')) {\n require('MyIncludeName');\n define('MyIncludeN...
2008/10/09
[ "https://Stackoverflow.com/questions/186338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314/" ]
186,345
<p>I have a HTML select list with quite a few (1000+) names. I have a javascript in place which will select the first matching name if someone starts typing. This matching looks at the start of the item: </p> <pre><code>var optionsLength = dropdownlist.options.length; for (var n=0; n &lt; optionsLength; n++) { ...
[ { "answer_id": 186393, "author": "MDCore", "author_id": 1896, "author_profile": "https://Stackoverflow.com/users/1896", "pm_score": 2, "selected": false, "text": "if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0)\n if (optionText.indexOf(dropdownlist.keypressBuffer) > 0)\n drop...
2008/10/09
[ "https://Stackoverflow.com/questions/186345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6399/" ]
186,385
<p>Which is the best timer approach for a C# console batch application that has to process as follows:</p> <ol> <li>Connect to datasources</li> <li>process batch until timeout occurs or processing complete. "Do something with datasources"</li> <li>stop console app gracefully.</li> </ol> <p>related question: <a href="...
[ { "answer_id": 186439, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "List<DataSource> dataSources = ConnectToDataSources();\nTimeSpan timeout = GetTimeoutFromConfiguration(); // Or have it ...
2008/10/09
[ "https://Stackoverflow.com/questions/186385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
186,392
<p>Many database systems don't allow comments or descriptions of tables and fields, so how do you go about documenting the purpose of a table/field apart from the obvious of having good naming conventions?</p> <p>(Let's assume for now that "excellent" table and field names are not enough to document the full meaning o...
[ { "answer_id": 25296408, "author": "hhh", "author_id": 1853769, "author_profile": "https://Stackoverflow.com/users/1853769", "pm_score": 1, "selected": false, "text": ".sql mysqldump --no-data --tab=./tables dbname" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1709/" ]
186,403
<p>When you create a procedure (or a function) in Oracle PL/SQL, you cannot specify the maximum length of the varchar2 arguments, only the datatype. For example</p> <pre><code>create or replace procedure testproc(arg1 in varchar2) is begin null; end; </code></pre> <p>Do you know the maximum length of a string that ...
[ { "answer_id": 22060657, "author": "user272735", "author_id": 272735, "author_profile": "https://Stackoverflow.com/users/272735", "pm_score": 2, "selected": false, "text": "VARCHAR2" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20037/" ]
186,405
<p>This is a very basic problem that's frustrating me at the moment. Let's say within a single solution, I have two projects. Let's call the first project SimpleMath. It has one header file "Add.h" which has </p> <pre><code>int add(int i, int j) </code></pre> <p>and the implementation "Add.cpp" which has</p> <pre><c...
[ { "answer_id": 186430, "author": "korona", "author_id": 25731, "author_profile": "https://Stackoverflow.com/users/25731", "pm_score": 3, "selected": false, "text": "int add (int, int)\n #pragma once #ifndef #ifndef __ADD_H\n#define __ADD_H\n\nint add (int i, int j);\n\n#endif\n" }, {...
2008/10/09
[ "https://Stackoverflow.com/questions/186405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
186,413
<p>I need to add a <code>xml:lang</code> attribute on the root xml node in the outbound document from BizTalk.</p> <p>This is a fixed value, so it may be set in the schema or something.</p> <p>This is what I want to get out:</p> <pre><code>&lt;Catalog xml:lang="NB-NO"&gt; ... &lt;/Catalog&gt; </code></pre> <p>I've ...
[ { "answer_id": 186435, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" \n" }, { "answer_id": 8806322, "author": "DanMan", "aut...
2008/10/09
[ "https://Stackoverflow.com/questions/186413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
186,422
<p>we're running in this issue. We're using a web service (using soap4r) to run some kind of searches and the problem appears when the webservice server is down and our aplication is trying to connect to it. At that point the application is unreachable, and all the customers are blocked.</p> <p>What can we do to avoi...
[ { "answer_id": 195681, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 0, "selected": false, "text": "maintence.html # Check for maintenance file and redirect all requests\nRewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f\...
2008/10/09
[ "https://Stackoverflow.com/questions/186422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22083/" ]
186,431
<p>Given a week number, e.g. <code>date -u +%W</code>, how do you calculate the days in that week starting from Monday?</p> <p>Example rfc-3339 output for week 40:</p> <pre><code>2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12 </code></pre>
[ { "answer_id": 186478, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 7, "selected": true, "text": "$week_number = 40;\n$year = 2008;\nfor($day=1; $day<=7; $day++)\n{\n echo date('m/d/Y', strtotime($year.\"W\".$week_number...
2008/10/09
[ "https://Stackoverflow.com/questions/186431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4534/" ]
186,443
<p>At the moment I pull data from remote MS SQL Server databases using custom-built JDBC connectors. This works fine but doesn't feel like the way to do it.</p> <p>I feel I should be able to put a JDBC connection string into tnsnames on the server and have it "just work". I've looked around a little for this functiona...
[ { "answer_id": 186811, "author": "Matthew Watson", "author_id": 3839, "author_profile": "https://Stackoverflow.com/users/3839", "pm_score": 3, "selected": true, "text": "select * from mytable@my_ms_sql_server;\n" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003/" ]
186,456
<p>How do you save data from ExtJS form? Load data from the business layer into form or grid?</p>
[ { "answer_id": 195118, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": " // Define the core service page to get the data (we use this when reloading)\n var url = '/pagedata/getbizzbox.ashx?dur...
2008/10/09
[ "https://Stackoverflow.com/questions/186456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24938/" ]
186,472
<p>I've seen some Python programmers use the following style fairly consistently (we'll call it style 1):</p> <pre><code>import some_module # Use some_module.some_identifier in various places. </code></pre> <p>For support of this style, you can cite the <a href="http://www.python.org/dev/peps/pep-0020/" rel="nofollow...
[ { "answer_id": 186483, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "import some_other_module as some_module\n" }, { "answer_id": 186485, "author": "paxdiablo", "author_id": ...
2008/10/09
[ "https://Stackoverflow.com/questions/186472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
186,475
<p>I would like to use databinding when displaying data in a TextBox. I'm basically doing like:</p> <pre><code> public void ShowRandomObject(IRandomObject randomObject) { Binding binding = new Binding {Source = randomObject, Path = new PropertyPath("Name")}; txtName.SetBinding(TextBox.TextProperty, bin...
[ { "answer_id": 186479, "author": "Pop Catalin", "author_id": 4685, "author_profile": "https://Stackoverflow.com/users/4685", "pm_score": 7, "selected": true, "text": "BindingOperations.ClearBinding(txtName, TextBox.TextProperty)\n txtName.SetBinding(TextBox.TextProperty, null);\n this.bt...
2008/10/09
[ "https://Stackoverflow.com/questions/186475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/143/" ]
186,477
<p>I have a function which parses one string into two strings. In C# I would declare it like this:</p> <pre><code>void ParseQuery(string toParse, out string search, out string sort) { ... } </code></pre> <p>and I'd call it like this:</p> <pre><code>string searchOutput, sortOutput; ParseQuery(userInput, out sear...
[ { "answer_id": 187577, "author": "Bert Huijben", "author_id": 2094, "author_profile": "https://Stackoverflow.com/users/2094", "pm_score": 8, "selected": true, "text": "void ReturnString([Out] String^% value)\n{\n value = \"Returned via out parameter\";\n}\n\n// Called as\nString^ resul...
2008/10/09
[ "https://Stackoverflow.com/questions/186477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
186,493
<p>I'm trying to write a Mono C# daemon for linux.</p> <p>I'd like to do a starts and stops of it when its done processing instead of just killing the process.</p> <p>Does anyone have any examples of this?</p> <p>Edit: I figured out how to use start-stop-daemon --background in debian, so I think I'll just use that f...
[ { "answer_id": 187523, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 4, "selected": false, "text": "ServiceProcess MONO_DISABLE_SHM" } ]
2008/10/09
[ "https://Stackoverflow.com/questions/186493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253/" ]