qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
2,775
<p>Here's what I use:</p> <pre><code>SELECT CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME) </code></pre> <p>I'm thinking there may be a better and more elegant way.</p> <p>Requirements:</p> <ul> <li>It has to be as fast as possible (the less casting, the better).</li> <li>The final result has to be a <code>datetime</code> type, not a string.</li> </ul>
[ { "answer_id": 2781, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 4, "selected": false, "text": "CAST" }, { "answer_id": 3130, "author": "Marek Grzenkowicz", "author_id": 95, "author_profile": "https://...
2008/08/05
[ "https://Stackoverflow.com/questions/2775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/434/" ]
2,780
<p>Let's say that we have an ARGB color:</p> <pre><code>Color argb = Color.FromARGB(127, 69, 12, 255); //Light Urple. </code></pre> <p>When this is painted on top of an existing color, the colors will blend. So when it is blended with white, the resulting color is <code>Color.FromARGB(255, 162, 133, 255);</code></p> <p>The solution should work like this:</p> <pre><code>Color blend = Color.White; Color argb = Color.FromARGB(127, 69, 12, 255); //Light Urple. Color rgb = ToRGB(argb, blend); //Same as Color.FromARGB(255, 162, 133, 255); </code></pre> <p>What is <code>ToRGB</code>'s implementation? </p>
[ { "answer_id": 2789, "author": "Louis Brandy", "author_id": 2089740, "author_profile": "https://Stackoverflow.com/users/2089740", "pm_score": 5, "selected": true, "text": "alpha=argb.alpha()\nr = (alpha/255)*argb.r() + (1 - alpha/255)*blend.r()\ng = (alpha/255)*argb.g() + (1 - alpha/255)...
2008/08/05
[ "https://Stackoverflow.com/questions/2780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
2,785
<p>Should you set all the objects to <code>null</code> (<code>Nothing</code> in VB.NET) once you have finished with them? </p> <p>I understand that in .NET it is essential to dispose of any instances of objects that implement the <code>IDisposable</code> interface to release some resources although the object can still be something after it is disposed (hence the <code>isDisposed</code> property in forms), so I assume it can still reside in memory or at least in part?</p> <p>I also know that when an object goes out of scope it is then marked for collection ready for the next pass of the garbage collector (although this may take time).</p> <p>So with this in mind will setting it to <code>null</code> speed up the system releasing the memory as it does not have to work out that it is no longer in scope and are they any bad side effects?</p> <p>MSDN articles never do this in examples and currently I do this as I cannot see the harm. However I have come across a mixture of opinions so any comments are useful.</p>
[ { "answer_id": 2794, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": -1, "selected": false, "text": ".dispose()" }, { "answer_id": 2813, "author": "Steve T", "author_id": 415, "author_profile": "https://St...
2008/08/05
[ "https://Stackoverflow.com/questions/2785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33/" ]
2,798
<p>I've always been intrigued by Map Routing, but I've never found any good introductory (or even advanced!) level tutorials on it. Does anybody have any pointers, hints, etc?</p> <p><strong>Update:</strong> I'm primarily looking for pointers as to how a map system is implemented (data structures, algorithms, etc).</p>
[ { "answer_id": 139714, "author": "Guillermo Phillips", "author_id": 441661, "author_profile": "https://Stackoverflow.com/users/441661", "pm_score": 2, "selected": false, "text": "nodes" }, { "answer_id": 7464631, "author": "Geof", "author_id": 951678, "author_profile"...
2008/08/05
[ "https://Stackoverflow.com/questions/2798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
2,804
<p>I have an application that displays an image inside of a Windows Forms <code>PictureBox</code> control. The <code>SizeMode</code> of the control is set to <code>Zoom</code> so that the image contained in the <code>PictureBox</code> will be displayed in an aspect-correct way regardless of the dimensions of the <code>PictureBox</code>.</p> <p>This is great for the visual appearance of the application because you can size the window however you want and the image will always be displayed using its best fit. Unfortunately, I also need to handle mouse click events on the picture box and need to be able to translate from screen-space coordinates to image-space coordinates.</p> <p>It looks like it's easy to translate from screen space to control space, but I don't see any obvious way to translate from control space to image space (i.e. the pixel coordinate in the source image that has been scaled in the picture box).</p> <p>Is there an easy way to do this, or should I just duplicate the scaling math that they're using internally to position the image and do the translation myself?</p>
[ { "answer_id": 3078, "author": "fastcall", "author_id": 328, "author_profile": "https://Stackoverflow.com/users/328", "pm_score": 3, "selected": false, "text": "// Recompute the image scaling the zoom mode uses to fit the image on screen\nimageScale ::= min(pictureBox.width / image.width...
2008/08/05
[ "https://Stackoverflow.com/questions/2804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/328/" ]
2,811
<p>I have a table with a structure like the following:</p> <hr /> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>LocationID</th> <th>AccountNumber</th> </tr> </thead> <tbody> <tr> <td>long-guid-here</td> <td>12345</td> </tr> <tr> <td>long-guid-here</td> <td>54321</td> </tr> </tbody> </table> </div> <p>To pass into another stored procedure, I need the XML to look like this:</p> <pre><code>&lt;root&gt; &lt;clientID&gt;12345&lt;/clientID&gt; &lt;clientID&gt;54321&lt;/clientID&gt; &lt;/root&gt; </code></pre> <p>The best I've been able to do so far was getting it like this:</p> <pre><code>&lt;root clientID=&quot;10705&quot;/&gt; </code></pre> <p>I'm using this SQL statement:</p> <pre><code>SELECT 1 as tag, null as parent, AccountNumber as 'root!1!clientID' FROM Location.LocationMDAccount WHERE locationid = 'long-guid-here' FOR XML EXPLICIT </code></pre> <p>So far, I've looked at the documentation on <a href="http://msdn.microsoft.com/en-us/library/ms345137.aspx" rel="nofollow noreferrer">the MSDN page</a>, but I've not come out with the desired results.</p> <hr /> <p>@KG,</p> <p>Yours gave me this output actually:</p> <pre><code>&lt;root&gt; &lt;Location.LocationMDAccount&gt; &lt;clientId&gt;10705&lt;/clientId&gt; &lt;/Location.LocationMDAccount&gt; &lt;/root&gt; </code></pre> <p>I'm going to stick with the <code>FOR XML EXPLICIT</code> from Chris Leon for now.</p>
[ { "answer_id": 2825, "author": "Chris Leon", "author_id": 289, "author_profile": "https://Stackoverflow.com/users/289", "pm_score": 3, "selected": true, "text": "SELECT\n 1 AS Tag,\n 0 AS Parent,\n AccountNumber AS [Root!1!AccountNumber!element]\nFROM\n Location.LocationMDAcc...
2008/08/05
[ "https://Stackoverflow.com/questions/2811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/448/" ]
2,815
<p>I would like to make a nightly cron job that fetches my stackoverflow page and diffs it from the previous day's page, so I can see a change summary of my questions, answers, ranking, etc.</p> <p>Unfortunately, I couldn't get the right set of cookies, etc, to make this work. Any ideas?</p> <p>Also, when the beta is finished, will my status page be accessible without logging in?</p>
[ { "answer_id": 2818, "author": "sparkes", "author_id": 269, "author_profile": "https://Stackoverflow.com/users/269", "pm_score": 2, "selected": false, "text": "--load-cookies (filename)\n" }, { "answer_id": 2819, "author": "Grant", "author_id": 30, "author_profile": "...
2008/08/05
[ "https://Stackoverflow.com/questions/2815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
2,840
<p>How do I page results in SQL Server 2005?</p> <p>I tried it in SQL Server 2000, but there was no reliable way to do this. I'm now wondering if SQL Server 2005 has any built in method?</p> <p>What I mean by paging is, for example, if I list users by their username, I want to be able to only return the first 10 records, then the next 10 records and so on.</p> <p>Any help would be much appreciated.</p>
[ { "answer_id": 2843, "author": "Pat", "author_id": 36, "author_profile": "https://Stackoverflow.com/users/36", "pm_score": 6, "selected": true, "text": "the Row_Number()" }, { "answer_id": 11352, "author": "Brian", "author_id": 700, "author_profile": "https://Stackove...
2008/08/05
[ "https://Stackoverflow.com/questions/2840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
2,844
<pre><code>#include &lt;stdio.h&gt; int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt); return 0; } </code></pre> <p>Output:</p> <pre><code>My number is 8 bytes wide and its value is 285212672l. A normal number is 0. </code></pre> <p>I assume this unexpected result is from printing the <code>unsigned long long int</code>. How do you <code>printf()</code> an <code>unsigned long long int</code>?</p>
[ { "answer_id": 2850, "author": "John Downey", "author_id": 200, "author_profile": "https://Stackoverflow.com/users/200", "pm_score": 10, "selected": true, "text": "printf(\"%llu\", 285212672);\n" }, { "answer_id": 2851, "author": "sparkes", "author_id": 269, "author_p...
2008/08/05
[ "https://Stackoverflow.com/questions/2844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
2,871
<p>What would be the best way to fill a C# struct from a byte[] array where the data was from a C/C++ struct? The C struct would look something like this (my C is very rusty):</p> <pre><code>typedef OldStuff { CHAR Name[8]; UInt32 User; CHAR Location[8]; UInt32 TimeStamp; UInt32 Sequence; CHAR Tracking[16]; CHAR Filler[12]; } </code></pre> <p>And would fill something like this:</p> <pre><code>[StructLayout(LayoutKind.Explicit, Size = 56, Pack = 1)] public struct NewStuff { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] [FieldOffset(0)] public string Name; [MarshalAs(UnmanagedType.U4)] [FieldOffset(8)] public uint User; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] [FieldOffset(12)] public string Location; [MarshalAs(UnmanagedType.U4)] [FieldOffset(20)] public uint TimeStamp; [MarshalAs(UnmanagedType.U4)] [FieldOffset(24)] public uint Sequence; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] [FieldOffset(28)] public string Tracking; } </code></pre> <p>What is best way to copy <code>OldStuff</code> to <code>NewStuff</code>, if <code>OldStuff</code> was passed as byte[] array?</p> <p>I'm currently doing something like the following, but it feels kind of clunky.</p> <pre><code>GCHandle handle; NewStuff MyStuff; int BufferSize = Marshal.SizeOf(typeof(NewStuff)); byte[] buff = new byte[BufferSize]; Array.Copy(SomeByteArray, 0, buff, 0, BufferSize); handle = GCHandle.Alloc(buff, GCHandleType.Pinned); MyStuff = (NewStuff)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(NewStuff)); handle.Free(); </code></pre> <p>Is there better way to accomplish this?</p> <hr> <p>Would using the <code>BinaryReader</code> class offer any performance gains over pinning the memory and using <code>Marshal.PtrStructure</code>?</p>
[ { "answer_id": 2887, "author": "Coincoin", "author_id": 42, "author_profile": "https://Stackoverflow.com/users/42", "pm_score": 8, "selected": true, "text": "SomeByteArray" }, { "answer_id": 8463705, "author": "Dushyant", "author_id": 1092176, "author_profile": "https...
2008/08/05
[ "https://Stackoverflow.com/questions/2871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206/" ]
2,873
<p>I'm working on a project where I'm coding in C in a UNIX environment. I've been using the lint tool to check my source code. Lint has been around a long time (since 1979), can anyone suggest a more recent code analysis tool I could use ? Preferably a tool that is free.</p>
[ { "answer_id": 2927, "author": "svec", "author_id": 103, "author_profile": "https://Stackoverflow.com/users/103", "pm_score": 6, "selected": true, "text": "-Werror" }, { "answer_id": 31055169, "author": "Nicolas Jean", "author_id": 4830306, "author_profile": "https://...
2008/08/05
[ "https://Stackoverflow.com/questions/2873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
2,874
<p>I have a control that is modelled on a <strong>ComboBox</strong>. I want to render the control so that the control <strong>border</strong> looks like that of a standard <strong>Windows ComboBox</strong>. Specifically, I have followed the MSDN documentation and all the rendering of the control is correct except for rendering when the control is disabled.</p> <p>Just to be clear, this is for a system with <strong>Visual Styles</strong> enabled. Also, all parts of the control render properly except the border around a disabled control, which does not match the disabled <strong>ComboBox border</strong> colour.</p> <p>I am using the <strong>VisualStyleRenderer</strong> class. MSDN suggests using the <code>VisualStyleElement.TextBox</code> element for the <strong>TextBox</strong> part of the <strong>ComboBox</strong> control but a standard disabled <strong>TextBox</strong> and a standard disabled <strong>ComboBox</strong> draw slightly differently (one has a light grey border, the other a light blue border).</p> <p>How can I get correct rendering of the control in a disabled state?</p>
[ { "answer_id": 13372, "author": "Patrik Svensson", "author_id": 936, "author_profile": "https://Stackoverflow.com/users/936", "pm_score": 4, "selected": false, "text": "// Create the renderer.\nif (VisualStyleInformation.IsSupportedByOS \n && VisualStyleInformation.IsEnabledByUser) \n...
2008/08/05
[ "https://Stackoverflow.com/questions/2874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/441/" ]
2,898
<p>Let me preface this question by saying I use TextMate on Mac OSX for my text needs and I am in love with it. Anything comparable on the Linux platform? I'll mostly use it for coding python/ruby.</p> <p>Doing a google search yielded outdated answers.</p> <p>Edit: Since there has been some concern about the 'merit' of this question. I am about to start a new Ruby Programming Project in Linux and before I got started I wanted to make sure I had the right tools to do the job.</p> <p>Edit #2: I use VIM on a daily basis -- all . the . time. I enjoy using it. I was just looking for some alternatives.</p>
[ { "answer_id": 2066166, "author": "Wayne Conrad", "author_id": 238886, "author_profile": "https://Stackoverflow.com/users/238886", "pm_score": 1, "selected": false, "text": "# Local Variables:\n# tab-width: 2\n# ruby-indent-level: 2\n# indent-tabs-mode: nil\n# End:\n" } ]
2008/08/05
[ "https://Stackoverflow.com/questions/2898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
2,900
<p>I am getting the following error:</p> <blockquote> <p>Access denied for user 'apache'@'localhost' (using password: NO)</p> </blockquote> <p>When using the following code:</p> <pre><code>&lt;?php include("../includes/connect.php"); $query = "SELECT * from story"; $result = mysql_query($query) or die(mysql_error()); echo "&lt;h1&gt;Delete Story&lt;/h1&gt;"; if (mysql_num_rows($result) &gt; 0) { while($row = mysql_fetch_row($result)){ echo '&lt;b&gt;'.$row[1].'&lt;/b&gt;&lt;span align="right"&gt;&lt;a href="../process/delete_story.php?id='.$row[0].'"&gt;Delete&lt;/a&gt;&lt;/span&gt;'; echo '&lt;br /&gt;&lt;i&gt;'.$row[2].'&lt;/i&gt;'; } } else { echo "No stories available."; } ?&gt; </code></pre> <p>The <code>connect.php</code> file contains my MySQL connect calls that are working fine with my <code>INSERT</code> queries in another portion of the software. If I comment out the <code>$result = mysql_query</code> line, then it goes through to the else statement. So, it is that line or the content in the if.</p> <p>I have been searching the net for any solutions, and most seem to be related to too many MySQL connections or that the user I am logging into MySQL as does not have permission. I have checked both. I can still perform my other queries elsewhere in the software, and I have verified that the account has the correct permissions.</p>
[ { "answer_id": 2908, "author": "Teifion", "author_id": 1384652, "author_profile": "https://Stackoverflow.com/users/1384652", "pm_score": 1, "selected": false, "text": "<?php\ninclude(\"../includes/connect.php\");\n\n$query = \"SELECT * from story\";\n$result = mysql_query($query) or die(...
2008/08/05
[ "https://Stackoverflow.com/questions/2900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454/" ]
2,913
<p>Does anyone have some good hints for writing test code for database-backend development where there is a heavy dependency on state?</p> <p>Specifically, I want to write tests for code that retrieve records from the database, but the answers will depend on the data in the database (which may change over time).</p> <p>Do people usually make a separate development system with a 'frozen' database so that any given function should always return the exact same result set?</p> <p>I am quite sure this is not a new issue, so I would be very interested to learn from other people's experience.</p> <p>Are there good articles out there that discuss this issue of web-based development in general?</p> <p>I usually write PHP code, but I would expect all of these issues are largely language and framework agnostic.</p>
[ { "answer_id": 16710, "author": "Peter Stuifzand", "author_id": 1633, "author_profile": "https://Stackoverflow.com/users/1633", "pm_score": 1, "selected": false, "text": "DELETE * FROM table" } ]
2008/08/05
[ "https://Stackoverflow.com/questions/2913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
2,914
<p>Occasionally, I've come across a webpage that tries to pop open a new window (for user input, or something important), but the popup blocker prevents this from happening.</p> <p>What methods can the calling window use to make sure the new window launched properly?</p>
[ { "answer_id": 2917, "author": "omar", "author_id": 453, "author_profile": "https://Stackoverflow.com/users/453", "pm_score": 9, "selected": true, "text": "var newWin = window.open(url); \n\nif(!newWin || newWin.closed || typeof newWin.closed=='undefined') \n{ \n //POPUP B...
2008/08/05
[ "https://Stackoverflow.com/questions/2914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/434/" ]
2,933
<p>Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.</p> <p>The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?</p>
[ { "answer_id": 2937, "author": "lubos hasko", "author_id": 275, "author_profile": "https://Stackoverflow.com/users/275", "pm_score": 9, "selected": true, "text": "PyQt" }, { "answer_id": 41966334, "author": "PythonProgrammi", "author_id": 6464947, "author_profile": "h...
2008/08/05
[ "https://Stackoverflow.com/questions/2933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
2,968
<p>For parsing player commands, I've most often used the <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29" rel="noreferrer">split</a> method to split a string by delimiters and then to then just figure out the rest by a series of <code>if</code>s or <code>switch</code>es. What are some different ways of parsing strings in Java?</p>
[ { "answer_id": 2971, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 1, "selected": false, "text": "String command = \"kick person\";\nStringTokenizer tokens = new StringTokenizer(command);\nString action = null;\n\nif (token...
2008/08/05
[ "https://Stackoverflow.com/questions/2968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/362/" ]
2,993
<p>I'm in an environment with a lot of computers that haven't been properly inventoried. Basically, no one knows which IP goes with which mac address and which hostname. So I wrote the following:</p> <pre><code># This script goes down the entire IP range and attempts to # retrieve the Hostname and mac address and outputs them # into a file. Yay! require "socket" TwoOctets = "10.26" def computer_exists?(computerip) system("ping -c 1 -W 1 #{computerip}") end def append_to_file(line) file = File.open("output.txt", "a") file.puts(line) file.close end def getInfo(current_ip) begin if computer_exists?(current_ip) arp_output = `arp -v #{current_ip}` mac_addr = arp_output.to_s.match(/..:..:..:..:..:../) host_name = Socket.gethostbyname(current_ip) append_to_file("#{host_name[0]} - #{current_ip} - #{mac_addr}\n") end rescue SocketError =&gt; mySocketError append_to_file("unknown - #{current_ip} - #{mac_addr}") end end (6..8).each do |i| case i when 6 for j in (1..190) current_ip = "#{TwoOctets}.#{i}.#{j}" getInfo(current_ip) end when 7 for j in (1..255) current_ip = "#{TwoOctets}.#{i}.#{j}" getInfo(current_ip) end when 8 for j in (1..52) current_ip = "#{TwoOctets}.#{i}.#{j}" getInfo(current_ip) end end end </code></pre> <p>Everything works except it does not find a Reverse DNS.</p> <p>Sample output that I'm getting is this:</p> <pre><code>10.26.6.12 - 10.26.6.12 - 00:11:11:9B:13:9F 10.26.6.17 - 10.26.6.17 - 08:00:69:9A:97:C3 10.26.6.18 - 10.26.6.18 - 08:00:69:93:2C:E2 </code></pre> <p>If I do <code>nslookup 10.26.6.12</code> then I get the correct reverse DNS so that shows that my machine is seeing the DNS server.</p> <p>I have tried <code>Socket.gethostbyname</code>, <code>gethostbyaddr</code>, but it doesn't work.</p> <p>Any guidance will be much appreciated.</p>
[ { "answer_id": 3012, "author": "Ecton", "author_id": 457, "author_profile": "https://Stackoverflow.com/users/457", "pm_score": 3, "selected": false, "text": "getaddrinfo" }, { "answer_id": 3306, "author": "garg", "author_id": 155, "author_profile": "https://Stackoverf...
2008/08/06
[ "https://Stackoverflow.com/questions/2993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/155/" ]
3,017
<p>By "generate", I mean auto-generation of the code necessary for a particular selected (set of) variable(s).</p> <p>But any more explicit explication or comment on good practice is welcome.</p>
[ { "answer_id": 3023, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 5, "selected": false, "text": "public PropertyType PropertyName { get; set; }\n" }, { "answer_id": 3029, "author": "Orion Edwards", "author_...
2008/08/06
[ "https://Stackoverflow.com/questions/3017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/391/" ]
3,021
<p>One of the topics that seems to come up regularly on mailing lists and online discussions is the merits (or lack thereof) of doing a Computer Science Degree. An argument that seems to come up time and again for the negative party is that they have been coding for some number of years and they have never used recursion.</p> <p>So the question is:</p> <ol> <li>What is recursion?</li> <li>When would I use recursion?</li> <li>Why don't people use recursion?</li> </ol>
[ { "answer_id": 3025, "author": "Louis Brandy", "author_id": 2089740, "author_profile": "https://Stackoverflow.com/users/2089740", "pm_score": 3, "selected": false, "text": "int fact(int a) \n{\n if(a==1)\n return 1;\n\n return a*fact(a-1);\n}\n" }, { "answer_id": 3030, "...
2008/08/06
[ "https://Stackoverflow.com/questions/3021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/358/" ]
3,033
<p>If I have a Perl hash with a bunch of (key, value) pairs, what is the preferred method of iterating through all the keys? I have heard that using <code>each</code> may in some way have unintended side effects. So, is that true, and is one of the two following methods best, or is there a better way?</p> <pre><code># Method 1 while (my ($key, $value) = each(%hash)) { # Something } # Method 2 foreach my $key (keys(%hash)) { # Something } </code></pre>
[ { "answer_id": 3360, "author": "John Siracusa", "author_id": 164, "author_profile": "https://Stackoverflow.com/users/164", "pm_score": 9, "selected": true, "text": "foreach my $key (keys %hash) { ... }\n" }, { "answer_id": 22669, "author": "Gary Richardson", "author_id": ...
2008/08/06
[ "https://Stackoverflow.com/questions/3033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219/" ]
3,058
<p>Inversion of Control (IoC) can be quite confusing when it is first encountered.</p> <ol> <li>What is it?</li> <li>Which problem does it solve?</li> <li>When is it appropriate to use and when not?</li> </ol>
[ { "answer_id": 3108, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 10, "selected": false, "text": "print \"enter your name\"\nread name\nprint \"enter your address\"\nread address\netc...\nstore in database\n" }, { ...
2008/08/06
[ "https://Stackoverflow.com/questions/3058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/358/" ]
3,061
<p>How do I call a function, using a string with the function's name? For example:</p> <pre><code>import foo func_name = &quot;bar&quot; call(foo, func_name) # calls foo.bar() </code></pre>
[ { "answer_id": 3071, "author": "Patrick Johnmeyer", "author_id": 363, "author_profile": "https://Stackoverflow.com/users/363", "pm_score": 12, "selected": true, "text": "foo" }, { "answer_id": 4605, "author": "HS.", "author_id": 618, "author_profile": "https://Stackov...
2008/08/06
[ "https://Stackoverflow.com/questions/3061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/121/" ]
3,088
<p><strong>Original Question</strong></p> <p>I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have gotten bogged down in minor details, and I don't feel I've been very organized. (<em>But the answers to this post have helped a lot.</em>)</p> <p>What can I do better to teach him effectively? Is there a logical order that I can use to run through concept by concept? Are there complexities I should avoid till later?</p> <p>The language we are working with is <a href="http://www.python.org" rel="noreferrer">Python</a>, but advice in any language is welcome.</p> <hr> <p><strong>How to Help</strong></p> <p>If you have good ones please add the following in your answer:</p> <ul> <li>Beginner Exercises and Project Ideas</li> <li>Resources for teaching beginners</li> <li>Screencasts / blog posts / free e-books</li> <li>Print books that are good for beginners</li> </ul> <p>Please describe the resource <em>with a link to it</em> so I can take a look. I want everyone to know that I have definitely been using some of these ideas. Your submissions will be aggregated in this post.</p> <hr> <p><strong>Online Resources</strong> for teaching beginners:</p> <ul> <li><a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-189January--IAP--2008/CourseHome/" rel="noreferrer">A Gentle Introduction to Programming Using Python</a></li> <li><a href="http://openbookproject.net/thinkcs/python/english2e/index.html" rel="noreferrer">How to Think Like a Computer Scientist</a></li> <li><a href="http://www.alice.org/" rel="noreferrer">Alice: a 3d program for beginners</a></li> <li><a href="http://scratch.mit.edu/" rel="noreferrer">Scratch (A system to develop programming skills)</a></li> <li><a href="http://www.htdp.org/" rel="noreferrer">How To Design Programs</a></li> <li><a href="http://mitpress.mit.edu/sicp/full-text/book/book.html" rel="noreferrer">Structure and Interpretation of Computer Programs</a></li> <li><a href="http://pine.fm/LearnToProgram/" rel="noreferrer">Learn To Program</a></li> <li><a href="http://samizdat.mines.edu/howto/HowToBeAProgrammer.html" rel="noreferrer">Robert Read's How To Be a Programmer</a></li> <li><a href="http://creators.xna.com/" rel="noreferrer">Microsoft XNA</a></li> <li><a href="http://vodpod.com/watch/914464-inspirational-oscon-keynote" rel="noreferrer">Spawning the Next Generation of Hackers</a></li> <li><a href="http://deimos3.apple.com/WebObjects/Core.woa/Browse/unsw.edu.au.1504975442.01504975444" rel="noreferrer"><em>COMP1917 Higher Computing</em> lectures by Richard Buckland</a> (requires iTunes)</li> <li><a href="http://diveintopython.net/" rel="noreferrer">Dive into Python</a></li> <li><a href="http://en.wikibooks.org/wiki/Programming:Python" rel="noreferrer">Python Wikibook</a></li> <li><a href="http://projecteuler.net/" rel="noreferrer">Project Euler</a> - sample problems (mostly mathematical)</li> <li><a href="http://www.pygame.org/" rel="noreferrer">pygame</a> - an easy python library for creating games</li> <li><a href="http://inventwithpython.com/IYOCGwP_book1.pdf" rel="noreferrer">Invent Your Own Computer Games With Python</a></li> <li><a href="http://codebetter.com/blogs/karlseguin/archive/2008/06/24/foundations-of-programming-ebook.aspx" rel="noreferrer">Foundations of Programming</a> for a next step beyond basics.</li> <li><a href="http://www.iam.unibe.ch/~scg/SBE/" rel="noreferrer">Squeak by Example</a> </li> <li><a href="http://www.briggs.net.nz/log/writing/snake-wrangling-for-kids/" rel="noreferrer">Snake Wrangling For Kids</a> (It's not just for kids!)</li> </ul> <hr> <p><strong>Recommended Print Books</strong> for teaching beginners</p> <ul> <li><a href="http://www.acceleratedcpp.com/" rel="noreferrer">Accelerated C++</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/1598631128" rel="noreferrer" rel="nofollow noreferrer">Python Programming for the Absolute Beginner</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/0735611319" rel="noreferrer" rel="nofollow noreferrer">Code by Charles Petzold</a></li> <li><a href="https://rads.stackoverflow.com/amzn/click/com/1590282418" rel="noreferrer" rel="nofollow noreferrer">Python Programming: An Introduction to Computer Science 2nd Edition</a></li> </ul>
[ { "answer_id": 12928, "author": "Wing", "author_id": 958, "author_profile": "https://Stackoverflow.com/users/958", "pm_score": 1, "selected": false, "text": "if :\n" }, { "answer_id": 22042, "author": "pkchukiss", "author_id": 2504504, "author_profile": "https://Stac...
2008/08/06
[ "https://Stackoverflow.com/questions/3088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/92/" ]
3,106
<p>I'm developing some cross platform software targeting Mono under Visual Studio and would like to be able to build the installers for Windows and Linux (Ubuntu specifically) with a single button click. I figure I could do it by calling cygwin from a post-build event, but I was hoping for at best a Visual Studio plugin or at worst a more Windows-native way of doing it. It seems like the package format is fairly simple and this must be a common need.</p> <p>edit: Re-asked question under other account due to duplicate login issue.</p>
[ { "answer_id": 74257, "author": "apenwarr", "author_id": 42219, "author_profile": "https://Stackoverflow.com/users/42219", "pm_score": 3, "selected": false, "text": "$ ar xv asciidoc_8.2.1-2_all.deb \nx - debian-binary\nx - control.tar.gz\nx - data.tar.gz\n\n$ tar -tzf control.tar.gz \n....
2008/08/06
[ "https://Stackoverflow.com/questions/3106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
3,112
<p>I have a perl variable <code>$results</code> that gets returned from a service. The value is supposed to be an array, and <code>$results</code> should be an array reference. However, when the array has only one item in it, <code>$results</code> will be set to that value, and not a referenced array that contains that one item.</p> <p>I want to do a <code>foreach</code> loop on the expected array. Without checking <code>ref($results) eq 'ARRAY'</code>, is there any way to have something equivalent to the following:</p> <pre><code>foreach my $result (@$results) { # Process $result } </code></pre> <p>That particular code sample will work for the reference, but will complain for the simple scalar.</p> <p>EDIT: I should clarify that there is no way for me to change what is returned from the service. The problem is that the value will be a scalar when there is only one value and it will be an array reference when there is more than one value.</p>
[ { "answer_id": 3126, "author": "svrist", "author_id": 86, "author_profile": "https://Stackoverflow.com/users/86", "pm_score": -1, "selected": false, "text": "#!/usr/bin/perl -w\nuse strict;\n\nsub testit {\n\n my @ret = ();\n if (shift){\n push @ret,1;\n push @ret,2;\n push @ret,3;...
2008/08/06
[ "https://Stackoverflow.com/questions/3112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219/" ]
3,136
<p>How can I set up my crontab to execute X script at 11:59PM every day without emailing me or creating any logs?</p> <p>Right now my crontab looks something like this</p> <pre><code>@daily /path/to/script.sh </code></pre>
[ { "answer_id": 3139, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 4, "selected": true, "text": "59 23 * * * /usr/sbin/myscript > /dev/null\n" }, { "answer_id": 3145, "author": "svrist", "author_id": 86, ...
2008/08/06
[ "https://Stackoverflow.com/questions/3136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87/" ]
3,143
<p>I'm compiling a NAnt project on linux with TeamCity Continuous Integration server. I have been able to generate a test report by running NAnt on mono thru a Command Line Runner but don't have the options of using the report like a NAnt Runner. I'm also using MBUnit for the testing framework.</p> <p>How can I merge in the test report and display "Tests failed: 1 (1 new), passed: 3049" for the build?</p> <p><strong>Update:</strong> take a look at MBUnitTask its a NAnt task that uses sends messages that TeamCity expects from NUnit so it lets you use all of TeamCity's features for tests.</p> <p><a href="http://code.google.com/p/nant-extensions/wiki/MbUnitTask" rel="noreferrer">MBUnitTask</a></p> <p><strong>Update:</strong> Galio has better support so you just have to reference the Galio MBUnit 3.5 dlls instead of the MBUnit 3.5 dlls and switch to the galio runner to make it work.</p>
[ { "answer_id": 4144, "author": "Lance Fisher", "author_id": 571, "author_profile": "https://Stackoverflow.com/users/571", "pm_score": 2, "selected": false, "text": "##teamcity[testSuiteStarted name='Test1']\n" }, { "answer_id": 30235, "author": "Scott Cowan", "author_id":...
2008/08/06
[ "https://Stackoverflow.com/questions/3143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253/" ]
3,147
<p>I have seen these being used every which way, and have been accused of using them the wrong way (though in that case, I was using them that way to demonstrate a <a href="http://blog.gadodia.net/extension-methods-in-vbnet-and-c/" rel="noreferrer">point</a>).</p> <p>So, what do you think are the best practices for employing Extension Methods?</p> <p>Should development teams create a library of extension methods and deploy them across various projects?</p> <p>Should there be a collection of common extension methods in the form of an open source project?</p> <p><em>Update: have decided to create an organization wide extension methods library</em></p>
[ { "answer_id": 3155, "author": "tags2k", "author_id": 192, "author_profile": "https://Stackoverflow.com/users/192", "pm_score": 2, "selected": false, "text": "Core.Extensions.Base64Encode(str);\n" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
3,150
<p>I'm having trouble figuring out how to get the testing framework set up and usable in <strong>Visual Studio 2008</strong> for <code>C++</code> presumably with the built-in unit testing suite.</p> <p>Any links or tutorials would be appreciated.</p>
[ { "answer_id": 16548, "author": "Lehane", "author_id": 142, "author_profile": "https://Stackoverflow.com/users/142", "pm_score": 1, "selected": false, "text": "#include <cppunit/extensions/HelperMacros.h>" }, { "answer_id": 1829212, "author": "aracntido", "author_id": 191...
2008/08/06
[ "https://Stackoverflow.com/questions/3150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/370/" ]
3,157
<p>In an application that heavily relies on <code>.htaccess</code> RewriteRules for its PrettyURLs (CakePHP in my case), how do I correctly set up directives to exclude certain directories from this rewriting? That is:</p> <pre><code>/appRoot/.htaccess app/ static/ </code></pre> <p>By default every request to <code>/appRoot/*</code> is being rewritten to be picked up by <code>app/webroot/index.php</code>, where it's being analysed and corresponding controller actions are being invoked. This is done by these directives in <code>.htaccess</code>:</p> <pre><code>RewriteBase /appRoot RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </code></pre> <p>I now want to exclude a few directories like static/ from this rewriting. I tried with this <em>before</em> the Cake RewriteRules:</p> <pre><code>RewriteCond $1 ^(static|otherDir).*$ [NC] RewriteRule (.*) - [L] </code></pre> <p>It works in so far that requests are no longer rewritten, but now <strong>all</strong> requests are being skipped, even legitimate Cake requests which should not match <code>^(static|otherDir).*$</code>.</p> <p>I tried several variations of these rules but can't get it to work the way I want.</p>
[ { "answer_id": 3159, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 1, "selected": false, "text": "RewriteBase /appRoot\n\nRewriteRule ^$ app/webroot/ &nbsp; &nbsp;\nRewriteRule (.*) app/webroot/$1\n" }, { "answer_id...
2008/08/06
[ "https://Stackoverflow.com/questions/3157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476/" ]
3,163
<p>I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss] into a Date object. Here are the 3 ways I have tried doing it and the times it takes each method to parse 50,000 date time strings.</p> <p>Does anyone know any faster ways of doing this or tips to speed up the methods?</p> <pre><code>castMethod1 takes 3673 ms castMethod2 takes 3812 ms castMethod3 takes 3931 ms </code></pre> <p>Code:</p> <pre><code>private function castMethod1(dateString:String):Date { if ( dateString == null ) { return null; } var year:int = int(dateString.substr(0,4)); var month:int = int(dateString.substr(5,2))-1; var day:int = int(dateString.substr(8,2)); if ( year == 0 &amp;&amp; month == 0 &amp;&amp; day == 0 ) { return null; } if ( dateString.length == 10 ) { return new Date(year, month, day); } var hour:int = int(dateString.substr(11,2)); var minute:int = int(dateString.substr(14,2)); var second:int = int(dateString.substr(17,2)); return new Date(year, month, day, hour, minute, second); } </code></pre> <p>-</p> <pre><code>private function castMethod2(dateString:String):Date { if ( dateString == null ) { return null; } if ( dateString.indexOf("0000-00-00") != -1 ) { return null; } dateString = dateString.split("-").join("/"); return new Date(Date.parse( dateString )); } </code></pre> <p>-</p> <pre><code>private function castMethod3(dateString:String):Date { if ( dateString == null ) { return null; } var mainParts:Array = dateString.split(" "); var dateParts:Array = mainParts[0].split("-"); if ( Number(dateParts[0])+Number(dateParts[1])+Number(dateParts[2]) == 0 ) { return null; } return new Date( Date.parse( dateParts.join("/")+(mainParts[1]?" "+mainParts[1]:" ") ) ); } </code></pre> <hr> <p>No, Date.parse will not handle dashes by default. And I need to return null for date time strings like <code>"0000-00-00"</code>.</p>
[ { "answer_id": 3194, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 1, "selected": false, "text": "private function castMethod2(dateString:String):Date {\n if ( dateString == null ) {\n return null;\n }\n\n i...
2008/08/06
[ "https://Stackoverflow.com/questions/3163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22/" ]
3,164
<p>If I have managed to locate and verify the existence of a file using Server.MapPath and I now want to send the user directly to that file, what is the <strong>fastest</strong> way to convert that absolute path back into a relative web path?</p>
[ { "answer_id": 3218, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 7, "selected": true, "text": "String RelativePath = AbsolutePath.Replace(Request.ServerVariables[\"APPL_PHYSICAL_PATH\"], String.Empty);\n" }, { "an...
2008/08/06
[ "https://Stackoverflow.com/questions/3164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
3,196
<p>If I have data like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Key</th> <th>Name</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Dan</td> </tr> <tr> <td>2</td> <td>Tom</td> </tr> <tr> <td>3</td> <td>Jon</td> </tr> <tr> <td>4</td> <td>Tom</td> </tr> <tr> <td>5</td> <td>Sam</td> </tr> <tr> <td>6</td> <td>Dan</td> </tr> </tbody> </table> </div> <p>What is the SQL query to bring back the records where <code>Name</code> is repeated 2 or more times?</p> <p>So the result I would want is</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Tom</th> </tr> </thead> <tbody> <tr> <td>Dan</td> </tr> </tbody> </table> </div>
[ { "answer_id": 3197, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 6, "selected": true, "text": "Select Name, Count(Name) As Count \n From Table\n Group By Name\n Having Count(Name) > 1\n Order By Count(Name) De...
2008/08/06
[ "https://Stackoverflow.com/questions/3196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230/" ]
3,213
<p>Is there an efficient method of converting an integer into the written numbers, for example:</p> <pre><code>string Written = IntegerToWritten(21); </code></pre> <p>would return "Twenty One".</p> <p>Is there any way of doing this that doesn't involve a massive look-up table?</p>
[ { "answer_id": 3215, "author": "lubos hasko", "author_id": 275, "author_profile": "https://Stackoverflow.com/users/275", "pm_score": 2, "selected": false, "text": "string GetWrittenInteger(int n)\n{\n string[] a = new string[] {\"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \...
2008/08/06
[ "https://Stackoverflow.com/questions/3213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
3,224
<p>CSS and Javascript files don't change very often, so I want them to be cached by the web browser. But I also want the web browser to see changes made to these files without requiring the user to clear their browser cache. Also want a solution that works well with a version control system such as Subversion.</p> <hr /> <blockquote> <p>Some solutions I have seen involve adding a version number to the end of the file in the form of a query string.</p> <p>Could use the SVN revision number to automate this for you: <a href="https://stackoverflow.com/questions/2308/aspnet-display-svn-revision-number">ASP.NET Display SVN Revision Number</a></p> </blockquote> <p>Can you specify how you include the <a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html" rel="noreferrer">Revision</a> variable of another file? That is in the HTML file I can include the Revision number in the URL to the CSS or Javascript file.</p> <p>In the <a href="http://svnbook.red-bean.com" rel="noreferrer">Subversion book</a> it says about Revision: &quot;This keyword describes the last known revision in which this file changed in the repository&quot;.</p> <blockquote> <p>Firefox also allows pressing <kbd>CTRL</kbd>+<kbd>R</kbd> to reload everything on a particular page.</p> </blockquote> <p>To clarify I am looking for solutions that don't require the user to do anything on their part.</p>
[ { "answer_id": 3225, "author": "grom", "author_id": 486, "author_profile": "https://Stackoverflow.com/users/486", "pm_score": 6, "selected": true, "text": "function urlmtime($url) {\n $parsed_url = parse_url($url);\n $path = $parsed_url['path'];\n\n if ($path[0] == \"/\") {\n ...
2008/08/06
[ "https://Stackoverflow.com/questions/3224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/486/" ]
3,234
<p>How would one display any add content from a "dynamic" aspx page? Currently I am working on using the System.Web.HttpResponse "Page.Response" to write a file that is stored on a web server to a web request.</p> <p>This would allow people to hit a url to the type <a href="http://www.foo.com?Image=test.jpg" rel="noreferrer">http://www.foo.com?Image=test.jpg</a> and have the image display in their browser. So as you may know this revolves around the use of Response.ContentType.</p> <p>By using </p> <pre><code>Response.ContentType = "application/octet-stream"; </code></pre> <p>I am able to display images of type gif/jpeg/png (all i have tested so far), bit trying to display .swf or .ico files gives me a nice little error.</p> <p>using</p> <pre><code>Response.ContentType = "application/x-shockwave-flash"; </code></pre> <p>I can get flash files to play, but then the images are messed.</p> <p>So how do i <strong>easily</strong> choose the contenttype?</p>
[ { "answer_id": 3240, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 0, "selected": false, "text": "// Clear the response buffer incase there is anything already in it.\nResponse.Clear();\nResponse.Buffer = true;\n\n// Read t...
2008/08/06
[ "https://Stackoverflow.com/questions/3234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231/" ]
3,255
<p>Most people with a degree in CS will certainly know what <a href="http://www.nist.gov/dads/HTML/bigOnotation.html" rel="noreferrer">Big O stands for</a>. It helps us to measure how well an algorithm scales. </p> <p>But I'm curious, how do <em>you</em> calculate or approximate the complexity of your algorithms?</p>
[ { "answer_id": 3368, "author": "DShook", "author_id": 370, "author_profile": "https://Stackoverflow.com/users/370", "pm_score": 8, "selected": false, "text": "int array[n];\n" }, { "answer_id": 4515, "author": "sven", "author_id": 46, "author_profile": "https://Stacko...
2008/08/06
[ "https://Stackoverflow.com/questions/3255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46/" ]
3,260
<p>We use a data acquisition card to take readings from a device that increases its signal to a peak and then falls back to near the original value. To find the peak value we currently search the array for the highest reading and use the index to determine the timing of the peak value which is used in our calculations.</p> <p>This works well if the highest value is the peak we are looking for but if the device is not working correctly we can see a second peak which can be higher than the initial peak. We take 10 readings a second from 16 devices over a 90 second period.</p> <p>My initial thoughts are to cycle through the readings checking to see if the previous and next points are less than the current to find a peak and construct an array of peaks. Maybe we should be looking at a average of a number of points either side of the current position to allow for noise in the system. Is this the best way to proceed or are there better techniques?</p> <hr> <p>We do use LabVIEW and I have checked the <a href="http://forums.lavag.org/Peak-Detection-t8499.html" rel="noreferrer">LAVA forums</a> and there are a number of interesting examples. This is part of our test software and we are trying to avoid using too many non-standard VI libraries so I was hoping for feedback on the process/algorithms involved rather than specific code. </p>
[ { "answer_id": 24259, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 3, "selected": false, "text": "TSpectrum*" }, { "answer_id": 44357, "author": "Thomas Kammeyer", "author_id": 4410, ...
2008/08/06
[ "https://Stackoverflow.com/questions/3260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186/" ]
3,281
<p>I'm wondering if there's a way to do what I can do below with Python, in Ruby:</p> <pre><code>sum = reduce(lambda x, y: x + y, map(lambda x, y: x * y, weights, data)) </code></pre> <p>I have two arrays of equal sizes with the weights and data but I can't seem to find a function similar to map in Ruby, reduce I have working.</p>
[ { "answer_id": 3314, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 2, "selected": false, "text": "weights = [1, 2, 3]\ndata = [4, 5, 6]\nresult = Array.new\na.zip(b) { |x, y| result << x * y } # For just the one opera...
2008/08/06
[ "https://Stackoverflow.com/questions/3281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484/" ]
3,284
<p>I've been working with <a href="http://msdn.microsoft.com/en-us/library/aa479030.aspx" rel="noreferrer">providers</a> a fair bit lately, and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a few posts on the topic, and it sort of made sense, but is there a nice clear explanation?</p>
[ { "answer_id": 3291, "author": "David Wengier", "author_id": 489, "author_profile": "https://Stackoverflow.com/users/489", "pm_score": 6, "selected": false, "text": "public static class Base\n{\n public static virtual int GetNumber() { return 5; }\n}\n\npublic static class Child1 : Ba...
2008/08/06
[ "https://Stackoverflow.com/questions/3284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
3,315
<p>I need to set the height of every textbox on my form, some of which are nested within other controls. I thought I could do something like this:</p> <pre><code>private static IEnumerator&lt;TextBox&gt; FindTextBoxes(Control rootControl) { foreach (Control control in rootControl.Controls) { if (control.Controls.Count &gt; 0) { // Recursively search for any TextBoxes within each child control foreach (TextBox textBox in FindTextBoxes(control)) { yield return textBox; } } TextBox textBox2 = control as TextBox; if (textBox2 != null) { yield return textBox2; } } } </code></pre> <p>Using it like this:</p> <pre><code>foreach(TextBox textBox in FindTextBoxes(this)) { textBox.Height = height; } </code></pre> <p>But of course the compiler spits its dummy, because <em>foreach</em> expects an <strong>IEnumerable</strong> rather than an <strong>IEnumerator</strong>.</p> <p>Is there a way to do this without having to create a separate class with a <strong>GetEnumerator()</strong> method?</p>
[ { "answer_id": 3323, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 1, "selected": false, "text": "// Generic function that gets all child controls of a certain type, \n// returned in a List collection\nprivate static List<T...
2008/08/06
[ "https://Stackoverflow.com/questions/3315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/503/" ]
3,319
<p>How can I set the background color of an HTML element using css in JavaScript?</p>
[ { "answer_id": 3320, "author": "tags2k", "author_id": 192, "author_profile": "https://Stackoverflow.com/users/192", "pm_score": 5, "selected": false, "text": "var element = document.getElementById('element');\nelement.style.background = '#FF00AA';\n" }, { "answer_id": 3321, "...
2008/08/06
[ "https://Stackoverflow.com/questions/3319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
3,362
<p>I would like to be able to use the <kbd>Tab</kbd> key within a text box to tab over four spaces. The way it is now, the Tab key jumps my cursor to the next input.</p> <p>Is there some JavaScript that will capture the Tab key in the text box before it bubbles up to the UI?</p> <p>I understand some browsers (i.e. FireFox) may not allow this. How about a custom key-combo like <kbd>Shift</kbd>+<kbd>Tab</kbd>, or <kbd>Ctrl</kbd>+<kbd>Q</kbd>?</p>
[ { "answer_id": 3370, "author": "Tom", "author_id": 20, "author_profile": "https://Stackoverflow.com/users/20", "pm_score": 4, "selected": false, "text": "document.onkeydown = TabExample;\n\nfunction TabExample(evt) {\n var evt = (evt) ? evt : ((event) ? event : null);\n var tabKey = 9;...
2008/08/06
[ "https://Stackoverflow.com/questions/3362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
3,385
<p>I know that we can get the MAC address of a user via IE (ActiveX objects).</p> <p>Is there a way to obtain a user's MAC address using JavaScript?</p>
[ { "answer_id": 48112607, "author": "Ad Kahn", "author_id": 2855519, "author_profile": "https://Stackoverflow.com/users/2855519", "pm_score": 3, "selected": false, "text": "function showMacAddress() {\n var obj = new ActiveXObject(\"WbemScripting.SWbemLocator\");\n var s = obj.Conne...
2008/08/06
[ "https://Stackoverflow.com/questions/3385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384/" ]
3,400
<p><strong>Note:</strong> I <em>am</em> using SQL's Full-text search capabilities, CONTAINS clauses and all - the * is the wildcard in full-text, % is for LIKE clauses only.</p> <p>I've read in several places now that "leading wildcard" searches (e.g. using "*overflow" to match "stackoverflow") is not supported in MS SQL. I'm considering using a <a href="http://blogs.msdn.com/sqlclr/archive/2005/06/29/regex.aspx" rel="noreferrer" title="SQL CLR Blog">CLR function to add regex matching</a>, but I'm curious to see what other solutions people might have.</p> <p><strong>More Info</strong>: <a href="http://msdn.microsoft.com/en-us/library/ms552152.aspx" rel="noreferrer" title="MSDN">You can add the asterisk only at the end of the word or phrase.</a> - along with my empirical experience: When matching "myvalue", "my*" works, but "(asterisk)value" returns no match, when doing a query as simple as:</p> <pre><code>SELECT * FROM TABLENAME WHERE CONTAINS(TextColumn, '"*searchterm"'); </code></pre> <p>Thus, my need for a workaround. I'm only using search in my site on an actual search page - so it needs to work basically the same way that Google works (in the eyes on a Joe Sixpack-type user). Not nearly as complicated, but this sort of match really shouldn't fail.</p>
[ { "answer_id": 3405, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 2, "selected": false, "text": "CONTAINS" }, { "answer_id": 3521, "author": "Otto", "author_id": 519, "author_profile": "https://Stackoverflow.c...
2008/08/06
[ "https://Stackoverflow.com/questions/3400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35/" ]
3,408
<p>What do you think is the best set-up for RoR in a Win Vista environment? I've tried the radrails eclipse plug-in, and it just seemed too bulky for me, I've also started to just use Textpad and the command line, but I'm used to having somewhat of an IDE to work with.</p>
[ { "answer_id": 8381, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 2, "selected": false, "text": "rubygems" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/514/" ]
3,432
<p>I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL?</p> <p>Edit: For example I have the following</p> <pre><code>Name id Col1 Col2 Row1 1 6 1 Row2 2 2 3 Row3 3 9 5 Row4 4 16 8 </code></pre> <p>I want to combine all the following Updates into one query</p> <pre><code>UPDATE table SET Col1 = 1 WHERE id = 1; UPDATE table SET Col1 = 2 WHERE id = 2; UPDATE table SET Col2 = 3 WHERE id = 3; UPDATE table SET Col1 = 10 WHERE id = 4; UPDATE table SET Col2 = 12 WHERE id = 4; </code></pre>
[ { "answer_id": 3439, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 3, "selected": false, "text": "UPDATE table1, table2 SET table1.col1='value', table2.col1='value' WHERE table1.col3='567' AND table2.col6='567'\n" }, { ...
2008/08/06
[ "https://Stackoverflow.com/questions/3432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
3,437
<p>We recently discovered that the Google Maps API does not play nicely with SSL. Fair enough, but what are some options for overcoming this that others have used effectively?</p> <blockquote> <p><a href="http://code.google.com/support/bin/answer.py?answer=65301&amp;topic=10945" rel="noreferrer">Will the Maps API work over SSL (HTTPS)?</a></p> <p>At this time, the Maps API is not available over a secure (SSL) connection. If you are running the Maps API on a secure site, the browser may warn the user about non-secure objects on the screen.</p> </blockquote> <p>We have considered the following options</p> <ol> <li>Splitting the page so that credit card collection (the requirement for SSL) is not on the same page as the Google Map.</li> <li>Switching to another map provider, such as Virtual Earth. Rumor has it that they support SSL.</li> <li>Playing tricks with IFRAMEs. Sounds kludgy.</li> <li>Proxying the calls to Google. Sounds like a lot of overhead.</li> </ol> <p>Are there other options, or does anyone have insight into the options that we have considered?</p>
[ { "answer_id": 20612, "author": "Gary", "author_id": 2330, "author_profile": "https://Stackoverflow.com/users/2330", "pm_score": 5, "selected": true, "text": "<script src=\"http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1\" type=\"text/javascript\"></script>\n" }, { "...
2008/08/06
[ "https://Stackoverflow.com/questions/3437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308/" ]
3,470
<p>I have a very simple problem which requires a very quick and simple solution in SQL Server 2005.</p> <p>I have a table with x Columns. I want to be able to select one row from the table and then transform the columns into rows.</p> <pre><code>TableA Column1, Column2, Column3 </code></pre> <p>SQL Statement to ruturn</p> <pre><code>ResultA Value of Column1 Value of Column2 Value of Column3 </code></pre> <hr> <p><strong>@Kevin:</strong> I've had a google search on the topic but alot of the example where overly complex for my example, <strong>are you able to help further?</strong></p> <p>@Mario: The solution I am creating has 10 columns which stores the values 0 to 6 and I must work out how many columns have the value 3 or more. So I thought about creating a query to turn that into rows and then using the generated table in a subquery to say count the number of rows with Column >= 3</p>
[ { "answer_id": 3475, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 0, "selected": false, "text": "SELECT Column1 FROM table WHERE idColumn = 1\nUNION ALL\nSELECT Column2 FROM table WHERE idColumn = 1\nUNION ALL\nSELECT Colu...
2008/08/06
[ "https://Stackoverflow.com/questions/3470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
3,486
<p>I have control over the HttpServer but not over the ApplicationServer or the Java Applications sitting there but I need to block direct access to certain pages on those applications. Precisely, I don't want users automating access to forms issuing direct GET/POST HTTP requests to the appropriate servlet. </p> <p>So, I decided to block users based on the value of <code>HTTP_REFERER</code>. After all, if the user is navigating inside the site, it will have an appropriate <code>HTTP_REFERER</code>. Well, that was what I thought. </p> <p>I implemented a rewrite rule in the .htaccess file that says: </p> <pre><code>RewriteEngine on # Options +FollowSymlinks RewriteCond %{HTTP_REFERER} !^http://mywebaddress(.cl)?/.* [NC] RewriteRule (servlet1|servlet2)/.+\?.+ - [F] </code></pre> <p>I expected to forbid access to users that didn't navigate the site but issue direct GET requests to the "servlet1" or "servlet2" servlets using querystrings. But my expectations ended abruptly because the regular expression <code>(servlet1|servlet2)/.+\?.+</code> didn't worked at all. </p> <p>I was really disappointed when I changed that expression to <code>(servlet1|servlet2)/.+</code> and it worked so well that my users were blocked no matter if they navigated the site or not. </p> <p>So, my question is: How do I can accomplish this thing of not allowing "robots" with direct access to certain pages if I have no access/privileges/time to modify the application?</p>
[ { "answer_id": 3827, "author": "jj33", "author_id": 430, "author_profile": "https://Stackoverflow.com/users/430", "pm_score": 3, "selected": true, "text": "RewriteCond %{HTTP_REFERER} !^http://(www.)?example.(com|org) [NC]\nRewriteCond %{QUERY_STRING} ^.+$\nRewriteRule ^(script1|script2)...
2008/08/06
[ "https://Stackoverflow.com/questions/3486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527/" ]
3,510
<p>What is BODMAS and why is it useful in programming?</p>
[ { "answer_id": 3511, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 5, "selected": true, "text": "result = (((i + 4) - (a + b)) * MAGIC_NUMBER) - ANOTHER_MAGIC_NUMBER;\n" }, { "answer_id": 3518, "author": "Patric...
2008/08/06
[ "https://Stackoverflow.com/questions/3510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
3,512
<p>I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.</p> <p>What's the best way to programatically list, and iterate through, this many files?</p> <p>Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?</p>
[ { "answer_id": 3583, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 1, "selected": false, "text": "DIR /s/b > Files.txt\n" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/517/" ]
3,530
<p>I have a <code>Rakefile</code> with a Rake task that I would normally call from the command line:</p> <pre><code>rake blog:post Title </code></pre> <p>I'd like to write a Ruby script that calls that Rake task multiple times, but the only solution I see is shelling out using `` (backticks) or <code>system</code>.</p> <p>What's the right way to do this?</p>
[ { "answer_id": 3543, "author": "titanous", "author_id": 399, "author_profile": "https://Stackoverflow.com/users/399", "pm_score": 7, "selected": true, "text": "require 'rake'\n\ndef capture_stdout\n s = StringIO.new\n oldstdout = $stdout\n $stdout = s\n yield\n s.string\nensure\n $...
2008/08/06
[ "https://Stackoverflow.com/questions/3530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388162/" ]
3,567
<p>In SQL Server how do you query a database to bring back all the tables that have a field of a specific name?</p>
[ { "answer_id": 3574, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 0, "selected": false, "text": "SELECT Table_Name\nFROM Information_Schema.Columns\nWHERE Column_Name = 'YourFieldName'\n" }, { "answer_id": 3575, "auth...
2008/08/06
[ "https://Stackoverflow.com/questions/3567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230/" ]
3,585
<p>I want to create my Rails application with MySQL, because I like it so much. How can I do that in the latest version of Rails instead of the default SQLite?</p>
[ { "answer_id": 3586, "author": "Daniel Broekman", "author_id": 124, "author_profile": "https://Stackoverflow.com/users/124", "pm_score": 8, "selected": false, "text": "rails ProjectName\n" }, { "answer_id": 3588, "author": "James Avery", "author_id": 537, "author_prof...
2008/08/06
[ "https://Stackoverflow.com/questions/3585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/124/" ]
3,589
<p>I need to create a backup of a SQL Server 2005 Database that's only the structure...no records, just the schema. Is there any way to do this?</p> <p>EDIT: I'm trying to create a backup file to use with old processes, so a script wouldn't work for my purposes, sorry</p>
[ { "answer_id": 73465453, "author": "Daniel Brink", "author_id": 141443, "author_profile": "https://Stackoverflow.com/users/141443", "pm_score": 0, "selected": false, "text": "dbcc clonedatabase(Demo, Demo_Clone) with verify_clonedb;\nalter database [Demo_Clone] set read_write;\nbackup da...
2008/08/06
[ "https://Stackoverflow.com/questions/3589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44/" ]
3,607
<p>I've got TotroiseSVN installed and have a majority of my repositories checking in and out from C:\subversion\ <em>and a couple checking in and out from a network share (I forgot about this when I originally posted this question)</em>.</p> <p>This means that I don't have a "subversion" server per-se.</p> <p>How do I integrate TortoiseSVN and Fogbugz?</p> <p><em>Edit: inserted italics</em></p>
[ { "answer_id": 370131, "author": "Andy Madge", "author_id": 46433, "author_profile": "https://Stackoverflow.com/users/46433", "pm_score": 5, "selected": true, "text": "svnlook.exe" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
3,611
<p>I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have:</p> <pre><code>&lt;?php if ( !empty($_FILES['file']['tmp_name']) ) { move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']); header('Location: http://www.mywebsite.com/dump/'); exit; } ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Dump Upload&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Upload a File&lt;/h1&gt; &lt;form action="upload.php" enctype="multipart/form-data" method="post"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /&gt; Select the File:&lt;br /&gt;&lt;input type="file" name="file" /&gt;&lt;br /&gt; &lt;input type="submit" value="Upload" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I'm getting these errors:</p> <blockquote> <p>Warning: move_uploaded_file(./test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3</p> <p>Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpA30E.tmp' to './test.txt' in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3</p> <p>Warning: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php:3) in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 4</p> </blockquote> <p>PHP version 4.4.7 Running IIS on a Windows box. This particular file/folder has 777 permissions.</p> <p>Any ideas?</p>
[ { "answer_id": 3618, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 4, "selected": true, "text": "E:\\inetpub\\vhosts\\mywebsite.com\\httpdocs\\dump\\\nC:\\WINDOWS\\Temp\\\n" }, { "answer_id": 4618, "author": "Ke...
2008/08/06
[ "https://Stackoverflow.com/questions/3611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402/" ]
3,625
<p>I can't seem to find Developer Express' version of the <code>LinkButton</code>. (The Windows Forms linkbutton, not the <code>ASP.NET</code> linkbutton.) <code>HyperLinkEdit</code> doesn't seem to be what I'm looking for since it looks like a TextEdit/TextBox.</p> <p>Anyone know what their version of it is? I'm using the latest DevX controls: 8.2.1.</p>
[ { "answer_id": 102129, "author": "Josh Kodroff", "author_id": 549, "author_profile": "https://Stackoverflow.com/users/549", "pm_score": 3, "selected": true, "text": " control.BorderStyle = BorderStyles.NoBorder;\n control.Properties.Appearance.BackColor = Color.Transparent;\n co...
2008/08/06
[ "https://Stackoverflow.com/questions/3625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
3,654
<p>When developing a new web based application which version of html should you aim for?</p> <p>EDIT:</p> <p>cool I was just attempting to get a feel from others I tend to use XHTML 1.0 Strict in my own work and Transitional when others are involved in the content creation.</p> <p>I marked the first XHTML 1.0 Transitional post as the 'correct answer' but believe strongly that all the answers given at that point where equally valid.</p>
[ { "answer_id": 20487, "author": "Chris", "author_id": 2134, "author_profile": "https://Stackoverflow.com/users/2134", "pm_score": 2, "selected": false, "text": "Content-type: application/xhtml+xml" }, { "answer_id": 194049, "author": "Kornel", "author_id": 27009, "aut...
2008/08/06
[ "https://Stackoverflow.com/questions/3654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269/" ]
3,682
<p>I have a MySQL table with approximately 3000 rows per user. One of the columns is a datetime field, which is mutable, so the rows aren't in chronological order.</p> <p>I'd like to visualize the time distribution in a chart, so I need a number of individual datapoints. 20 datapoints would be enough.</p> <p>I could do this:</p> <pre><code>select timefield from entries where uid = ? order by timefield; </code></pre> <p>and look at every 150th row.</p> <p>Or I could do 20 separate queries and use <code>limit 1</code> and <code>offset</code>. </p> <p>But there must be a more efficient solution...</p>
[ { "answer_id": 3691, "author": "Michal Sznajder", "author_id": 501, "author_profile": "https://Stackoverflow.com/users/501", "pm_score": 1, "selected": false, "text": "select @rownum:=@rownum+1 rownum, entries.* \nfrom (select @rownum:=0) r, entries \nwhere uid = ? and rownum % 150 = 0\n...
2008/08/06
[ "https://Stackoverflow.com/questions/3682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136/" ]
3,713
<p>I'm writing a web page in ASP.NET. I have some JavaScript code, and I have a submit button with a click event.</p> <p>Is it possible to call a method I created in ASP with JavaScript's click event?</p>
[ { "answer_id": 3752, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 4, "selected": false, "text": "Ajax.Utility.RegisterTypeForAjax(GetType(YOURPAGECLASSNAME))\n" }, { "answer_id": 3777, "author": "Adhip Gup...
2008/08/06
[ "https://Stackoverflow.com/questions/3713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/557/" ]
3,725
<p>I'm writing an application that is basically just a preferences dialog, much like the tree-view preferences dialog that Visual Studio itself uses. The function of the application is simply a pass-through for data from a serial device to a file. It performs many, many transformations on the data before writing it to the file, so the GUI for the application is simply all the settings that dictate what those transformations should be.</p> <p>What's the best way to go about designing/coding a tree-view preferences dialog? The way I've been going about it is building the main window with a docked tree control on the left. Then I have been creating container controls that correspond to each node of the tree. When a node is selected, the app brings that node's corresponding container control to the front, moves it to the right position, and maximizes it in the main window. This seems really, really clunky while designing it. It basically means I have tons of container controls beyond the edge of the main window during design time that I have to keep scrolling the main window over to in order to work with them. I don't know if this totally makes sense the way I'm writing this, but maybe this visual for what I'm talking about will make more sense:</p> <p><img src="https://i.stack.imgur.com/bVRJB.png" alt="form design"></p> <p>Basically I have to work with this huge form, with container controls all over the place, and then do a bunch of run-time reformatting to make it all work. This seems like a <em>lot</em> of extra work. Am I doing this in a totally stupid way? Is there some "obvious" easier way of doing this that I'm missing?</p>
[ { "answer_id": 3776, "author": "xyz", "author_id": 82, "author_profile": "https://Stackoverflow.com/users/82", "pm_score": 5, "selected": true, "text": "this.TopLevel = false;\nthis.FormBorderStyle = FormBorderStyle.None;\nthis.Dock = DockStyle.Fill;\n" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/551/" ]
3,739
<p>I have an unusual situation in which I need a SharePoint timer job to both have local administrator windows privileges and to have <code>SHAREPOINT\System</code> SharePoint privileges.</p> <p>I can get the windows privileges by simply configuring the timer service to use an account which is a member of local administrators. I understand that this is not a good solution since it gives SharePoint timer service more rights then it is supposed to have. But it at least allows my SharePoint timer job to run <code>stsadm</code>.</p> <p>Another problem with running the timer service under local administrator is that this user won't necessarily have <code>SHAREPOINT\System</code> SharePoint privileges which I also need for this SharePoint job. It turns out that <code>SPSecurity.RunWithElevatedPrivileges</code> won't work in this case. Reflector shows that <code>RunWithElevatedPrivileges</code> checks if the current process is <code>owstimer</code> (the service process which runs SharePoint jobs) and performs no elevation this is the case (the rational here, I guess, is that the timer service is supposed to run under <code>NT AUTHORITY\NetworkService</code> windows account which which has <code>SHAREPOINT\System</code> SharePoint privileges, and thus there's no need to elevate privileges for a timer job).</p> <p>The only possible solution here seems to be to run the timer service under its usual NetworkService windows account and to run stsadm as a local administrator by storing the administrator credentials somewhere and passing them to System.Diagnostics.Process.Run() trough the StarInfo's Username, domain and password.</p> <p>It seems everything should work now, but here is another problem I'm stuck with at the moment. Stsamd is failing with the following error popup (!) (Winternals filemon shows that stsadm is running under the administrator in this case):</p> <p><code>The application failed to initialize properly (0x0c0000142).</code> <br /> <code>Click OK to terminate the application.</code></p> <p>Event Viewer registers nothing except the popup.</p> <p>The local administrator user is my account and when I just run <code>stsadm</code> interactively under this account everything is ok. It also works fine when I configure the timer service to run under this account.</p> <p>Any suggestions are appreciated :)</p>
[ { "answer_id": 3741, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 1, "selected": false, "text": "SPUserToken sut = thisSite.RootWeb.AllUsers[\"SHAREPOINT\\SYSTEM\"].UserToken;\n\nusing (SPSite syssite = new SPSite(thisSite...
2008/08/06
[ "https://Stackoverflow.com/questions/3739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
3,793
<p>What's the best way to get the contents of the mixed <code>body</code> element in the code below? The element might contain either XHTML or text, but I just want its contents in string form. The <code>XmlElement</code> type has the <code>InnerXml</code> property which is exactly what I'm after.</p> <p>The code as written <em>almost</em> does what I want, but includes the surrounding <code>&lt;body&gt;</code>...<code>&lt;/body&gt;</code> element, which I don't want.</p> <pre class="lang-js prettyprint-override"><code>XDocument doc = XDocument.Load(new StreamReader(s)); var templates = from t in doc.Descendants("template") where t.Attribute("name").Value == templateName select new { Subject = t.Element("subject").Value, Body = t.Element("body").ToString() }; </code></pre>
[ { "answer_id": 3896, "author": "Mike Powell", "author_id": 205, "author_profile": "https://Stackoverflow.com/users/205", "pm_score": 3, "selected": false, "text": "Body = t.Element(\"body\").Nodes().Aggregate(\"\", (b, node) => b += node.ToString());\n" }, { "answer_id": 16882, ...
2008/08/06
[ "https://Stackoverflow.com/questions/3793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205/" ]
3,798
<p>Currently I have two Linux servers running MySQL, one sitting on a rack right next to me under a 10 Mbit/s upload pipe (main server) and another some couple of miles away on a 3 Mbit/s upload pipe (mirror).</p> <p>I want to be able to replicate data on both servers continuously, but have run into several roadblocks. One of them being, under MySQL master/slave configurations, every now and then, some statements drop (!), meaning; some people logging on to the mirror URL don't see data that I know is on the main server and vice versa. Let's say this happens on a meaningful block of data once every month, so I can live with it and assume it's a "lost packet" issue (i.e., god knows, but we'll compensate).</p> <p>The other most important (and annoying) recurring issue is that, when for some reason we do a major upload or update (or reboot) on one end and have to <a href="http://en.wiktionary.org/wiki/sever" rel="noreferrer">sever</a> the link, then LOAD DATA FROM MASTER doesn't work and I have to manually dump on one end and upload on the other, quite a task nowadays moving some .5 TB worth of data.</p> <p>Is there software for this? I know MySQL (the "corporation") offers this as a VERY expensive service (full database replication). What do people out there do? The way it's structured, we run an automatic failover where if one server is not up, then the main URL just resolves to the other server. </p>
[ { "answer_id": 2303995, "author": "serbaut", "author_id": 84760, "author_profile": "https://Stackoverflow.com/users/84760", "pm_score": 0, "selected": false, "text": " Network timeouts between the master and the slave could result\n in corruption of the relay log.\n" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547/" ]
3,802
<p>What is the best way to typeset a function with arguments for readibility, brevity, and accuracy? I tend to put empty parentheses after the function name like <code>func()</code>, even if there are actually arguments for the function. I have trouble including the arguments and still feeling like the paragraph is readable.</p> <p>Any thoughts on best practices for this?</p>
[ { "answer_id": 3874, "author": "MojoFilter", "author_id": 93, "author_profile": "https://Stackoverflow.com/users/93", "pm_score": 3, "selected": true, "text": "myFunction(...)" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59/" ]
3,839
<p>I'm trying out the following query:</p> <pre><code>SELECT A,B,C FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C FROM table WHERE field LIKE '%query' UNION SELECT A,B,C FROM table WHERE field LIKE '%query%' GROUP BY B ORDER BY B ASC LIMIT 5 </code></pre> <p>That's three queries stuck together, kinda sorta. However, the result set that comes back reflects results from query #3 before the results from query #1 which is undesired.</p> <p>Is there any way to prioritize these so that results come as all for query #1, then all for query #2 then all for query #3? I don't want to do this in PHP just yet (not to mention having to control for results that showed up in the first query not to show in the second and so forth).</p>
[ { "answer_id": 3852, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 2, "selected": false, "text": "SELECT * FROM (\n SELECT A,B,C FROM table WHERE field LIKE 'query%'\n UNION\n SELECT A,B,C FROM table WHERE field...
2008/08/06
[ "https://Stackoverflow.com/questions/3839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547/" ]
3,856
<p>I wrote a component that displays a filename, a thumbnail and has a button to load/play the file. The component is databound to a repeater. How can I make it so that the button event fires to the main application and tells it which file to play?</p>
[ { "answer_id": 3852, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 2, "selected": false, "text": "SELECT * FROM (\n SELECT A,B,C FROM table WHERE field LIKE 'query%'\n UNION\n SELECT A,B,C FROM table WHERE field...
2008/08/06
[ "https://Stackoverflow.com/questions/3856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
3,868
<p>I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object?</p> <p>It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been <a href="http://starkravingfinkle.org/blog/2007/03/how-to-parse-html-in-mozilla/" rel="nofollow noreferrer">talk</a> of updating <a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser" rel="nofollow noreferrer">DOMParser</a> to support text/html but as of Firefox 3.0.1 you still get an <code>NS_ERROR_NOT_IMPLEMENTED</code> if you try.</p> <p>Is there any option besides using the hidden iframe trick? And if not, what is the best way to do the iframe trick so that your code works outside the context of any currently open tabs (so that closing tabs won't screw up the code, etc)?</p> <p><a href="http://mxr.mozilla.org/mozilla/source/browser/components/microsummaries/src/nsMicrosummaryService.js#2090" rel="nofollow noreferrer">This</a> is an example of why I'm looking for a solution other than the iframe hack, if I have to write <em>all</em> that code to have a robust solution, then I'd rather keep looking for something else.</p>
[ { "answer_id": 3871, "author": "Steve Willard", "author_id": 402, "author_profile": "https://Stackoverflow.com/users/402", "pm_score": 3, "selected": false, "text": "var request = new XMLHttpRequest();\n\nrequest.overrideMimeType( 'text/xml' );\nrequest.onreadystatechange = process;\nreq...
2008/08/06
[ "https://Stackoverflow.com/questions/3868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/163/" ]
3,881
<p>I have a simple setter method for a property and <code>null</code> is not appropriate for this particular property. I have always been torn in this situation: should I throw an <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html" rel="noreferrer"><code>IllegalArgumentException</code></a>, or a <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html" rel="noreferrer"><code>NullPointerException</code></a>? From the javadocs, both seem appropriate. Is there some kind of an understood standard? Or is this just one of those things that you should do whatever you prefer and both are really correct?</p>
[ { "answer_id": 3886, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 9, "selected": true, "text": "IllegalArgumentException" }, { "answer_id": 3890, "author": "Jeremy Privett", "author_id": 560, "author_pr...
2008/08/06
[ "https://Stackoverflow.com/questions/3881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
3,894
<p>Given the constraint of only using T-Sql in Sql Server 2005, is there a better way to remove the decimal point from a money datatype than a conversion to a varchar (here implicitly) and then a replace of the decimal point?</p> <p>Here is what I have currently.</p> <pre><code>SELECT REPLACE(1.23, '.', ''), REPLACE(19.99, '.', '') </code></pre> <p>Which returns the desired 123 and 1999, but I was wondering if there was a better way. Any thoughts?</p>
[ { "answer_id": 5944, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 2, "selected": false, "text": "DECLARE\n@mon1 MONEY,\n@mon2 MONEY,\n@mon3 MONEY,\n@mon4 MONEY,\n@num1 DECIMAL(19,4),\n@num2 DECIMAL(19,4),\n@num3 DECIMAL(19,...
2008/08/06
[ "https://Stackoverflow.com/questions/3894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/76/" ]
3,927
<p>What profilers have you used when working with .net programs, and which would you particularly recommend?</p>
[ { "answer_id": 100490, "author": "Matt Howells", "author_id": 16881, "author_profile": "https://Stackoverflow.com/users/16881", "pm_score": 9, "selected": true, "text": "windbg.exe" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/121/" ]
3,976
<p>I have a Prolite LED sign that I like to set up to show scrolling search queries from a apache logs and other fun statistics. The problem is, my G5 does not have a serial port, so I have to use a usb to serial dongle. It shows up as /dev/cu.usbserial and /dev/tty.usbserial . </p> <p>When i do this everything seems to be hunky-dory:</p> <pre><code>stty -f /dev/cu.usbserial speed 9600 baud; lflags: -icanon -isig -iexten -echo iflags: -icrnl -ixon -ixany -imaxbel -brkint oflags: -opost -onlcr -oxtabs cflags: cs8 -parenb </code></pre> <p>Everything also works when I use the <a href="http://www.versiontracker.com/dyn/moreinfo/macosx/24024" rel="noreferrer">serial port tool</a> to talk to it.</p> <p>If I run this piece of code while the above mentioned serial port tool, everthing also works. But as soon as I disconnect the tool the connection gets lost. </p> <pre><code>#!/usr/bin/python import serial ser = serial.Serial('/dev/cu.usbserial', 9600, timeout=10) ser.write("&lt;ID01&gt;&lt;PA&gt; \r\n") read_chars = ser.read(20) print read_chars ser.close() </code></pre> <p>So the question is, what magicks do I need to perform to start talking to the serial port without the serial port tool? Is that a permissions problem? Also, what's the difference between /dev/cu.usbserial and /dev/tty.usbserial?</p> <hr> <p>Nope, no serial numbers. The thing is, the problem persists even with sudo-running the python script, and the only thing that makes it go through if I open the connection in the gui tool that I mentioned.</p>
[ { "answer_id": 4162, "author": "Lily Ballard", "author_id": 582, "author_profile": "https://Stackoverflow.com/users/582", "pm_score": 3, "selected": false, "text": "/dev/cu.xxxxx" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/3976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
4,004
<p><strong>Most recent edits in bold</strong> I am using the .net <code>HttpListener</code> class, but I won't be running this application on IIS and am not using ASP.net. This <a href="http://www.leastprivilege.com/CommentView.aspx?guid=0c34094a-bdd4-4041-be6e-919f10fe1d31" rel="noreferrer">web site</a> describes what code to actually use to implement SSL with asp.net and <a href="http://blogs.msdn.com/adarshk/archive/2004/11/10/255467.aspx" rel="noreferrer">this site</a> describes how to set up the certificates (although I'm not sure if it works only for IIS or not). </p> <p>The class documentation describes various types of authentication (basic, digest, Windows, etc.) --- none of them refer to SSL. It does say that if <a href="http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx" rel="noreferrer">HTTPS is used, you will need to set a server certificate</a>. Is this going to be a one line property setting and <code>HttpListener</code> figures out the rest? </p> <p>In short, I need to know how to set up the certificates and how to modify the code to implement SSL.</p> <p>Although it doesn't occur when I'm trying to access HTTPS, I did notice an error in my System Event log - the source is "Schannel" and the content of the message is:</p> <blockquote> <p>A fatal error occurred when attempting to access the SSL server credential private key. The error code returned from the cryptographic module is 0x80090016.</p> </blockquote> <p>Edit:<br> <strong>Steps taken so far</strong></p> <ul> <li>Created a working HTTPListener in C# that works for HTTP connections (e.g. "<a href="http://localhost:8089/foldername/" rel="noreferrer">http://localhost:8089/foldername/</a>"</li> <li>Created a certificate using makecert.exe</li> <li>Added the certificate to be trusted using certmgr.exe</li> <li>Used Httpcfg.exe to listen for SSL connections on a test port (e.g. 8090)</li> <li>Added port 8080 to the HTTPListener via listener.Prefixes.Add(<a href="https://localhost:8090/foldername/" rel="noreferrer">https://localhost:8090/foldername/</a>");</li> <li>tested an HTTP client connection, e.g. (<a href="http://localhost:8089/foldername/" rel="noreferrer">http://localhost:8089/foldername/</a>") in a browser and receive correct return</li> <li>tested an HTTPS client connection, e.g. (<a href="http://localhost:8090/foldername/" rel="noreferrer">http://localhost:8090/foldername/</a>") in a browser and receive "Data Transfer Interrupted" (in Firefox)</li> <li>debugging in visual studio shows that the listener callback that receives the requests never gets hit when the HTTPS connection starts - I don't see any place that I could set a breakpoint to catch anything else earlier.</li> <li>netstat shows that listening ports are open for both HTTPS and HTTP. the HTTPS port does go to TIME_WAIT after a connection is attempted.</li> <li><strong><a href="http://www.fiddlertool.com/fiddler/" rel="noreferrer">Fiddler</a> and <a href="http://www.ieinspector.com/httpanalyzer/" rel="noreferrer">HTTPAnalyzer</a> don't catch any of the traffic, I guess it doesn't get far enough in the process to show up in those HTTP analysis tools</strong></li> </ul> <p><strong>Questions</strong></p> <ul> <li>What could the problem be? </li> <li>Is there a piece of .Net code I am missing (meaning I have to do more in C# other than simply add a prefix to the listener that points to HTTPS, which is what i have done)</li> <li>Have a missed a configuration step somewhere? </li> <li>What else might I do to analyze the problem?</li> <li>Is the error message in the System Event log a sign of the problem? If so how would it be fixed?</li> </ul>
[ { "answer_id": 727624, "author": "galets", "author_id": 14395, "author_profile": "https://Stackoverflow.com/users/14395", "pm_score": 3, "selected": false, "text": "makecert.exe -r -a sha1 -n CN=localhost -sky exchange -pe -b 01/01/2000 -e 01/01/2050 -ss my -sr localmachine\n" }, { ...
2008/08/06
[ "https://Stackoverflow.com/questions/4004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525/" ]
4,034
<p>What is the best way to support multiple languages for the interface in an ASP.NET MVC application? I've seen people use resource files for other applications. Is this still the best way?</p>
[ { "answer_id": 4038, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "Site.resx\nSite.en.resx\nSite.en-US.resx\nSite.fr.resx\netc...\n" }, { "answer_id": 68081, "author": "user10479",...
2008/08/06
[ "https://Stackoverflow.com/questions/4034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
4,046
<p>I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P</p> <p>I started a build.xml for a project that generates a JAR file but stopped there and I need real examples to compare notes. My good friends! I don't have anyone close to chat about this! </p> <p>This is my <a href="http://pastebin.ca/1094382" rel="noreferrer">build.xml</a> so far. </p> <p><i>(*) I edited my question based in the <a href="https://stackoverflow.com/questions/4046/can-someone-give-me-a-working-example-of-a-buildxml-for-an-ear-that-deploys-in-#4298">suggestion</a> of to use pastebin.ca</i></p>
[ { "answer_id": 4902, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 5, "selected": true, "text": "<?xml version=\"1.0\"?>\n<project name=\"project\" default=\"wasListApps\" basedir=\".\">\n <description>\n Script for...
2008/08/06
[ "https://Stackoverflow.com/questions/4046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527/" ]
4,051
<p>In <code>C</code> can I <strong>pass a multidimensional array</strong> to a function <strong>as a single argument</strong> when I don't know what the dimensions of the array are going to be?</p> <p>Besides, my multidimensional array may contain types other than strings.</p>
[ { "answer_id": 4192, "author": "andrewrk", "author_id": 432, "author_profile": "https://Stackoverflow.com/users/432", "pm_score": 6, "selected": true, "text": "typedef struct {\n int myint;\n char* mystring;\n} data;\n\ndata** array;\n" }, { "answer_id": 1916200, "author": ...
2008/08/06
[ "https://Stackoverflow.com/questions/4051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
4,052
<p>I am trying to enable Full-text indexing in SQL Server 2005 Express. I am running this on my laptop with Vista Ultimate.</p> <p>I understand that the standard version of SQL Server Express does not have full-text indexing. I have already downloaded and installed "Microsoft SQL Server 2005 Express Edition with Advanced Services Service Pack 2" (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5B5528B9-13E1-4DB9-A3FC-82116D598C3D&amp;displaylang=en" rel="noreferrer">download</a>).</p> <p>I have also ensured that both the "SQL Server (instance)" and "SQL Server FullText Search (instance)" services are running on the same account which is "Network Service".</p> <p>I have also selected the option to "Use full-text indexing" in the Database Properties > Files area.</p> <p>I can run the sql query "SELECT fulltextserviceproperty('IsFulltextInstalled');" and return 1.</p> <p>The problem I am having is that when I have my table open in design view and select "Manage FullText Index"; the full-text index window displays the message... </p> <blockquote> <p>"Creation of the full-text index is not available. Check that you have the correct permissions or that full-text catalogs are defined."</p> </blockquote> <p>Any ideas on what to check or where to go next?</p>
[ { "answer_id": 4139, "author": "csmba", "author_id": 350, "author_profile": "https://Stackoverflow.com/users/350", "pm_score": 5, "selected": true, "text": "sp_fulltext_database 'enable'\n\nCREATE FULLTEXT CATALOG [myFullText]\nWITH ACCENT_SENSITIVITY = ON\n\nCREATE FULLTEXT INDEX ON [db...
2008/08/06
[ "https://Stackoverflow.com/questions/4052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/576/" ]
4,062
<p>Currently I know of only two ways to cache data (I use PHP but I assume that the same will apply to most languages).</p> <ol> <li>Save the cache to a file</li> <li>Save the cache to a large DB field</li> </ol> <p>Are there any other (perhaps better) ways of caching or is it really just this simple?</p>
[ { "answer_id": 67170, "author": "Erlend Halvorsen", "author_id": 1920, "author_profile": "https://Stackoverflow.com/users/1920", "pm_score": 0, "selected": false, "text": "RewriteEngine on\nRewriteCond %{QUERY_STRING} ^$ # let's not cache urls with queries\nRewriteCond %{REQUEST_METHOD} ...
2008/08/06
[ "https://Stackoverflow.com/questions/4062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
4,072
<p>I just did a merge using something like:</p> <pre><code>svn merge -r 67212:67213 https://my.svn.repository/trunk . </code></pre> <p>I only had 2 files, one of which is a simple <code>ChangeLog</code>. Rather than just merging my <code>ChangeLog</code> changes, it actually pulled mine plus some previous ones that were not in the destination <code>ChangeLog</code>. I noticed there was a conflict when I executed --dry-run, so I updated <code>ChangeLog</code>, and there was still a conflict (and I saw the conflict when I did the actual merge).</p> <p>I then later diffed on the file I was merging from:</p> <pre><code>svn diff -r 67212:67213 ChangeLog </code></pre> <p>And I see just the changes I had made, so I know that extra changes didn't get in there somehow. </p> <p>This makes me worried that merge is not actually just taking what I changed, which is what I would have expected. Can anybody explain what happened?</p> <p>UPDATE: In response to NilObject:</p> <p>So, I have 2 files changed, only ChangeLog is relevant, the other merged fine. When I go to my regular trunk checkout, I do the diff command above and see:</p> <pre><code>Index: ChangeLog =================================================================== --- ChangeLog (revision 67212) +++ ChangeLog (revision 67213) @@ -1,3 +1,7 @@ +2008-08-06 Mike Stone &lt;myemail&gt; + + * changed_file: Details. + 2008-08-06 Someone Else &lt;their_email&gt; * theirChanges: Details. </code></pre> <p>After my merge of the previous changes, the diff of ChangeLog looks like this:</p> <pre><code>Index: ChangeLog =================================================================== --- ChangeLog (revision 67215) +++ ChangeLog (working copy) @@ -1,3 +1,14 @@ +&lt;&lt;&lt;&lt;&lt;&lt;&lt; .working +======= +2008-08-06 Mike Stone &lt;myemail&gt; + + * changed_file: Details. + +2008-08-06 Someone Else &lt;their_email&gt; + + * theirChanges: Details. + +&gt;&gt;&gt;&gt;&gt;&gt;&gt; .merge-right.r67213 2008-08-05 Someone Else2 &lt;their2_email&gt; * olderChange: Details. </code></pre> <p>Note that the entry that was incorrectly pulled in was not in the file I am merging it to, but yet it was not one of my changes and shouldn't have been merged anyways. It was easy to fix (remove the extra lines that weren't part of my changes), but it still makes me worry about merging automatically in <code>SVN</code>.</p>
[ { "answer_id": 4104, "author": "Ecton", "author_id": 457, "author_profile": "https://Stackoverflow.com/users/457", "pm_score": 0, "selected": false, "text": "svn merge -r 67212:67213 https://my.svn.repository/trunk .\n" }, { "answer_id": 13738, "author": "Cebjyre", "autho...
2008/08/06
[ "https://Stackoverflow.com/questions/4072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
4,080
<p>What code analysis tools do you use on your Java projects?</p> <p>I am interested in all kinds</p> <ul> <li>static code analysis tools (FindBugs, PMD, and any others)</li> <li>code coverage tools (Cobertura, Emma, and any others)</li> <li>any other instrumentation-based tools </li> <li>anything else, if I'm missing something</li> </ul> <p>If applicable, also state what build tools you use and how well these tools integrate with both your IDEs and build tools. </p> <p>If a tool is only available a specific way (as an IDE plugin, or, say, a build tool plugin) that information is also worth noting.</p>
[ { "answer_id": 79845, "author": "Greg Mattes", "author_id": 13940, "author_profile": "https://Stackoverflow.com/users/13940", "pm_score": 7, "selected": true, "text": "/absolute-path/filename:line-number:column-number: warning(tool-name): message" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/4080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235/" ]
4,138
<p>What is the best SVN Ignore Pattern should TortoiseSVN have for a VB.NET solution?</p>
[ { "answer_id": 4140, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 5, "selected": true, "text": "build deploy */bin */bin/* obj *.dll *.pdb *.user *.suo _ReSharper* *.resharper* bin\n" } ]
2008/08/06
[ "https://Stackoverflow.com/questions/4138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
4,149
<p>I have an application that writes information to file. This information is used post-execution to determine pass/failure/correctness of the application. I'd like to be able to read the file as it is being written so that I can do these pass/failure/correctness checks in real time.</p> <p>I assume it is possible to do this, but what are the gotcha's involved when using Java? If the reading catches up to the writing, will it just wait for more writes up until the file is closed, or will the read throw an exception at this point? If the latter, what do I do then? </p> <p>My intuition is currently pushing me towards BufferedStreams. Is this the way to go?</p>
[ { "answer_id": 4498, "author": "Anthony Cramp", "author_id": 488, "author_profile": "https://Stackoverflow.com/users/488", "pm_score": 2, "selected": false, "text": "public class Writer extends Object\n{\n Writer () {\n\n }\n\n public static String[] strings = \n {\n ...
2008/08/06
[ "https://Stackoverflow.com/questions/4149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/488/" ]
4,168
<p>I'm looking for a simple algorithm to 'serialize' a directed graph. In particular I've got a set of files with interdependencies on their execution order, and I want to find the correct order at compile time. I know it must be a fairly common thing to do - compilers do it all the time - but my google-fu has been weak today. What's the 'go-to' algorithm for this?</p>
[ { "answer_id": 4185, "author": "Kieron", "author_id": 588, "author_profile": "https://Stackoverflow.com/users/588", "pm_score": 1, "selected": false, "text": "Map<Object, List<Object>> source; // map of each object to its dependency list\nList<Object> dest; // destination list\n\nfunctio...
2008/08/07
[ "https://Stackoverflow.com/questions/4168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/588/" ]
4,170
<p>I need to learn ADO.NET to build applications based on MS Office. I have read a good deal about ADO.NET in the MSDN Library, but everything seems rather messy to me.</p> <p>What are the basics one must figure out when using ADO.NET? I think a few key words will suffice to let me organize my learning.</p>
[ { "answer_id": 4204, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 4, "selected": true, "text": "SQLConnection" }, { "answer_id": 14218, "author": "Mark Cidade", "author_id": 1659, "author_profile": "http...
2008/08/07
[ "https://Stackoverflow.com/questions/4170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
4,208
<p>Is there a Windows equivalent of the Unix command, <em>nice</em>?</p> <p>I'm specifically looking for something I can use at the command line, and <strong>not</strong> the "Set Priority" menu from the task manager.</p> <p>My attempts at finding this on Google have been thwarted by those who can't come up with better adjectives.</p>
[ { "answer_id": 4302, "author": "Chris Miller", "author_id": 206, "author_profile": "https://Stackoverflow.com/users/206", "pm_score": 3, "selected": false, "text": "function set-ProcessPriority { \n param($processName = $(throw \"Enter process name\"), $priority = \"Normal\")\n\n g...
2008/08/07
[ "https://Stackoverflow.com/questions/4208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55/" ]
4,221
<p>I'd like to use a <code>LinqDataSource</code> control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:</p> <pre><code>IEnumerable&lt;int&gt; values = Enumerable.Range(0, 10); IEnumerable&lt;int&gt; take3 = values.Take(3); </code></pre> <p>Does anyone know if something like this is possible with a <code>LinqDataSource</code> control?</p> <p><strong>[Update]</strong></p> <p>I'm going to use the <code>LinqDataSource</code> with the <code>ListView</code> control, <em>not</em> a GridView or Repeater. The <code>LinqDataSource</code> wizard does not provide the ability to limit the number of records return. The Advanced options only allow you to enabled deletes, inserts, and updates.</p>
[ { "answer_id": 4231, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 2, "selected": false, "text": "SELECT TOP 3 FROM \n" }, { "answer_id": 27327, "author": "Portman", "author_id": 1690, "author_profile": "htt...
2008/08/07
[ "https://Stackoverflow.com/questions/4221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519/" ]
4,227
<p>I'm using a <code>Dictionary&lt;string, int&gt;</code> where the <code>int</code> is a count of the key.</p> <p>Now, I need to access the last-inserted Key inside the Dictionary, but I do not know the name of it. The obvious attempt:</p> <pre><code>int LastCount = mydict[mydict.keys[mydict.keys.Count]]; </code></pre> <p>does not work, because <code>Dictionary.Keys</code> does not implement a []-indexer.</p> <p>I just wonder if there is any similar class? I thought about using a Stack, but that only stores a string. I could now create my own struct and then use a <code>Stack&lt;MyStruct&gt;</code>, but I wonder if there is another alternative, essentially a Dictionary that implements an []-indexer on the Keys?</p>
[ { "answer_id": 4252, "author": "Patrick", "author_id": 429, "author_profile": "https://Stackoverflow.com/users/429", "pm_score": 3, "selected": false, "text": "string[] temp = new string[mydict.count];\nmydict.Keys.CopyTo(temp, 0)\nint LastCount = mydict[temp[mydict.count - 1]]\n" }, ...
2008/08/07
[ "https://Stackoverflow.com/questions/4227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
4,230
<p>I've been doing ASP.NET development for a little while now, and I've used both the GridView and the DataGrid controls before for various things, but I never could find a really good reason to use one or the other. I'd like to know:</p> <p>What is the difference between these 2 ASP.NET controls? What are the advantages or disadvantages of both? Is one any faster? Newer? Easier to maintain?</p> <p>The intellisense summary for the controls doesn't seem to describe any difference between the two. They both can view, edit, and sort data and automatically generate columns at runtime.</p> <p><strong>Edit:</strong> Visual Studio 2008 no longer lists DataGrid as an available control in the toolbox. It is still available (for legacy support I assume) if you type it in by hand though.</p>
[ { "answer_id": 21901381, "author": "Suhaib Janjua", "author_id": 3240038, "author_profile": "https://Stackoverflow.com/users/3240038", "pm_score": 4, "selected": false, "text": "GridView" }, { "answer_id": 55546706, "author": "Litisqe Kumar", "author_id": 5047627, "au...
2008/08/07
[ "https://Stackoverflow.com/questions/4230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
4,242
<p>I want to convert a primitive to a string, and I tried:</p> <pre><code>myInt.toString(); </code></pre> <p>This fails with the error:</p> <pre><code>int cannot be dereferenced </code></pre> <p>Now, I get that primitives are not reference types (ie, not an Object) and so cannot have methods. However, Java 5 introduced autoboxing and unboxing (a la C#... which I never liked in C#, but that's beside the point). So with autoboxing, I would expect the above to convert myInt to an Integer and then call toString() on that.</p> <p>Furthermore, I believe C# allows such a call, unless I remember incorrectly. Is this just an unfortunate shortcoming of Java's autoboxing/unboxing specification, or is there a good reason for this?</p>
[ { "answer_id": 4247, "author": "Justin Standard", "author_id": 92, "author_profile": "https://Stackoverflow.com/users/92", "pm_score": 7, "selected": true, "text": "myInt" }, { "answer_id": 4256, "author": "Patrick", "author_id": 429, "author_profile": "https://Stacko...
2008/08/07
[ "https://Stackoverflow.com/questions/4242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
4,269
<p>What is the best way to programmatically send an SMS text message?</p> <p>Are there any free Web Service based SMS gateways?</p> <p>I know that if I happen to know the user's carrier (Sprint, AT&amp;T, etc), I can send an <a href="http://en.wikipedia.org/wiki/SMS_gateways" rel="noreferrer">SMS by emailing an address</a> based on phone number + carrier. I would like a good solution that does not require me to know the carrier. Barring that, is there an easy way to lookup carrier given a cell phone number?</p> <p>I understand that there are some services independent of the major mobile carriers that offer a per-message fee-based service, with API. What I would like to know is how such organizations tap into the SMS networks. Do they have contracts with mobile carriers to resell their services?</p>
[ { "answer_id": 429566, "author": "masfenix", "author_id": 50312, "author_profile": "https://Stackoverflow.com/users/50312", "pm_score": -1, "selected": false, "text": "myphonenumber@verizon.com" } ]
2008/08/07
[ "https://Stackoverflow.com/questions/4269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
4,287
<p>I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it?</p>
[ { "answer_id": 4304, "author": "Lily Ballard", "author_id": 582, "author_profile": "https://Stackoverflow.com/users/582", "pm_score": 5, "selected": true, "text": "spawn_link(?MODULE, child, [self()]).\n" }, { "answer_id": 1261457, "author": "rvirding", "author_id": 77617...
2008/08/07
[ "https://Stackoverflow.com/questions/4287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/121/" ]
4,306
<p>I am working on a project that requires the manipulation of enormous matrices, specifically pyramidal summation for a copula calculation. </p> <p>In short, I need to keep track of a relatively small number of values (usually a value of 1, and in rare cases more than 1) in a sea of zeros in the matrix (multidimensional array). </p> <p>A sparse array allows the user to store a small number of values, and assume all undefined records to be a preset value. Since it is not physically possibly to store all values in memory, I need to store only the few non-zero elements. This could be several million entries.</p> <p>Speed is a huge priority, and I would also like to dynamically choose the number of variables in the class at runtime.</p> <p>I currently work on a system that uses a binary search tree (b-tree) to store entries. Does anyone know of a better system?</p>
[ { "answer_id": 4311, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 6, "selected": true, "text": "#include <stdio.h>\n#include <stdlib.h>\n#include <map>\n\nclass triple {\npublic:\n int x;\n int y;\n int z;\n ...
2008/08/07
[ "https://Stackoverflow.com/questions/4306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/522/" ]
4,369
<p>I have a directory structure like the following;</p> <blockquote> <p>script.php</p> <p>inc/include1.php<br/> inc/include2.php</p> <p>objects/object1.php<br/> objects/object2.php</p> <p>soap/soap.php</p> </blockquote> <p>Now, I use those objects in both <code>script.php</code> and <code>/soap/soap.php</code>, I could move them, but I want the directory structure like that for a specific reason. When executing <code>script.php</code> the include path is <code>inc/include.php</code> and when executing <code>/soap/soap.php</code> it's <code>../inc</code>, absolute paths work, <code>/mnt/webdev/[project name]/inc/include1.php...</code> But it's an ugly solution if I ever want to move the directory to a different location.</p> <p>So is there a way to use relative paths, or a way to programmatically generate the <code>"/mnt/webdev/[project name]/"</code>?</p>
[ { "answer_id": 4385, "author": "Peter Coulton", "author_id": 117, "author_profile": "https://Stackoverflow.com/users/117", "pm_score": 8, "selected": true, "text": "$root = realpath($_SERVER[\"DOCUMENT_ROOT\"]);\n\ninclude \"$root/inc/include1.php\";\n" }, { "answer_id": 4388, ...
2008/08/07
[ "https://Stackoverflow.com/questions/4369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264/" ]
4,371
<p>I lost my MySQL username and password. How do I retrieve it?</p>
[ { "answer_id": 4376, "author": "Xenph Yan", "author_id": 264, "author_profile": "https://Stackoverflow.com/users/264", "pm_score": 9, "selected": true, "text": "SELECT * FROM mysql.user;\n" }, { "answer_id": 4403, "author": "jake", "author_id": 389, "author_profile": ...
2008/08/07
[ "https://Stackoverflow.com/questions/4371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131/" ]
4,393
<p>How can I drop all tables whose names begin with a given string? </p> <p>I think this can be done with some dynamic SQL and the <code>INFORMATION_SCHEMA</code> tables.</p>
[ { "answer_id": 4394, "author": "Xenph Yan", "author_id": 264, "author_profile": "https://Stackoverflow.com/users/264", "pm_score": 7, "selected": false, "text": "SELECT 'DROP TABLE \"' + TABLE_NAME + '\"' \nFROM INFORMATION_SCHEMA.TABLES \nWHERE TABLE_NAME LIKE '[prefix]%'\n" }, { ...
2008/08/07
[ "https://Stackoverflow.com/questions/4393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
4,416
<p>I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter 8 it mentions a tool with the filename "wca.exe". This is supposed to be able to generate workflow communication helper classes based on an interface you provide it. I can't find that file. I thought it would be in the latest .NET 3.5 SDK, but I just downloaded and fully installed, and it's not there. Also, some MSDN forum posts had links posted that just go to 404s. So, where can I find wca.exe?</p>
[ { "answer_id": 4394, "author": "Xenph Yan", "author_id": 264, "author_profile": "https://Stackoverflow.com/users/264", "pm_score": 7, "selected": false, "text": "SELECT 'DROP TABLE \"' + TABLE_NAME + '\"' \nFROM INFORMATION_SCHEMA.TABLES \nWHERE TABLE_NAME LIKE '[prefix]%'\n" }, { ...
2008/08/07
[ "https://Stackoverflow.com/questions/4416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]