qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
97,370
<p>I have a macro which refreshes all fields in a document (the equivalent of doing an <kbd>F9</kbd> on the fields). I'd like to fire this macro automatically when the user saves the document.</p> <p>Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I only seem to find events for the <code>Document_Open()</code> event, not the <code>Document_Save()</code> event.</p> <p>Is it possible to get the macro to fire when the user saves the document?</p> <p>Please note:</p> <ol> <li>This is Word 97. I know it is possible in later versions of Word</li> <li>I don't want to replace the standard Save button on the toolbar with a button to run my custom macro. Replacing the button on the toolbar applies to all documents and I only want it to affect this one document.</li> </ol> <p>To understand why I need this, the document contains a "SaveDate" field and I'd like this field to update on the screen when the user clicks Save. So if you can suggest another way to achieve this, then that would be just as good.</p>
[ { "answer_id": 97486, "author": "Gregg", "author_id": 18266, "author_profile": "https://Stackoverflow.com/users/18266", "pm_score": 1, "selected": false, "text": "<Import Project=\"$(MSBuildProjectDirectory)\\my.team.build.targets.proj\" />\n" }, { "answer_id": 99893, "author...
2008/09/18
[ "https://Stackoverflow.com/questions/97370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9625/" ]
97,371
<p>I need to copy the newest file in a directory to a new location. So far I've found resources on the <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a> command, a <a href="https://stackoverflow.com/q/51837">date-related question</a> here, and another <a href="https://stackoverflow.com/q/50902">related question</a>. I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place?</p>
[ { "answer_id": 97414, "author": "Robert Swisher", "author_id": 1852, "author_profile": "https://Stackoverflow.com/users/1852", "pm_score": 2, "selected": false, "text": "cp `ls -t1 | head -1` /somedir/\n" }, { "answer_id": 97427, "author": "moswald", "author_id": 8368, ...
2008/09/18
[ "https://Stackoverflow.com/questions/97371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5269/" ]
97,381
<p>C# has the keyword called <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx" rel="noreferrer">yield</a>. VB.NET lacks this keyword. How have the Visual Basic programmers gotten around the lack of this keyword? Do they implement they own iterator class? Or do they try and code to avoid the need of an iterator?</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx" rel="noreferrer">yield</a> keyword does force the compiler to do some coding behind the scenes. <em><a href="http://blogs.msdn.com/oldnewthing/archive/2008/08/12/8849519.aspx" rel="noreferrer">The implementation of iterators in C# and its consequences (part 1)</a></em> has a good example of that. </p>
[ { "answer_id": 97398, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 1, "selected": false, "text": "IEnumerator(Of T)" }, { "answer_id": 382189, "author": "Joel Coehoorn", "author_id": 3043, "author_profi...
2008/09/18
[ "https://Stackoverflow.com/questions/97381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8505/" ]
97,391
<p>I have the following enum declared:</p> <pre><code> public enum TransactionTypeCode { Shipment = 'S', Receipt = 'R' } </code></pre> <p>How do I get the value 'S' from a TransactionTypeCode.Shipment or 'R' from TransactionTypeCode.Receipt ?</p> <p>Simply doing TransactionTypeCode.ToString() gives a string of the Enum name "Shipment" or "Receipt" so it doesn't cut the mustard.</p>
[ { "answer_id": 97397, "author": "J D OConal", "author_id": 17023, "author_profile": "https://Stackoverflow.com/users/17023", "pm_score": -1, "selected": true, "text": "string value = (string)TransactionTypeCode.Shipment;\n" }, { "answer_id": 123545, "author": "IaCoder", "...
2008/09/18
[ "https://Stackoverflow.com/questions/97391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
97,392
<p>How do I get the physical addresses of my machine in <strong>Java</strong>?</p>
[ { "answer_id": 97411, "author": "Joe Dean", "author_id": 5917, "author_profile": "https://Stackoverflow.com/users/5917", "pm_score": 0, "selected": false, "text": "try {\n InetAddress addr = InetAddress.getLocalHost();\n\n // Get IP Address\n byte[] ipAddr = addr.getAddress();\n...
2008/09/18
[ "https://Stackoverflow.com/questions/97392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16949/" ]
97,421
<p>Will IE6 negotiate a 256 bit AES SSL connection if the server is capable?</p>
[ { "answer_id": 31424019, "author": "hairysocks", "author_id": 1782344, "author_profile": "https://Stackoverflow.com/users/1782344", "pm_score": 0, "selected": false, "text": "SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:!MEDIUM:!LOW:!SSLv2:!EXP:!NULL\n" } ]
2008/09/18
[ "https://Stackoverflow.com/questions/97421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17583/" ]
97,435
<p>Suppose you have the following string:</p> <pre><code>white sand, tall waves, warm sun </code></pre> <p>It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun":</p> <pre><code>\s*,\s* </code></pre> <p>Now say you have this string:</p> <pre><code>white sand and tall waves and warm sun </code></pre> <p>Again, the regex to split the tokens is easy (ensuring you don't get the "and" inside the word "sand"):</p> <pre><code>\s+and\s+ </code></pre> <p>Now, consider this string:</p> <pre><code>white sand, tall waves and warm sun </code></pre> <p>Can a regex be written that will match the delimiters correctly, allowing you to split the string into the same tokens as in the previous two cases? Alternatively, can a regex be written that will match the tokens themselves and omit the delimiters? (Any amount of white space on either side of a comma or the word "and" should be considered part of the delimiter.)</p> <p>Edit: As has been pointed out in the comments, the correct answer should robustly handle delimiters at the beginning or end of the input string. The <em>ideal</em> answer should be able to take a string like ",white sand, tall waves and warm sun and " and provide these exact three tokens:</p> <pre><code>[ "white sand", "tall waves", "warm sun" ] </code></pre> <p>...without <del>extra empty tokens or</del> extra white space at the start or end of any token.</p> <p>Edit: It's been pointed out that extra empty tokens are unavoidable with String.split(), so that's been removed as a criterion for the "perfect" regex.</p> <hr> <p>Thanks everyone for your responses! I've tried to make sure I upvoted everyone who contributed a workable regex that wasn't essentially a duplicate. Dan's answer was the most robust (it even handles ",white sand, tall waves,and warm sun and " reasonably, with that odd comma placement after the word "waves"), so I've marked his as the accepted answer. The regex provided by nsayer was a close second.</p>
[ { "answer_id": 97457, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 2, "selected": false, "text": "(?:\\sand|,)\\s\n" }, { "answer_id": 97458, "author": "e-satis", "author_id": 9951, "author_profile": "ht...
2008/09/18
[ "https://Stackoverflow.com/questions/97435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4287/" ]
97,447
<p>If I am writing a library and I have a function that needs to return a sequence of values, I could do something like:</p> <pre><code>std::vector&lt;int&gt; get_sequence(); </code></pre> <p>However, this requires the library user to use the std::vector&lt;> container rather than allowing them to use whatever container they want to use. In addition, it can add an extra copy of the returned array (depending on whether the compiler could optimize this or not) that might have a negative impact on performance.</p> <p>You could theoretically enable the use of arbitrary containers (and avoid the unnecessary extra copying) by making a templated function that takes a start and an end iter:</p> <pre><code>template&lt;class T_iter&gt; void get_sequence(T_iter begin, T_iter end); </code></pre> <p>The function would then store the sequence values in the range given by the iterators. But the problem with this is that it requires you to know the size of the sequence so you have enough elements between <code>begin</code> and <code>end</code> to store all of the values in the sequence.</p> <p>I thought about an interface such as:</p> <pre><code>template&lt;T_insertIter&gt; get_sequence(T_insertIter inserter); </code></pre> <p>which requires that the T_insertIter be an insert iterator (e.g. created with <code>std::back_inserter(my_vector)</code>), but this seems way too easy to misuse since the compiler would happily accept a non-insert iterator but would behave incorrectly at run-time.</p> <p>So is there a best practice for designing generic interfaces that return sequences of arbitrary length?</p>
[ { "answer_id": 97519, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 0, "selected": false, "text": "std::list<int>" }, { "answer_id": 97541, "author": "moswald", "author_id": 8368, "author_profile"...
2008/09/18
[ "https://Stackoverflow.com/questions/97447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78437/" ]
97,459
<p>When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar.</p> <p>To see what I mean, click in your web browser's address bar. You'll notice the following behavior: </p> <ol> <li>Clicking in the textbox should select all the text if the textbox wasn't previously focused.</li> <li>Mouse down and drag in the textbox should select only the text I've highlighted with the mouse.</li> <li>If the textbox is already focused, clicking does not select all text.</li> <li>Focusing the textbox programmatically or via keyboard tabbing should select all text.</li> </ol> <p>I want to do exactly this in WinForms.</p> <p><strong>FASTEST GUN ALERT: please read the following before answering!</strong> Thanks guys. :-)</p> <blockquote> <p><strong>Calling .SelectAll() during the .Enter or .GotFocus events won't work</strong> because if the user clicked the textbox, the caret will be placed where he clicked, thus deselecting all text.</p> <p><strong>Calling .SelectAll() during the .Click event won't work</strong> because the user won't be able to select any text with the mouse; the .SelectAll() call will keep overwriting the user's text selection.</p> <p><strong>Calling BeginInvoke((Action)textbox.SelectAll) on focus/enter event enter doesn't work</strong> because it breaks rule #2 above, it will keep overriding the user's selection on focus.</p> </blockquote>
[ { "answer_id": 97499, "author": "Jakub Kotrla", "author_id": 16943, "author_profile": "https://Stackoverflow.com/users/16943", "pm_score": 2, "selected": false, "text": "private bool f = false;\n\nprivate void textBox_MouseClick(object sender, MouseEventArgs e)\n{ \n if (this.f) { this....
2008/09/18
[ "https://Stackoverflow.com/questions/97459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
97,465
<p>Has anyone figured out how to use Crystal Reports with Linq to SQL?</p>
[ { "answer_id": 7691717, "author": "Mohammad Sepahvand", "author_id": 189756, "author_profile": "https://Stackoverflow.com/users/189756", "pm_score": 3, "selected": true, "text": "List" }, { "answer_id": 23882327, "author": "user3243012", "author_id": 3243012, "author_...
2008/09/18
[ "https://Stackoverflow.com/questions/97465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11063/" ]
97,468
<p><a href="http://github.com/rails/ssl_requirement/tree/master/lib/ssl_requirement.rb" rel="nofollow noreferrer">Take a look at the ssl_requirement plugin.</a></p> <p>Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal behavior for the plugin? I thought it behaved differently in the past.</p>
[ { "answer_id": 98697, "author": "Nathan de Vries", "author_id": 11109, "author_profile": "https://Stackoverflow.com/users/11109", "pm_score": 4, "selected": true, "text": "class YourController < ApplicationController\n ssl_required :update unless Rails.env.development?\nend\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/97468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076/" ]
97,474
<p>I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: </p> <pre><code>..../xsl:template/xsl:choose/xsl:when </code></pre> <p>But that just returns the 'when' elements, not the exact attribute values I need.</p> <p>Here is a snippet of my XML:</p> <pre><code>&lt;xsl:template match="field"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="@name='First Name'"&gt; &lt;xsl:call-template name="handleColumn_1" /&gt; &lt;/xsl:when&gt; &lt;/xsl:choose&gt; </code></pre>
[ { "answer_id": 97500, "author": "Steve Cooper", "author_id": 6722, "author_profile": "https://Stackoverflow.com/users/6722", "pm_score": 2, "selected": false, "text": ".../xsl:template/xsl:choose/xsl:when/@test" }, { "answer_id": 97738, "author": "Mike Tunnicliffe", "auth...
2008/09/18
[ "https://Stackoverflow.com/questions/97474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10876/" ]
97,480
<p>I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress?</p> <p>I understand there are problems with using ROWID for row identification, but it's all I have right now.</p>
[ { "answer_id": 100430, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 4, "selected": true, "text": "ROWID" }, { "answer_id": 102910, "author": "Stefan Moser", "author_id": 8739, "author_profile": "https...
2008/09/18
[ "https://Stackoverflow.com/questions/97480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
97,505
<p>Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. </p> <p>In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I created a main panel that selects the company, and binds to a FormView. The FormView contains a Web User Control that handles the display/configuration of the export details.</p> <p>The Web User Control Contains a property to define which Config it should be handling, and it gets the value from the FormView using Bind().</p> <p>Basically the control is used like this:</p> <pre><code>&lt;syn:ExportInfo ID="eiConfigDetails" ExportInfoID='&lt;%# Bind("ExportInfoID" ) %&gt;' runat="server" /&gt; </code></pre> <p>The property being bound is declared like this in CodeBehind:</p> <pre><code>public int ExportInfoID { get { return Convert.ToInt32(hfID.Value); } set { try { hfID.Value = value.ToString(); } catch(Exception) { hfID.Value="-1"; } } } </code></pre> <p>Whenever the <code>ExportInfoID</code> is null I get a null reference exception, but the kicker is that it happens BEFORE it actually tries to set the property (or it would be caught in this version.)</p> <p>Anyone know what's going on or, more importantly, how to fix it...?</p>
[ { "answer_id": 100430, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 4, "selected": true, "text": "ROWID" }, { "answer_id": 102910, "author": "Stefan Moser", "author_id": 8739, "author_profile": "https...
2008/09/18
[ "https://Stackoverflow.com/questions/97505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17145/" ]
97,506
<p><strong>This isn't a holy war, this isn't a question of "which is better".</strong></p> <p>What are the pros of using the following format for single statement if blocks.</p> <pre><code>if (x) print "x is true"; if(x) print "x is true"; </code></pre> <p>As opposed to</p> <pre><code>if (x) { print "x is true"; } if(x) { print "x is true"; } </code></pre> <p><strong>If you format your single statement ifs without brackets</strong> or know a programmer that does, what led you/them to adopt this style in the first place? I'm specifically interested in what benefits this has brought you.</p> <p><strong>Update</strong>: As the most popular answer ignores the actual question (even if it presents the most sane advice), here's a roundup of the bracket-less pros.</p> <ol> <li>Compactness</li> <li>More readable to some</li> <li>Brackets invoke scope, which has a theoretical overhead in some cases</li> </ol>
[ { "answer_id": 97525, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 2, "selected": false, "text": "if (foo)\n{\n Console.WriteLine(\"Foobar\");\n}\n" }, { "answer_id": 97526, "author": "Matt Dillard", "au...
2008/09/18
[ "https://Stackoverflow.com/questions/97506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668/" ]
97,520
<p>How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties?</p> <p>E.g. every table contains audit columns like CreatedBy, CreatedDate, UpdatedBy, UpdatedDate. But I dont want to add these poperties to the domain classes. I want to keep domain modedl Percistence Ignorance factor as high as possible.</p>
[ { "answer_id": 101037, "author": "noetic", "author_id": 9198, "author_profile": "https://Stackoverflow.com/users/9198", "pm_score": 1, "selected": false, "text": "private IDictionary _infrastructureProperties = new Dictionary<object, object>();\n" } ]
2008/09/18
[ "https://Stackoverflow.com/questions/97520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9198/" ]
97,522
<p>What are all the valid self-closing elements (e.g. &lt;br/&gt;) in XHTML (as implemented by the major browsers)?</p> <p>I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See <a href="http://dusan.fora.si/blog/self-closing-tags" rel="noreferrer">http://dusan.fora.si/blog/self-closing-tags</a> for examples of some problems caused by self-closing elements such as &lt;div /&gt;.</p>
[ { "answer_id": 97575, "author": "e-satis", "author_id": 9951, "author_profile": "https://Stackoverflow.com/users/9951", "pm_score": 3, "selected": false, "text": "<br />\n<hr />\n<img />\n<input />\n" }, { "answer_id": 97585, "author": "ConroyP", "author_id": 2287, "a...
2008/09/18
[ "https://Stackoverflow.com/questions/97522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1335/" ]
97,565
<p>C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a "bit depth" field in the header. After I decode the header I read the pixel values into the "pixels" array. So far I have not had more than 16bpp, so I'm okay. But what if I have 32bpp?</p> <p>What I want to do is have the type of pixels be determined at runtime. I want to do this after I read the bit depth out of the header and before I copy the pixel data into memory. Any ideas?</p>
[ { "answer_id": 97788, "author": "Wedge", "author_id": 332, "author_profile": "https://Stackoverflow.com/users/332", "pm_score": 3, "selected": true, "text": "public static ImageData Create(string imageFilename)\n{\n // ...\n ImageDataHeader imageHeader = ParseHeader(imageFilename);\n...
2008/09/18
[ "https://Stackoverflow.com/questions/97565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1812999/" ]
97,578
<p>Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example:</p> <pre><code>&lt;a href="#" onclick="SelectSurveyItem('&lt;%itemid%&gt;', '&lt;%itemname%&gt;'); return false;"&gt;Select&lt;/a&gt; </code></pre> <p>The <code>&lt;%itemid%&gt;</code> and <code>&lt;%itemname%&gt;</code> are where template substitution occurs. My problem is that the item name can contain any character, including single and double quotes. Currently, if it contains single quotes it breaks the JavaScript code.</p> <p>My first thought was to use the template language's function to JavaScript-escape the item name, which just escapes the quotes. That will not fix the case of the string containing double quotes which breaks the HTML of the link. How is this problem normally addressed? Do I need to HTML-escape the entire onClick handler?</p> <p>If so, that would look really strange since the template language's escape function for that would also HTMLify the parentheses, quotes, and semicolons...</p> <p>This link is being generated for every result in a search results page, so creating a separate method inside a JavaScript tag is not possible, because I'd need to generate one per result.</p> <p>Also, I'm using a templating engine that was home-grown at the company I work for, so toolkit-specific solutions will be of no use to me.</p>
[ { "answer_id": 97613, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 3, "selected": false, "text": ">" }, { "answer_id": 97670, "author": "Alexandre Victoor", "author_id": 11897, "author_profile": "https://S...
2008/09/18
[ "https://Stackoverflow.com/questions/97578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10861/" ]
97,586
<p>My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&amp;F.</p> <p>Can anyone provide an example of an SWT application still being able to edit the GUI in eclipse, but having the Aerith L&amp;F?</p>
[ { "answer_id": 97613, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 3, "selected": false, "text": ">" }, { "answer_id": 97670, "author": "Alexandre Victoor", "author_id": 11897, "author_profile": "https://S...
2008/09/18
[ "https://Stackoverflow.com/questions/97586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15441/" ]
97,637
<p>Anyone got a good explanation of "combinators" (Y-combinators etc. and <strong>NOT</strong> <a href="https://en.wikipedia.org/wiki/Y_Combinator_(company)" rel="noreferrer">the company</a>)?</p> <p>I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background.</p> <p>(Note: that I'm talking about <a href="https://en.wikipedia.org/wiki/Fixed-point_combinator#Fixed_point_combinators_in_lambda_calculus" rel="noreferrer">these things</a>)</p>
[ { "answer_id": 101932, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": false, "text": "> def fun():\n> print \"bla\"\n> fun()\n\n> fun()\nbla\nbla\nbla\n...\n" }, { "answer_id": 286014, "author": "mb...
2008/09/18
[ "https://Stackoverflow.com/questions/97637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
97,640
<p>How do I get my project's runtime dependencies copied into the <code>target/lib</code> folder? </p> <p>As it is right now, after <code>mvn clean install</code> the <code>target</code> folder contains only my project's jar, but none of the runtime dependencies.</p>
[ { "answer_id": 996915, "author": "Georgy Bolyuba", "author_id": 4052, "author_profile": "https://Stackoverflow.com/users/4052", "pm_score": 8, "selected": false, "text": "<project>\n ...\n <profiles>\n <profile>\n <id>qa</id>\n <build>\n <plugins>\n <plugin...
2008/09/18
[ "https://Stackoverflow.com/questions/97640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18320/" ]
97,646
<p>Given a source color of any hue by the system or user, I'd like a simple algorithm I can use to work out a lighter or darker variants of the selected color. Similar to effects used on Windows Live Messenger for styling the user interface.</p> <p>Language is C# with .net 3.5.</p> <p><strong>Responding to comment:</strong> Color format is (Alpha)RGB. With values as bytes or floats.</p> <p><strong>Marking answer:</strong> For the context of my use (a few simple UI effects), the answer I'm marking as accepted is actually the most simple for this context. However, I've given up votes to the more complex and accurate answers too. Anyone doing more advanced color operations and finding this thread in future should definitely check those out. Thanks SO. :)</p>
[ { "answer_id": 97697, "author": "KPexEA", "author_id": 13676, "author_profile": "https://Stackoverflow.com/users/13676", "pm_score": 4, "selected": false, "text": "void RGBToHSV(unsigned char cr, unsigned char cg, unsigned char cb,double *ph,double *ps,double *pv)\n{\ndouble r,g,b;\ndoub...
2008/09/18
[ "https://Stackoverflow.com/questions/97646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/483/" ]
97,663
<p>Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc.</p> <p>However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right.</p> <p>I click on Windows|Preferences and type in "wrap" and get:</p> <pre><code>- Java | Code Style | Formatter - Java | Editor | Typing - Web and XML | CSS Files | Source </code></pre> <p>I've tried changing the "wrap automatically" that I found there and the "Line width" to 72 but they had no effect.</p> <p>How can I get word wrap to work in Eclipse PDT for PHP files?</p>
[ { "answer_id": 15783091, "author": "Fedir RYKHTIK", "author_id": 634275, "author_profile": "https://Stackoverflow.com/users/634275", "pm_score": 4, "selected": false, "text": "-clean" }, { "answer_id": 37103016, "author": "KrisWebDev", "author_id": 2227298, "author_pr...
2008/09/18
[ "https://Stackoverflow.com/questions/97663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
97,683
<p>Here is a snippet of CSS that I need explained:</p> <pre class="lang-css prettyprint-override"><code>#section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } </code></pre> <p>Ok so it's absolute positioning of an image, obviously.</p> <ol> <li>top is like padding from the top, right?</li> <li>what does left 50% do?</li> <li>why is the left margin at -445px? </li> </ol> <p><b>Update:</b> width is 860px. The actual image is 100x100 if that makes a difference??</p>
[ { "answer_id": 97747, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https://Stackoverflow.com/users/6615", "pm_score": 3, "selected": true, "text": "top: 50%\nmargin-top: -(height/2)px;\n" }, { "answer_id": 97761, "author": "Dan", "author_id": 17121, ...
2008/09/18
[ "https://Stackoverflow.com/questions/97683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
97,694
<p>I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? </p> <p>So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and a } will shift back 2 spaces?</p>
[ { "answer_id": 97723, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 8, "selected": true, "text": ":set autoindent\n:set cindent\n" }, { "answer_id": 97775, "author": "Commodore Jaeger", "author_id": 4659, ...
2008/09/18
[ "https://Stackoverflow.com/questions/97694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
97,732
<p>I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this:</p> <p>&lt; Page 1 ><br> &nbsp;&nbsp;&lt; MyPage / ><br> &nbsp;&nbsp;...<br> &lt; /Page 1 ><br><br> &lt; Page 2 ><br> &nbsp;&nbsp;&lt; MyPage / ><br> &nbsp;&nbsp;...<br> &lt; /Page 2 ><br><br> &lt; Page 3 ><br> &nbsp;&nbsp;&lt; MyPage / ><br> &nbsp;&nbsp;...<br> &lt; /Page 3 ><br></p> <p>In doing so I received the following error:</p> <p>Multiple nodes with the same URL 'Default.aspx' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs.</p> <p>I read online that the SiteMapNodes are stored as a dictionary internally which explains why I can't use the same URL. In any case, I'm just looking for alternate ways to go about solving this problem. Any suggestions would be greatly appreciated.</p>
[ { "answer_id": 202251, "author": "Beaker", "author_id": 8673, "author_profile": "https://Stackoverflow.com/users/8673", "pm_score": 0, "selected": false, "text": "<siteMapNode url=\"ListAll.aspx\">\n <siteMapNode url =\"Detail.aspx?node=all\" />\n</siteMapNode>\n<siteMapNode url=\"ListM...
2008/09/18
[ "https://Stackoverflow.com/questions/97732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16830/" ]
97,762
<p>I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click?</p> <p>The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by position so that the algorithm is less than O(n), say, O(log n) or O(sqrt(n))?</p>
[ { "answer_id": 97806, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 4, "selected": true, "text": " int id = bitmap_getpixel (mouse.x, mouse.y)\n if (id != -1)\n {\n hit_rectange (id);\n }\n else\n {\n ...
2008/09/18
[ "https://Stackoverflow.com/questions/97762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10293/" ]
97,781
<p>Part of a new product I have been assigned to work on involves server-side conversion of the 'common' video formats to something that Flash can play.</p> <p>As far as I know, my only option is to convert to FLV. I have been giving ffmpeg a go around, but I'm finding a few WMV files that come out with garbled sound (I've tried playing with the audio rates).</p> <p>Are there any other 'good' CLI converters for Linux? Or are there other video formats that Flash can play?</p>
[ { "answer_id": 97799, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 5, "selected": true, "text": "FLV with AAC or MP3 audio, and FLV1 (Sorenson Spark H.263), VP6, or H.264 video.\nMP4 with AAC or MP3 audio, and H.264 ...
2008/09/18
[ "https://Stackoverflow.com/questions/97781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2192/" ]
97,816
<p>I want to know if people here typically disable SELinux on installations where it is on by default? If so can you explain why, what kind of system it was, etc?</p> <p>I'd like to get as many opinions on this as possible.</p>
[ { "answer_id": 97881, "author": "hoyhoy", "author_id": 3499, "author_profile": "https://Stackoverflow.com/users/3499", "pm_score": 2, "selected": false, "text": "chcon -R -h -t httpd_sys_content_t /var/www/html \n" }, { "answer_id": 98219, "author": "mike511", "author_id"...
2008/09/18
[ "https://Stackoverflow.com/questions/97816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12098/" ]
97,850
<p>For my school work, I do a lot of switching computers (from labs to my laptop to the library). I'd kind of like to put this code under some kind of version control. Of course the problem is that I can't always install additional software on the computers I use. Is there any kind of version control system that I can keep on a thumb drive? I have a 2GB drive to put this on, but I can get a bigger one if necessary.</p> <p>The projects I'm doing aren't especially big FYI.</p> <p><strong>EDIT:</strong> This needs to work under windows.</p> <p><strong>EDIT II:</strong> Bazaar ended up being what I chose. It's even better if you go with TortoiseBzr.</p>
[ { "answer_id": 97922, "author": "Milan Babuškov", "author_id": 14690, "author_profile": "https://Stackoverflow.com/users/14690", "pm_score": 4, "selected": false, "text": "git-init\ngit add .\ngit commit -m \"Done\"\n" }, { "answer_id": 97955, "author": "Jonny Buchanan", ...
2008/09/18
[ "https://Stackoverflow.com/questions/97850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
97,875
<p>I need a way to recursively delete a folder and its children.</p> <p>Is there a prebuilt tool for this, or do I need to write one?</p> <p><code>DEL /S</code> doesn't delete directories.</p> <p><code>DELTREE</code> was removed from Windows 2000+</p>
[ { "answer_id": 97895, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "del /s foldername\n" }, { "answer_id": 97896, "author": "Duncan Smart", "author_id": 1278, "author_prof...
2008/09/18
[ "https://Stackoverflow.com/questions/97875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
97,913
<p>What are your best usability testing tips? I need quick &amp; cheap. </p>
[ { "answer_id": 98664, "author": "therealhoff", "author_id": 18175, "author_profile": "https://Stackoverflow.com/users/18175", "pm_score": 3, "selected": false, "text": "The archetypal non-technical user, one's elderly and scatterbrained maiden aunt. Invoked in discussions of usability fo...
2008/09/18
[ "https://Stackoverflow.com/questions/97913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17398/" ]
97,948
<p>What is <code>std::pair</code> for, why would I use it, and what benefits does <code>boost::compressed_pair</code> bring?</p>
[ { "answer_id": 97968, "author": "John Mulder", "author_id": 2242, "author_profile": "https://Stackoverflow.com/users/2242", "pm_score": 2, "selected": false, "text": "std::map<>\nstd::multimap<> \n" }, { "answer_id": 97973, "author": "user17481", "author_id": 17481, "...
2008/09/18
[ "https://Stackoverflow.com/questions/97948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18352/" ]
97,962
<p>A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submission has come from the same user.</p> <p>One thing we've noticed is users double-clicking the form submission button. I need to de-bounce these clicks, and prevent a second form submission.<br> My approach (using Prototype) places an <code>onSubmit</code> on the form that calls the following function which hides the form submission button and displays a "loading..." <code>div</code>.</p> <pre><code>function disableSubmit(id1, id2) { $(id1).style.display = 'none'; $(id2).style.display = 'inline'; } </code></pre> <p>The problem I've found with this approach is that if I use an animated gif in the "loading..." <code>div</code>, it loads fine but doesn't animate while the form is submitting.</p> <p>Is there a better way to do this de-bouncing and continue to show animation on the page while waiting for the form result to (finally) load? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
[ { "answer_id": 99366, "author": "matt lohkamp", "author_id": 14026, "author_profile": "https://Stackoverflow.com/users/14026", "pm_score": 3, "selected": true, "text": "$('input[type=\"submit\"]').click(function(event){\n event.preventDefault();\n this.click(null);\n});\n" }, { "...
2008/09/18
[ "https://Stackoverflow.com/questions/97962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10788/" ]
97,971
<p>Having programmed through emacs and vi for years and years at this point, I have heard that using an IDE is a very good way of becoming more efficient.</p> <p>To that end, I have decided to try using Eclipse for a lot of coding and seeing how I get on.</p> <p>Are there any suggestions for easing the transition over to an IDE. Obviously, some will think none of this is worth the bother, but I think with Eclipse allowing emacs-style key bindings and having code completion and in-built debugging, I reckon it is well worth trying to move over to a more feature-rich environment for the bulk of my development worth.</p> <p>So what suggestions do you have for easing the transition?</p>
[ { "answer_id": 98151, "author": "Desty", "author_id": 2161072, "author_profile": "https://Stackoverflow.com/users/2161072", "pm_score": 3, "selected": true, "text": "String messageXml = in.read();\nMessage response = messageParser.parse(messageXml);\nreturn response;" } ]
2008/09/18
[ "https://Stackoverflow.com/questions/97971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
97,976
<p>I have a datagridview that accepts a list(of myObject) as a datasource. I want to add a new row to the datagrid to add to the database. I get this done by getting the list... adding a blank myObject to the list and then reseting the datasource. I now want to set the focus to the second cell in the new row.</p> <p>To CLARIFY i am trying to set the focus</p>
[ { "answer_id": 97986, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 0, "selected": false, "text": "Me.dataEvidence.SelectedRows\n" }, { "answer_id": 1213548, "author": "Michael Todd", "author_id": 16623, "aut...
2008/09/18
[ "https://Stackoverflow.com/questions/97976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16820/" ]
97,982
<p>A Google search for "site:example.com" will tell you the number of pages of example.com that are currently in Google's index. Is it possible to find out how this number has changed over time?</p>
[ { "answer_id": 172539, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 0, "selected": false, "text": "\\d+(?=</b> from <b>domain\\.net</b>)\n" } ]
2008/09/18
[ "https://Stackoverflow.com/questions/97982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18333/" ]
97,984
<p>When a PHP application makes a database connection it of course generally needs to pass a login and password. If I'm using a single, minimum-permission login for my application, then the PHP needs to know that login and password somewhere. What is the best way to secure that password? It seems like just writing it in the PHP code isn't a good idea.</p>
[ { "answer_id": 98120, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 3, "selected": false, "text": "~/.pgpass" }, { "answer_id": 101696, "author": "e-satis", "author_id": 9951, "author_profile": "https://Stack...
2008/09/18
[ "https://Stackoverflow.com/questions/97984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18359/" ]
97,987
<p>What's the best practice for using a <code>switch</code> statement vs using an <code>if</code> statement for 30 <code>unsigned</code> enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. I've abstracted the snippet so don't hate me for the naming conventions.</p> <p><code>switch</code> statement:</p> <pre><code>// numError is an error enumeration type, with 0 being the non-error case // fire_special_event() is a stub method for the shared processing switch (numError) { case ERROR_01 : // intentional fall-through case ERROR_07 : // intentional fall-through case ERROR_0A : // intentional fall-through case ERROR_10 : // intentional fall-through case ERROR_15 : // intentional fall-through case ERROR_16 : // intentional fall-through case ERROR_20 : { fire_special_event(); } break; default: { // error codes that require no additional action } break; } </code></pre> <p><code>if</code> statement:</p> <pre><code>if ((ERROR_01 == numError) || (ERROR_07 == numError) || (ERROR_0A == numError) || (ERROR_10 == numError) || (ERROR_15 == numError) || (ERROR_16 == numError) || (ERROR_20 == numError)) { fire_special_event(); } </code></pre>
[ { "answer_id": 98011, "author": "William Keller", "author_id": 17095, "author_profile": "https://Stackoverflow.com/users/17095", "pm_score": 0, "selected": false, "text": "if" }, { "answer_id": 98036, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https...
2008/09/18
[ "https://Stackoverflow.com/questions/97987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8883/" ]
98,033
<p>Several Linq.Enumerable functions take an <code>IEqualityComparer&lt;T&gt;</code>. Is there a convenient wrapper class that adapts a <code>delegate(T,T)=&gt;bool</code> to implement <code>IEqualityComparer&lt;T&gt;</code>? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but I'd like to know if there is an out-of-the-box solution.</p> <p>Specifically, I want to do set operations on <code>Dictionary</code>s, using only the Keys to define membership (while retaining the values according to different rules).</p>
[ { "answer_id": 98119, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 6, "selected": false, "text": "class Comparer<T>: IEqualityComparer<T>\n{\n private readonly Func<T, T, bool> _comparer;\n\n public Comparer(Func<T, T, bo...
2008/09/18
[ "https://Stackoverflow.com/questions/98033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9990/" ]
98,096
<p>I've seen some people use <code>EXISTS (SELECT 1 FROM ...)</code> rather than <code>EXISTS (SELECT id FROM ...)</code> as an optimization--rather than looking up and returning a value, SQL Server can simply return the literal it was given.</p> <p>Is <code>SELECT(1)</code> always faster? Would Selecting a value from the table require work that Selecting a literal would avoid?</p>
[ { "answer_id": 99340, "author": "jalbert", "author_id": 1360388, "author_profile": "https://Stackoverflow.com/users/1360388", "pm_score": 3, "selected": false, "text": "SELECT 1" }, { "answer_id": 115881, "author": "Community", "author_id": -1, "author_profile": "http...
2008/09/18
[ "https://Stackoverflow.com/questions/98096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18347/" ]
98,098
<p>Is the a VS2005 C++ compiler flag like the Xmx???M java flag so I can limit the heap size of my application running on Windows. </p> <p>I need to limit the heap size so I can fill the memory to find out the current free memory. (The code also runs on an embedded system where this is the best method to get the memory usage)</p>
[ { "answer_id": 98217, "author": "jfs", "author_id": 6223, "author_profile": "https://Stackoverflow.com/users/6223", "pm_score": 0, "selected": false, "text": "malloc()" }, { "answer_id": 641887, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https:...
2008/09/18
[ "https://Stackoverflow.com/questions/98098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2731698/" ]
98,124
<p>Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?</p> <pre><code>myDate = new Date(); year = myDate.getYear(); </code></pre> <p>year = 108?</p>
[ { "answer_id": 98136, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 2, "selected": false, "text": "date.getFullYear()" }, { "answer_id": 98162, "author": "ConroyP", "author_id": 2287, "author_profile": "htt...
2008/09/18
[ "https://Stackoverflow.com/questions/98124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
98,134
<p>I'm using a build script that calls Wise to create some install files. The problem is that the Wise license only allows it to be run under one particular user account, which is not the same account that my build script will run under. I know Windows has the <strong>runas</strong> command but this won't work for an automated script as there is no way to enter the password via the command line.</p>
[ { "answer_id": 98323, "author": "Jeffrey Vanneste", "author_id": 5497, "author_profile": "https://Stackoverflow.com/users/5497", "pm_score": 2, "selected": false, "text": "CPAU -u user [-p password] -ex \"WhatToRun\" [switches]\n" } ]
2008/09/18
[ "https://Stackoverflow.com/questions/98134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
98,135
<p>I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO_SETTINGS_MODULE environment variable?</p> <p>If I run the following code:</p> <pre><code>&gt;&gt;&gt; import django.template &gt;&gt;&gt; from django.template import Template, Context &gt;&gt;&gt; t = Template('My name is {{ my_name }}.') </code></pre> <p>I get:</p> <pre><code>ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. </code></pre>
[ { "answer_id": 98146, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "settings.py" }, { "answer_id": 98150, "author": "William Keller", "author_id": 17095, "author_profi...
2008/09/18
[ "https://Stackoverflow.com/questions/98135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
98,153
<p>I've found the standard hashing function on VS2005 is painfully slow when trying to achieve high performance look ups. What are some good examples of fast and efficient hashing algorithms that should void most collisions?</p>
[ { "answer_id": 98179, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 4, "selected": false, "text": "/* magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ */\nstatic const size_t InitialFNV = 2166136261U;\nst...
2008/09/18
[ "https://Stackoverflow.com/questions/98153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13646/" ]
98,205
<p>I'm gearing up to do some Ajax style client-side JavaScript code in the near future, and I've heard rave reviews of jQuery when it comes to this realm. What I'm wondering is:</p> <ul> <li><strong>What are all the cross-browser JavaScript libraries out there?</strong></li> </ul> <p>What is the experience using them?</p>
[ { "answer_id": 11110702, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Element::classList" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145/" ]
98,212
<p>I am wondering what methods people are using for validating check boxes in ASP.NET MVC (both client and server side).</p> <p>I am using JQuery currently for client side validation but I am curious what methods people are using, ideally with the least amount of fuss (I am looking for a new solution).</p> <p>I should mention that I am currently using MVC Preview 4, and while I could upgrade to MVC Preview 5 if there is no elegant solution in MVC Preview 4, I would prefer not to at this stage just for compatibility purposes with other developers and existing solutions.</p> <p>Note, I have seen these related posts:</p> <ul> <li><a href="https://stackoverflow.com/questions/10300/validating-posted-form-data-in-the-aspnet-mvc-framework">Validating posted form data in the ASP.NET MVC framework</a></li> <li><a href="https://stackoverflow.com/questions/16747/whats-the-best-way-to-implement-field-validation-using-aspnet-mvc">What’s the best way to implement field validation using ASP.NET MVC?</a></li> <li><a href="https://stackoverflow.com/questions/61456/mvcnet-jquery-validation">MVC.net JQuery Validation</a></li> </ul>
[ { "answer_id": 98227, "author": "Thomas R", "author_id": 2192, "author_profile": "https://Stackoverflow.com/users/2192", "pm_score": 0, "selected": false, "text": "<?php echo isset($_POST['checkbox_name']) ? 'checked' : 'not checked'; ?>\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
98,224
<p>After downloading files from a remote UNIX FTP server, you want to verify that you have downloaded all the files correctly. Minimal you will get information similar to "dir /s" command in Windows command prompt. The FTP client runs on Windows.</p>
[ { "answer_id": 4414456, "author": "jamesmar", "author_id": 538522, "author_profile": "https://Stackoverflow.com/users/538522", "pm_score": 3, "selected": false, "text": "ls -lR\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13584/" ]
98,225
<p>Any other tweaks for making emacs as vim-like as possible would be appreciated as well.</p> <p>Addendum: The main reason I don't just use vim is that I love how emacs lets you open a file in two different frames [ADDED: sorry, this was confusing: I mean separate <em>windows</em>, which emacs calls "frames"]. It's like making a vertical split but I don't have to have one enormous window.</p>
[ { "answer_id": 482859, "author": "Sébastien RoccaSerra", "author_id": 2797, "author_profile": "https://Stackoverflow.com/users/2797", "pm_score": 2, "selected": false, "text": "(define-key viper-vi-global-user-map [(delete)] 'delete-char)\n(define-key viper-vi-global-user-map \"/\" 'isea...
2008/09/19
[ "https://Stackoverflow.com/questions/98225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
98,242
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="https://stackoverflow.com/questions/6457130/pre-post-increment-operator-behavior-in-c-c-java-c-sharp">Pre &amp; post increment operator behavior in C, C++, Java, &amp; C#</a></p> </blockquote> <p>Here is a test case:</p> <pre><code> void foo(int i, int j) { printf("%d %d", i, j); } ... test = 0; foo(test++, test); </code></pre> <p>I would expect to get a &quot;0 1&quot; output, but I get &quot;0 0&quot; What gives??</p>
[ { "answer_id": 98263, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 4, "selected": false, "text": "mov ecx, DWORD PTR _i$[ebp]\npush ecx\nmov edx, DWORD PTR tv66[ebp]\npush edx\ncall _foo\nadd esp, 8\nmov eax,...
2008/09/19
[ "https://Stackoverflow.com/questions/98242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
98,274
<p>Is it possible to integrate SSRS reports to the webforms..an example will be enough to keep me moving. </p>
[ { "answer_id": 98344, "author": "John Christensen", "author_id": 1194, "author_profile": "https://Stackoverflow.com/users/1194", "pm_score": 3, "selected": false, "text": "public void ProcessRequest(HttpContext context)\n{\n string report = null;\n int managerId = -1;\n int plan...
2008/09/19
[ "https://Stackoverflow.com/questions/98274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
98,310
<p>(I don't want to hear about how crazy I am to want that! :)</p> <p>Focus-follows-mouse is also known as point-to-focus, pointer focus, and (in some implementations) sloppy focus. [Add other terms that will make this more searchable!] X-mouse</p>
[ { "answer_id": 98331, "author": "Clint Ecker", "author_id": 13668, "author_profile": "https://Stackoverflow.com/users/13668", "pm_score": 6, "selected": false, "text": "defaults write com.apple.Terminal FocusFollowsMouse -bool true\n" }, { "answer_id": 98357, "author": "dreev...
2008/09/19
[ "https://Stackoverflow.com/questions/98310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
98,320
<p>My model layer is being used by a handful of different projects and I'd like to use a single XML Spring Configuration file for the model regardless of which project is using it.</p> <p>My question is: Since not all beans are used in all projects am I wasting resources to any significant amount if there not being instantiated? I'm not too sure how lazy Spring is about loading them since it's never been an issue until now.</p> <p>Any ideas?</p>
[ { "answer_id": 98544, "author": "MetroidFan2002", "author_id": 8026, "author_profile": "https://Stackoverflow.com/users/8026", "pm_score": 4, "selected": true, "text": "<bean id=\"lazy\" class=\"com.foo.ExpensiveToCreateBean\" lazy-init=\"true\"/>\n" }, { "answer_id": 150210, ...
2008/09/19
[ "https://Stackoverflow.com/questions/98320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
98,340
<p>An example of unspecified behavior in the C language is the order of evaluation of arguments to a function. It might be left to right or right to left, you just don't know. This would affect how <code>foo(c++, c)</code> or <code>foo(++c, c)</code> gets evaluated.</p> <p>What other unspecified behavior is there that can surprise the unaware programmer?</p>
[ { "answer_id": 98356, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 7, "selected": true, "text": "float funky_float_abs (float a)\n{\n unsigned int temp = *(unsigned int *)&a;\n temp &= 0x7fffffff;\n return *(f...
2008/09/19
[ "https://Stackoverflow.com/questions/98340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
98,359
<p>How do you implement the fastest possible <a href="http://en.wikipedia.org/wiki/Gaussian_blur" rel="noreferrer">Gaussian blur</a> algorithm?</p> <p>I am going to implement it in Java, so <a href="http://en.wikipedia.org/wiki/Graphics_processing_unit" rel="noreferrer">GPU</a> solutions are ruled out. My application, <a href="http://planetGenesis.sourceforge.net" rel="noreferrer">planetGenesis</a>, is cross platform, so I don't want <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">JNI</a>.</p>
[ { "answer_id": 1377012, "author": "Paul Harrison", "author_id": 102709, "author_profile": "https://Stackoverflow.com/users/102709", "pm_score": 2, "selected": false, "text": "y(i) = y(i-1) + x(i)\n" }, { "answer_id": 3712073, "author": "Ben McIntosh", "author_id": 50859, ...
2008/09/19
[ "https://Stackoverflow.com/questions/98359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18390/" ]
98,376
<p>I need to store some simple properties in a file and access them from Ruby.</p> <p>I absolutely love the .properties file format that is the standard for such things in Java (using the java.util.Properties class)... it is simple, easy to use and easy to read.</p> <p>So, is there a Ruby class somewhere that will let me load up some key value pairs from a file like that without a lot of effort?</p> <p>I don't want to use XML, so please don't suggest REXML (my purpose does not warrant the "angle bracket tax").</p> <p>I have considered rolling my own solution... it would probably be about 5-10 lines of code tops, but I would still rather use an existing library (if it is essentially a hash built from a file)... as that would bring it down to 1 line....</p> <hr> <p>UPDATE: It's actually a straight Ruby app, not rails, but I think YAML will do nicely (it was in the back of my mind, but I had forgotten about it... have seen but never used as of yet), thanks everyone!</p>
[ { "answer_id": 98415, "author": "Ryan Bigg", "author_id": 15245, "author_profile": "https://Stackoverflow.com/users/15245", "pm_score": 6, "selected": true, "text": "YAML::Load(File.open(\"file\"))" }, { "answer_id": 99032, "author": "Dan Harper", "author_id": 14530, ...
2008/09/19
[ "https://Stackoverflow.com/questions/98376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
98,394
<p>I looked for the name of a procedure, which applies a tree structure of procedures to a tree structure of data, yielding a tree structure of results - all three trees having the same structure. </p> <p>Such a procedure might have the signature: </p> <pre>(map-tree data functree)</pre> <p>Its return value would be the result of elementwise application of functree's elements on the corresponding data elements. </p> <p>Examples (assuming that the procedure is called map-tree): </p> <p>Example 1: </p> <pre>(define *2 (lambda (x) (* 2 x))) ; and similar definitions for *3 and *5 (map-tree '(100 (10 1)) '(*2 (*3 *5)))</pre> <p>would yield the result <pre>(200 (30 5))</pre></p> <p>Example 2: </p> <pre>(map-tree '(((aa . ab) (bb . bc)) (cc . (cd . ce))) '((car cdr) cadr))</pre> <p>yields the result <pre>((aa bc) cd)</pre></p> <p>However I did not find such a function in the SLIB documentation, which I consulted. </p> <p>Does such a procedure already exist?<br> If not, what would be a suitable name for the procedure, and how would you order its arguments?</p>
[ { "answer_id": 98520, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": true, "text": "map-traversing" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11886/" ]
98,400
<p>I've got a git-svn clone of an svn repo, and I want to encourage my colleagues to look at git as an option. The problem is that cloning the repo out of svn takes 3 days, but cloning from my git instance takes 10 minutes.</p> <p>I've got a script that will allow people to clone my git repo and re-point it at the original SVN, but it requires knowing how I set some of my config values. I'd prefer the script be able to pull those values over the wire.</p>
[ { "answer_id": 107740, "author": "Pat Notz", "author_id": 825, "author_profile": "https://Stackoverflow.com/users/825", "pm_score": 2, "selected": false, "text": "\ngit config -f/path/to/your/repo/.git/config --get ...\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9700/" ]
98,426
<p>I am working on an application that is about 250,000 lines of code. I'm currently the only developer working on this application that was originally built in .NET 1.1. Pervasive throughout is a class that inherits from CollectionBase. All database collections inherit from this class. I am considering refactoring to inherit from the generic collection List instead. Needless to say, Martin Fowler's Refactoring book has no suggestions. Should I attempt this refactor? If so, what is the best way to tackle this refactor?</p> <p>And yes, there are unit tests throughout, but no QA team.</p>
[ { "answer_id": 99555, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "Collection<T>" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18372/" ]
98,449
<p>How would I go about converting an address or city to a latitude/longitude? Are there commercial outfits I can "rent" this service from? This would be used in a commercial desktop application on a Windows PC with fulltime internet access.</p>
[ { "answer_id": 25066314, "author": "MilanNz", "author_id": 2922851, "author_profile": "https://Stackoverflow.com/users/2922851", "pm_score": 2, "selected": false, "text": " public static String GET(String url) throws Exception {//GET Method\n String result = null;\n InputSt...
2008/09/19
[ "https://Stackoverflow.com/questions/98449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17259/" ]
98,454
<p>There are a number of other questions related to this topic:</p> <ol> <li><s><a href="https://stackoverflow.com/questions/5214/whats-a-good-standard-code-layout-for-a-php-application">Whats a good standard code layout for a php application</a></s> (deleted)</li> <li><a href="https://stackoverflow.com/questions/7596/how-to-structure-a-java-application-in-other-words-where-do-i-put-my-classes">How to structure a java application, in other words: where do I put my classes?</a></li> <li><a href="https://stackoverflow.com/questions/41513/recommended-source-control-directory-structure">Recommended Source Control Directory Structure?</a> </li> <li><a href="https://stackoverflow.com/questions/16829/structure-of-projects-in-version-control">Structure of Projects in Version Control</a></li> </ol> <p>I could not find any specific to VSTF, which has some capabilities like Team Build, integrated Unit Testing, etc. I'm wondering if these capabilities lead to a slightly different source layout recommendation.</p> <p>Please post example of high level directory structures that you have had good luck with an explain why you like them. I'll let people vote on a "best" approach and I'll award the answer in a few days.</p>
[ { "answer_id": 25066314, "author": "MilanNz", "author_id": 2922851, "author_profile": "https://Stackoverflow.com/users/2922851", "pm_score": 2, "selected": false, "text": " public static String GET(String url) throws Exception {//GET Method\n String result = null;\n InputSt...
2008/09/19
[ "https://Stackoverflow.com/questions/98454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
98,479
<p>What is the maximum value of an int in ChucK? Is there a symbolic constant for it?</p>
[ { "answer_id": 98500, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "int" }, { "answer_id": 98865, "author": "Paul Reiners", "author_id": 7648, "author_profile": "https...
2008/09/19
[ "https://Stackoverflow.com/questions/98479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7648/" ]
98,484
<p>I have a huge file, where I have to insert certain characters at a specific location. What is the easiest way to do that in C# without rewriting the whole file again.</p>
[ { "answer_id": 469174, "author": "Scott Marlowe", "author_id": 1683, "author_profile": "https://Stackoverflow.com/users/1683", "pm_score": 1, "selected": false, "text": "using (BinaryWriter bw = new BinaryWriter (File.Open (strFile, FileMode.Open)))\n{\n string strNewData = \"this is ...
2008/09/19
[ "https://Stackoverflow.com/questions/98484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337/" ]
98,497
<p>Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:</p> <pre><code>function generateAccNo() generate an account number between 100,000,000 and 999,999,999 if the account number already exists in the DB call generateAccNo() /* recursive call */ else return new accout number end if end function </code></pre> <p>The function seems to be working well, however I am a bit worried about the recursive call. </p> <p>Will this cause any memory leaks (PHP 5 under apache)?</p> <p>Is this an acceptable way to tackle this problem?</p> <p>Thanks for your input.</p>
[ { "answer_id": 98513, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 0, "selected": false, "text": "function generateAccNo()\n\n while (true) { \n\n generate an account number between 100,000,000 and 999,999,999\...
2008/09/19
[ "https://Stackoverflow.com/questions/98497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
98,559
<pre><code>uint color; bool parsedhex = uint.TryParse(TextBox1.Text, out color); //where Text is of the form 0xFF0000 if(parsedhex) //... </code></pre> <p>doesn't work. What am i doing wrong?</p>
[ { "answer_id": 98572, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 8, "selected": true, "text": "Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment\n" }, { "answer_id": 98588, "author":...
2008/09/19
[ "https://Stackoverflow.com/questions/98559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1748529/" ]
98,586
<p>I'm looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down miserably here as it checks for locale changes on every call to isdigit(). Our current best is derived from the best of perl + tcl's atof implementation, and outperforms msvcrt.dll's atof by an order of magnitude. I want to do better, but am out of ideas. The BCD related x86 instructions seemed promising, but I couldn't get it to outperform the perl/tcl C code. Can any SO'ers dig up a link to the best out there? Non x86 assembly based solutions are also welcome.</p> <p>Clarifications based upon initial answers:</p> <p>Inaccuracies of ~2 ulp are fine for this application.<br> The numbers to be converted will arrive in ascii messages over the network in small batches and our application needs to convert them in the lowest latency possible.</p>
[ { "answer_id": 1638340, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "__forceinline" }, { "answer_id": 10425062, "author": "Ira Baxter", "author_id": 120163, "author_profile":...
2008/09/19
[ "https://Stackoverflow.com/questions/98586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6996/" ]
98,597
<p>I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).</p> <p>So, does anyone have any good AHK macros to share?</p>
[ { "answer_id": 100648, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 4, "selected": false, "text": "SetTitleMatchMode RegEx ;\n; Stuff to do when Windows Explorer is open\n;\n#IfWinActive ahk_class ExploreWClass|Cabine...
2008/09/19
[ "https://Stackoverflow.com/questions/98597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10934/" ]
98,606
<p>What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse! <br /></p> <p><strong>One</strong> per answer please.</p>
[ { "answer_id": 98629, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 5, "selected": false, "text": "Collection<string>" }, { "answer_id": 98779, "author": "rbrayb", "author_id": 9922, "author_profi...
2008/09/19
[ "https://Stackoverflow.com/questions/98606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13791/" ]
98,610
<p>By default, Eclipse won't show my .htaccess file that I maintain in my project. It just shows an empty folder in the Package Viewer tree. How can I get it to show up? No obvious preferences.</p>
[ { "answer_id": 98634, "author": "scubabbl", "author_id": 9450, "author_profile": "https://Stackoverflow.com/users/9450", "pm_score": 11, "selected": true, "text": "Package Explorer -> View Menu -> Filters -> uncheck .* resources" }, { "answer_id": 26042251, "author": "kakhkAt...
2008/09/19
[ "https://Stackoverflow.com/questions/98610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4223/" ]
98,622
<p>In VisualStudio (Pro 2008), I have just noticed some inconsistent behaviour and wondered if there was any logical reasoning behind it</p> <p>In a WinForms project, if I use the line</p> <pre><code>if(myComboBox.Items[i] == myObject) </code></pre> <p>I get a compiler warning that I might get 'Possible unintended references' as I am comparing type object to type MyObject. Fair enough.</p> <p>However, if I instead use an interface to compare against:</p> <pre><code>if(myComboBox.Items[i] == iMyInterface) </code></pre> <p>the compile warning goes away.</p> <p>Can anyone think if there is any logical reason why this should happen, or just an artifact of the compiler not to check interfaces for comparison warnings. Any thoughts?</p> <p><strong>EDIT</strong> In my example, the combobox was bound to a List, but that list was generated using <code>list&lt;IMyInterface&gt;.Cast&lt;MyObject&gt;().ToList&lt;MyObject&gt;()</code></p> <p>Its as if the compiler is only taking still assuming I am binding to the List of IMyInterface.</p> <p>(Object and Interface methods have been changed to protect the innocent)</p>
[ { "answer_id": 98708, "author": "Jason Stevenson", "author_id": 13368, "author_profile": "https://Stackoverflow.com/users/13368", "pm_score": 0, "selected": false, "text": "myComboBox.DataSource = Collection<Car>;\n" }, { "answer_id": 171045, "author": "Danny Tuppeny", "a...
2008/09/19
[ "https://Stackoverflow.com/questions/98622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
98,650
<p>When asking about <a href="https://stackoverflow.com/questions/98340/what-are-the-common-undefinedunspecified-behavior-for-c-that-you-run-into">common undefined behavior in C</a>, people sometimes refer to the strict aliasing rule.<br> What are they talking about?</p>
[ { "answer_id": 98702, "author": "Niall", "author_id": 6049, "author_profile": "https://Stackoverflow.com/users/6049", "pm_score": 8, "selected": false, "text": "int*" }, { "answer_id": 99010, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackover...
2008/09/19
[ "https://Stackoverflow.com/questions/98650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
98,687
<p>I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of framework. </p> <p>The solution works great except that every time a new request is made, I open a new connection via MySQLdb.connect. </p> <p>What is the best "drop in" solution to switch this over to using connection pooling in python? I am imagining something like the commons DBCP solution for Java. </p> <p>The process is long running and has many threads that need to make requests, but not all at the same time... specifically they do quite a lot of work before brief bursts of writing out a chunk of their results.</p> <p>Edited to add: After some more searching I found <a href="http://furius.ca/antiorm/" rel="noreferrer">anitpool.py</a> which looks decent, but as I'm relatively new to python I guess I just want to make sure I'm not missing a more obvious/more idiomatic/better solution. </p>
[ { "answer_id": 98703, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 4, "selected": false, "text": "import sqlalchemy.pool as pool\nimport MySQLdb as mysql\nmysql = pool.manage(mysql)\n" }, { "answer_id": 24741694, ...
2008/09/19
[ "https://Stackoverflow.com/questions/98687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
98,693
<p>First of all, I don't need a textual comparison so Beyond Compare doesn't do what I need.</p> <p>I'm looking for a util that can report on the differences between two files, at the byte level. Bare minimum is the need to see the percentage change in the file, or a report on affected bytes/sectors. </p> <p>Is there anything available to save me the trouble of doing this myself?</p>
[ { "answer_id": 98723, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 2, "selected": false, "text": "hexdump file1 > file1.tmp\nhexdump file2 > file2.tmp\ndiff file1.tmp file2.tmp\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13132/" ]
98,705
<p>I understand that the function is not allowed to change the state of the object, but I thought I read somewhere that the compiler was allowed to assume that if the function was called with the same arguments, it would return the same value and thus could reuse a cached value if it was available. e.g.</p> <pre><code>class object { int get_value(int n) const { ... } ... object x; int a = x.get_value(1); ... int b = x.get_value(1); </code></pre> <p>then the compiler could optimize the second call away and either use the value in a register or simply do <code>b = a;</code></p> <p>Is this true?</p>
[ { "answer_id": 98762, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "const" }, { "answer_id": 98787, "author": "blackwing", "author_id": 9107, "author_profile": "https://Stac...
2008/09/19
[ "https://Stackoverflow.com/questions/98705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4086/" ]
98,739
<p>Should entities have behavior? or not?</p> <p>Why or why not?</p> <p>If not, does that violate Encapsulation?</p>
[ { "answer_id": 5527174, "author": "Eduard", "author_id": 689450, "author_profile": "https://Stackoverflow.com/users/689450", "pm_score": 3, "selected": false, "text": "book.Write(); \nbook.Print(); \nbook.Publish(); \nbook.Buy(); \nbook.Open(); \nbook.Read(); \nbook.Highlight(); ...
2008/09/19
[ "https://Stackoverflow.com/questions/98739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18175/" ]
98,768
<p>I can understand that imposing a minimum length on passwords makes a lot of sense (to save users from themselves), but my <strong>bank</strong> has a requirement that passwords are between 6 and 8 characters long, and I started wondering...</p> <ul> <li>Wouldn't this just make it easier for brute force attacks? (Bad)</li> <li>Does this imply that my password is being stored unencrypted? (Bad)</li> </ul> <p>If someone with (hopefully) some good IT security professionals working for them are imposing a max password length, should I think about doing similar? What are the pros/cons of this?</p>
[ { "answer_id": 72495962, "author": "dewd", "author_id": 2298108, "author_profile": "https://Stackoverflow.com/users/2298108", "pm_score": 0, "selected": false, "text": "password_hash()" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
98,774
<p>I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this.</p> <pre><code>// Quick, and very dirty System.IO.File.WriteAllBytes(filename, new byte[f.Length]); </code></pre> <p>It works, atleast until you download a file that is several hundred MB's, or potentially even GB's and you throw Windows into a thrashing frenzy if not totally wipe out the pagefile and kill your systems memory altogether. Oops.</p> <p>So, with a little more enlightenment, I set out with the following algorithm.</p> <pre><code>using (FileStream outFile = System.IO.File.Create(filename)) { // 4194304 = 4MB; loops from 1 block in so that we leave the loop one // block short byte[] buff = new byte[4194304]; for (int i = buff.Length; i &lt; f.Length; i += buff.Length) { outFile.Write(buff, 0, buff.Length); } outFile.Write(buff, 0, f.Length % buff.Length); } </code></pre> <p>This works, well even, and doesn't suffer the crippling memory problem of the last solution. It's still slow though, especially on older hardware since it writes out (potentially GB's worth of) data out to the disk.</p> <p>The question is this: Is there a better way of accomplishing the same thing? Is there a way of telling Windows to create a file of x size and simply allocate the space on the filesystem rather than actually write out a tonne of data. I don't care about initialising the data in the file at all (the protocol I'm using - bittorrent - provides hashes for the files it sends, hence worst case for random uninitialised data is I get a lucky coincidence and part of the file is correct).</p>
[ { "answer_id": 98822, "author": "Mark", "author_id": 4405, "author_profile": "https://Stackoverflow.com/users/4405", "pm_score": 3, "selected": false, "text": "using (FileStream outFile = System.IO.File.Create(filename))\n{\n outFile.Seek(<length_to_write>-1, SeekOrigin.Begin);\n O...
2008/09/19
[ "https://Stackoverflow.com/questions/98774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
98,778
<p>I need to execute a batch file as part of the un-install process in a Windows installer project (standard OOTB VS 2008 installer project-vdproj). One cannot execute a bat file directly from the Custom Actions in the installer project, so I wrote a quick vbs script to call the required bat file.<br> vbs code: </p> <pre><code>Set WshShell = WScript.CreateObject( "WScript.Shell" ) command = "uninstall-windows-serivce.bat" msgbox command WshShell.Run ("cmd /C " &amp; """" &amp; command &amp; """") Set WshShell = Nothing </code></pre> <p>When this script is run independent of the uninstall, it works perfectly. However, when run as part of the uninstall, it does not execute the bat file (but the message box is shown, so I know the vbs file is called). No errors reported (at least that I can tell). Why doesn't this script work as part of the "Uninstall Custom Action"</p>
[ { "answer_id": 98839, "author": "Mike L", "author_id": 12085, "author_profile": "https://Stackoverflow.com/users/12085", "pm_score": 0, "selected": false, "text": " Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)\n MyBase.Uninstall(savedState...
2008/09/19
[ "https://Stackoverflow.com/questions/98778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18449/" ]
98,827
<p>I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET something like </p> <pre><code>String^ speed; String^ size; </code></pre> <p>"command SPEED=[speed] SIZE=[size]"</p> <p>Right now I'm using IndexOf() and Substring() but it is quite ugly</p>
[ { "answer_id": 98946, "author": "user10392", "author_id": 10392, "author_profile": "https://Stackoverflow.com/users/10392", "pm_score": 0, "selected": false, "text": "foreach (FieldInfo f in typeof(InputArgs).GetFields()) {\n string = Regex.replace(\"\\\\[\" + f.Name + \"\\\\]\",\n ...
2008/09/19
[ "https://Stackoverflow.com/questions/98827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6367/" ]
98,859
<p>Does Information Hiding mean I should minimize the number of properties my classes have? Is that right? Do you tend to make your classes private fields with methods?</p>
[ { "answer_id": 98939, "author": "Benjamin Autin", "author_id": 1440933, "author_profile": "https://Stackoverflow.com/users/1440933", "pm_score": 0, "selected": false, "text": "private int _myInt;\npublic int MyInt\n{\n get { return _myInt; }\n set { _myInt = value; }\n}\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18175/" ]
98,867
<p>In c#, we have interfaces. Where did these come from? They didn't exist in c++.</p>
[ { "answer_id": 98881, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "public class Dog : Animal, IMammal\n" }, { "answer_id": 98891, "author": "Statement", "author_id": 2166173, ...
2008/09/19
[ "https://Stackoverflow.com/questions/98867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18175/" ]
98,878
<p>I've always been wondering how people use CRC (class responsiblity collaboration) cards. I've read about them in books, found vague information on the internet, but never grasped it really. I think someone ought to make a youtube video showing a session with CRC cards, since one of my books described it as being very hard to formulate in text, that it should be "taught by someone who already masters it". Sadly, I know noone around here who uses CRC cards and I'd like to learn more.</p> <h2>UPDATE</h2> <p>Any links to videos showing people elaborating with this technique would be appreciated.</p>
[ { "answer_id": 99384, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 3, "selected": false, "text": "///////////////////////\n//* CRC CARD\n//* Class: UISliderEvent\n//* Responsability: Event that holds the value and ...
2008/09/19
[ "https://Stackoverflow.com/questions/98878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2166173/" ]
98,895
<p>I'm having problems refreshing .Net 2.0 with IIS 6.</p> <p>I have been able to successfully execute &quot;aspnet_regiis.exe -i&quot;, but when I try to register the aspnet_isapi.dll:</p> <pre><code>regsvr32 “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&quot; </code></pre> <p>I get the error</p> <blockquote> <p>C:\Windows..\aspnet_isapi.dll was loaded, but the DllRegisterServer entry point was not found.</p> <p>The file cannot be registered.</p> </blockquote> <p>Does anyone know how to resolve this? Google hasn't been very helpful.</p> <p><strong>Edit:</strong> My problem is actually that IIS isn't serving my webpages properly - that is, it's returning 404s when I try to request .aspx files that I know exist.</p> <p>I can access .gif and .js files OK, but I can't access .aspx or other .Net files. I know this is related to .Net being properly configured with IIS, and the above commands are supposed to be the solution, but the second command doesn't work.</p> <p><strong>@aaronjensen</strong>: Your command to register scripts worked successfully, and investigating the logs I find that I'm getting an entry for my failed request with status 404, substatus 2.</p> <p>Microsoft tells me this because &quot;<a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0f4ac79a-dc2b-4a5f-89c1-d57266aa6ffe.mspx?mfr=true" rel="nofollow noreferrer">Lockdown Policy Prevents This Request</a>&quot;.</p> <blockquote> <p>If a request is denied because the associated ISAPI or CGI has not been unlocked, a 404.2 error is returned.</p> </blockquote> <p>Which I assume is due to the isapi DLL in my original query being denied?</p>
[ { "answer_id": 1052042, "author": "Dexter", "author_id": 10717, "author_profile": "https://Stackoverflow.com/users/10717", "pm_score": 3, "selected": true, "text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis -s /w3svc/1/root" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10717/" ]
98,901
<p>In any language really, im looking for a simple (very simple) way to control the position of a shortcut on the users desktop. I already make the assumption that Auto Arrange and Align to Grid are unchecked.</p> <p>Ex: The program creates the shortcut to the desktop than places it at position (450,302) on the desktop. </p> <p>I know how to create shortcuts, but i dont know how to control their placement on the desktop.</p>
[ { "answer_id": 1052042, "author": "Dexter", "author_id": 10717, "author_profile": "https://Stackoverflow.com/users/10717", "pm_score": 3, "selected": true, "text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regiis -s /w3svc/1/root" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18431/" ]
98,915
<p>I realize that this question has been <a href="https://stackoverflow.com/questions/10293/has-anyone-used-jaxer-in-production">asked before</a>, but it has been a month with no decent responses... I'm looking at <a href="http://web.archive.org/web/20090803092709/http://www.aptana.com:80/Jaxer" rel="nofollow noreferrer">Aptana's Jaxer</a> and I find the concept to be very exciting.</p> <p>Here is a quick overview for those who are not familiar with it:</p> <p>Jaxer is, in their words, "the world's first true AJAX server". It is based on the Mozilla engine so scripts are written with javascript and you have complete access to the DOM on the server-side. </p> <p>Scripts are placed on your pages with <code>&lt;script&gt;</code> tags and you can specify a <code>runat</code> attribute (ala ASP.NET) to mark scripts for execution on the client, server, both, or as a "server-proxy" which makes the functions available on the client, but they execute on the server via AJAX. This also means that you can use your favorite client-side libraries (jQuery, Prototype) on the server as well as the client.</p> <p>It also can be used to process documents that are generated in another language (e.g. php, ruby) which I imagine is not practical except to help in transitioning existing applications to use Jaxer.</p> <ul> <li>What are the pros and cons?</li> <li>How mature/stable is it the API?</li> <li>How good is performance compared to other server-side html preprocessors?</li> <li>Has anyone used Jaxer with another technology (php, pearl, ruby, etc.) and what were your experiences?</li> </ul> <p>EDIT: I've posted another question regarding a drawback I discovered while playing with Jaxer: <a href="https://stackoverflow.com/questions/109762/defining-objects-when-using-jaxer">Defining objects when using Jaxer</a></p>
[ { "answer_id": 105555, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<jaxer:include" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/98915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5628/" ]
98,916
<p>How do you programmatically find the number of hosts that a netmask supports.</p> <p>Eg, If you have a /30 , how do you find how many IP's are in it without using a lookup table?</p> <p>Preferably would be able to work with the "/" notation, rather than 255.xxx.xxx.xxx notation.</p>
[ { "answer_id": 98935, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 2, "selected": false, "text": ">>> def number_of_hosts(n):\n... return 2 ** (32 - n)\n... \n>>> number_of_hosts(32)\n1\n>>> number_of_hosts(30)\n4...
2008/09/19
[ "https://Stackoverflow.com/questions/98916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
98,930
<p>In an environment with multiple windows servers what is the best way to ensure patch compliance accross all systems? </p> <p>Is there a simple tool (some sort of client/server app?) that allows reports to be generated showing the status of all the systems so any that aren't automatically patching themselves can be fixed without having to manually check each systemevery time an audit is needed?</p>
[ { "answer_id": 98935, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 2, "selected": false, "text": ">>> def number_of_hosts(n):\n... return 2 ** (32 - n)\n... \n>>> number_of_hosts(32)\n1\n>>> number_of_hosts(30)\n4...
2008/09/19
[ "https://Stackoverflow.com/questions/98930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17007/" ]
98,944
<p>How do I write a cpp macro which expands to include newlines?</p>
[ { "answer_id": 98956, "author": "Branan", "author_id": 13894, "author_profile": "https://Stackoverflow.com/users/13894", "pm_score": -1, "selected": false, "text": "\\" }, { "answer_id": 98972, "author": "PiNoYBoY82", "author_id": 13646, "author_profile": "https://Sta...
2008/09/19
[ "https://Stackoverflow.com/questions/98944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18458/" ]
99,013
<p>Is it possible to use stored procedures for designing Reports in Report builder?</p>
[ { "answer_id": 123573, "author": "jimmyorr", "author_id": 19239, "author_profile": "https://Stackoverflow.com/users/19239", "pm_score": 0, "selected": false, "text": "select * from table (f_foo(:p_bar))\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/99013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
99,020
<p>I have a java app (not running in any application container) which listens on a ServerSocket for connections. I would like it to only accept connections which come from localhost. Currently, after a connection is accepted, it checks the peer IP and rejects it if it is not the loopback address, but I know that peer IP addresses can be spoofed. So, if possible, I'd prefer to bind to a socket that only listens on the loopback interface; is this possible?</p> <p>I've tried a few different things (such as specifying &quot;127.0.0.1&quot; as the local address when calling bind()) with no luck.</p> <hr /> <p><strong>Update:</strong></p> <p>I'm embarrassed to admit that this was all my mistake. Our application listens on two different ports, and I was binding one to the loopback interface but testing against the other. When I actually try to telnet to the correct port, everything works fine (i.e., binding to &quot;127.0.0.1&quot; does exactly what it's supposed to).</p> <p>As for spoofing the loopback address, you guys are right. I shouldn't have made it sound like the primary concern. Really, the desired behavior is to only take local connections, and binding to only the local interface is a more direct way of achieving that than accepting all connections and then closing non-local ones.</p>
[ { "answer_id": 99430, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "127.0.0.1" }, { "answer_id": 9271782, "author": "Selfmade Javaman", "author_id": 1208324, "author_pro...
2008/09/19
[ "https://Stackoverflow.com/questions/99020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
99,045
<p>We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.</p> <p>Currently we use the commands in the test:</p> <pre><code>// force new window to open at this point - so we can select it later selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')"); selenium().click("//input[@value='Submit']"); selenium().waitForPopUp("enquiryPopup", getWaitTime()); selenium().selectWindow("enquiryPopup"); </code></pre> <p>...which works <em>most of the time</em>. Occasionally the test will fail on the <code>waitForPopUp()</code> line with </p> <pre><code>com.thoughtworks.selenium.SeleniumException: Permission denied </code></pre> <p>Can anyone suggest a better, more <em>reliable</em> method?</p> <p>Also, we primarily run these tests on IE6 and 7.</p>
[ { "answer_id": 99372, "author": "brasskazoo", "author_id": 6340, "author_profile": "https://Stackoverflow.com/users/6340", "pm_score": 0, "selected": false, "text": "windowFocus()" }, { "answer_id": 429196, "author": "branchgabriel", "author_id": 30807, "author_profil...
2008/09/19
[ "https://Stackoverflow.com/questions/99045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340/" ]
99,056
<p>If given the choice, which path would you take?</p> <blockquote> <p>ASP.NET Webforms + ASP.NET AJAX</p> </blockquote> <p><strong>or</strong></p> <blockquote> <p>ASP.NET MVC + JavaScript Framework of your Choice</p> </blockquote> <p>Are there any limitations that ASP.NET Webforms / ASP.NET AJAX has vis-a-vis MVC? </p>
[ { "answer_id": 1651600, "author": "Mike", "author_id": 199673, "author_profile": "https://Stackoverflow.com/users/199673", "pm_score": 4, "selected": false, "text": "public partial class SamplePage : System.Web.Mvc.ViewPage\n{\n protected void Page_Load(object sender, EventArgs e)\n ...
2008/09/19
[ "https://Stackoverflow.com/questions/99056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
99,074
<p>Would it be useful to be able to provide method return value for null objects?</p> <p>For a List the null return values might be:</p> <pre><code>get(int) : null size() : 0 iterator() : empty iterator </code></pre> <p>That would allow the following code that has less null checks.</p> <pre><code>List items = null; if(something) { items = ... } for(int index = 0; index &lt; items.size(); index++) { Object obj = items.get(index); } </code></pre> <p>This would only be used if the class or interface defined it and a null check would still work. Sometimes you don't want to do null checks so it seems like it could be beneficial to have this as an option.</p> <p>From: <a href="http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html" rel="nofollow noreferrer">http://jamesjava.blogspot.com/2007/05/method-return-values-for-null-objects.html</a></p>
[ { "answer_id": 99332, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "Foo x = null;\nif (x.Bar() == 0)\n{\n Console.WriteLine(\"I win\");\n}\n" } ]
2008/09/19
[ "https://Stackoverflow.com/questions/99074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]
99,098
<p>What is the best way to generate a current datestamp in Java? </p> <p>YYYY-MM-DD:hh-mm-ss</p>
[ { "answer_id": 99105, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "Date d = new Date();\nString formatted = new SimpleDateFormat (\"yyyy-MM-dd:HH-mm-ss\").format (d);\nSystem.out.println...
2008/09/19
[ "https://Stackoverflow.com/questions/99098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3020/" ]
99,118
<p>Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of list.get(0) would automatically be casted to the type of the variable hi.</p> <pre><code>List list = new ArrayList(); list.add("hi"); String hi = list.get(0); </code></pre> <p>I know that generics allow you to reduce casting but they do so at the expense of making declaration more difficult. To me, the benefit of generics is that they allow you to have the complier enforce more rules -- not they they reduce casting (but I haven't used them much so I am somewhat uninformed). This proposal would only reduce the amount of code to type, not move it to another place. Also there are instances where generics can't be used because a collection can have different objectis. If that "looks too surprising" based on current usage maybe there could be a syntax tweak to use it.</p> <p>From: <a href="http://jamesjava.blogspot.com/2007/01/automatic-casting.html" rel="nofollow noreferrer">http://jamesjava.blogspot.com/2007/01/automatic-casting.html</a></p>
[ { "answer_id": 99216, "author": "jon", "author_id": 12215, "author_profile": "https://Stackoverflow.com/users/12215", "pm_score": 2, "selected": false, "text": "List list = new ArrayList();\nlist.add(new Integer(42));\nString hi = (String) list.get(0); // run time error\n\nList<String> l...
2008/09/19
[ "https://Stackoverflow.com/questions/99118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]
99,132
<p>I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it.</p> <p>I mainly use mingw/msys but would like something that works across other shells/systems too.</p> <p>I tried this but it didn't work, any ideas?</p> <pre><code>ifeq (,$(findstring $(OBJDIR),$(wildcard $(OBJDIR) ))) -mkdir $(OBJDIR) endif </code></pre>
[ { "answer_id": 99156, "author": "andrewdotnich", "author_id": 10569, "author_profile": "https://Stackoverflow.com/users/10569", "pm_score": 4, "selected": false, "text": "-mkdir $(OBJDIR) 2>/dev/null\n" }, { "answer_id": 99174, "author": "tchen", "author_id": 18417, "...
2008/09/19
[ "https://Stackoverflow.com/questions/99132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
99,161
<p>I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.</p> <p>Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.</p> <p>Can't I just hit a magic key to kill the highlights when I'm done searching?</p>
[ { "answer_id": 99182, "author": "Lee H", "author_id": 18201, "author_profile": "https://Stackoverflow.com/users/18201", "pm_score": 9, "selected": false, "text": ":noh" }, { "answer_id": 99186, "author": "Lucas S.", "author_id": 7363, "author_profile": "https://Stacko...
2008/09/19
[ "https://Stackoverflow.com/questions/99161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18446/" ]
99,164
<p>I often see code like:</p> <pre><code>Iterator i = list.iterator(); while(i.hasNext()) { ... } </code></pre> <p>but I write that (when Java 1.5 isn't available or for each can't be used) as:</p> <pre><code>for(Iterator i = list.iterator(); i.hasNext(); ) { ... } </code></pre> <p>because</p> <ul> <li>It is shorter</li> <li>It keeps <code>i</code> in a smaller scope</li> <li>It reduces the chance of confusion. (Is <code>i</code> used outside the while? Where is <code>i</code> declared?)</li> </ul> <p>I think code should be as simple to understand as possible so that I only have to make complex code to do complex things. What do you think? Which is better?</p> <p>From: <a href="http://jamesjava.blogspot.com/2006/04/iterating.html" rel="noreferrer">http://jamesjava.blogspot.com/2006/04/iterating.html</a></p>
[ { "answer_id": 99189, "author": "Giorgio Galante", "author_id": 18269, "author_profile": "https://Stackoverflow.com/users/18269", "pm_score": 3, "selected": false, "text": "List<String> names = new ArrayList<String>();\nnames.add(\"a\");\nnames.add(\"b\");\nnames.add(\"c\");\n\nfor (Stri...
2008/09/19
[ "https://Stackoverflow.com/questions/99164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6770/" ]