qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
4
<p>I want to assign the decimal variable &quot;trans&quot; to the double variable &quot;this.Opacity&quot;.</p> <pre class="lang-cs prettyprint-override"><code>decimal trans = trackBar1.Value / 5000; this.Opacity = trans; </code></pre> <p>When I build the app it gives the following error:</p> <blockquote> <p>Cannot implicitly convert type decimal to double</p> </blockquote>
[ { "answer_id": 7, "author": "Kevin Dente", "author_id": 9, "author_profile": "https://Stackoverflow.com/users/9", "pm_score": 10, "selected": true, "text": "double" }, { "answer_id": 78, "author": "Ryan Fox", "author_id": 55, "author_profile": "https://Stackoverflow.c...
2008/07/31
[ "https://Stackoverflow.com/questions/4", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8/" ]
6
<p>I have an absolutely positioned <code>div</code> containing several children, one of which is a relatively positioned <code>div</code>. When I use a <code>percentage-based width</code> on the child <code>div</code>, it collapses to <code>0 width</code> on IE7, but not on Firefox or Safari.</p> <p>If I use <code>pixel width</code>, it works. If the parent is relatively positioned, the percentage width on the child works.</p> <ol> <li>Is there something I'm missing here?</li> <li>Is there an easy fix for this besides the <code>pixel-based width</code> on the child?</li> <li>Is there an area of the CSS specification that covers this?</li> </ol>
[ { "answer_id": 31, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 8, "selected": true, "text": "div" }, { "answer_id": 1948, "author": "Matt MacLean", "author_id": 22, "author_profile": "https://Stackoverflo...
2008/07/31
[ "https://Stackoverflow.com/questions/6", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9/" ]
9
<p>Given a <code>DateTime</code> representing a person's birthday, how do I calculate their age in years?</p>
[ { "answer_id": 22, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 6, "selected": false, "text": "DateTime birthDate = new DateTime(2000,3,1);\nint age = (int)Math.Floor((DateTime.Now - birthDate).TotalDays / 365.25D);\n" }...
2008/07/31
[ "https://Stackoverflow.com/questions/9", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1/" ]
11
<p>Given a specific <code>DateTime</code> value, how do I display relative time, like:</p> <ul> <li><code>2 hours ago</code></li> <li><code>3 days ago</code></li> <li><code>a month ago</code></li> </ul>
[ { "answer_id": 12, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 8, "selected": false, "text": "var ts = new TimeSpan(DateTime.UtcNow.Ticks - dt.Ticks);\ndouble delta = Math.Abs(ts.TotalSeconds);\n\nif (delta < 60)\n{\n retur...
2008/07/31
[ "https://Stackoverflow.com/questions/11", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1/" ]
13
<p>Is there a standard way for a web server to be able to determine a user's timezone within a web page? </p> <p>Perhaps from an HTTP header or part of the <code>user-agent</code> string?</p>
[ { "answer_id": 817, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 5, "selected": false, "text": "visitortime.getTimezoneOffset()\n" }, { "answer_id": 1809974, "author": "JD Isaacks", "author_id": 46011, ...
2008/08/01
[ "https://Stackoverflow.com/questions/13", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9/" ]
14
<p>What is the difference between <a href="http://msdn.microsoft.com/en-us/library/9a6a2sxy.aspx" rel="noreferrer"><code>Math.Floor()</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx" rel="noreferrer"><code>Math.Truncate()</code></a> in .NET?</p>
[ { "answer_id": 33, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 9, "selected": false, "text": "Math.Floor" }, { "answer_id": 2086, "author": "Marek Grzenkowicz", "author_id": 95, "author_profile": "https...
2008/08/01
[ "https://Stackoverflow.com/questions/14", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11/" ]
16
<p>How do you expose a LINQ query as an ASMX web service? <br> Usually, from the business tier, I can return a typed <code>DataSet</code> or a <code>DataTable</code> which can be serialized for transport over ASMX.</p> <p>How can I do the same for a LINQ query? <br> Is there a way to populate a typed <code>DataSet</code> or a <code>DataTable</code> via a LINQ query?</p> <pre><code>public static MyDataTable CallMySproc() { string conn = &quot;...&quot;; MyDatabaseDataContext db = new MyDatabaseDataContext(conn); MyDataTable dt = new MyDataTable(); // execute a sproc via LINQ var query = from dr in db.MySproc().AsEnumerable select dr; // copy LINQ query resultset into a DataTable -this does not work ! dt = query.CopyToDataTable(); return dt; } </code></pre> <p>How could I put the result set of a LINQ query into a <code>DataSet</code> or a <code>DataTable</code>? <br> Alternatively, can the LINQ query be serializable so that I can expose it as an ASMX web service?</p>
[ { "answer_id": 84, "author": "Dave Ward", "author_id": 60, "author_profile": "https://Stackoverflow.com/users/60", "pm_score": 4, "selected": false, "text": "IEnumerable" }, { "answer_id": 5830, "author": "Brian Childress", "author_id": 721, "author_profile": "https:/...
2008/08/01
[ "https://Stackoverflow.com/questions/16", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2/" ]
17
<p>How do I store binary data in <a href="http://en.wikipedia.org/wiki/MySQL" rel="noreferrer">MySQL</a>?</p>
[ { "answer_id": 18, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "CREATE TABLE binary_data (\n id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,\n description CHAR(50),\n bin_data LONGBLOB,\...
2008/08/01
[ "https://Stackoverflow.com/questions/17", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2/" ]
19
<p>I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using <code>#define</code> constants like <code>M_PI</code>, or hard-coding the number in.</p> <p>The program below tests the various ways I know of. The inline assembly version is, in theory, the fastest option, though clearly not portable. I've included it as a baseline to compare against the other versions. In my tests, with built-ins, the <code>4 * atan(1)</code> version is fastest on GCC 4.2, because it auto-folds the <code>atan(1)</code> into a constant. With <code>-fno-builtin</code> specified, the <code>atan2(0, -1)</code> version is fastest.</p> <p>Here's the main testing program (<code>pitimes.c</code>):</p> <pre class="lang-c prettyprint-override"><code>#include &lt;math.h&gt; #include &lt;stdio.h&gt; #include &lt;time.h&gt; #define ITERS 10000000 #define TESTWITH(x) { \ diff = 0.0; \ time1 = clock(); \ for (i = 0; i &lt; ITERS; ++i) \ diff += (x) - M_PI; \ time2 = clock(); \ printf("%s\t=&gt; %e, time =&gt; %f\n", #x, diff, diffclock(time2, time1)); \ } static inline double diffclock(clock_t time1, clock_t time0) { return (double) (time1 - time0) / CLOCKS_PER_SEC; } int main() { int i; clock_t time1, time2; double diff; /* Warmup. The atan2 case catches GCC's atan folding (which would * optimise the ``4 * atan(1) - M_PI'' to a no-op), if -fno-builtin * is not used. */ TESTWITH(4 * atan(1)) TESTWITH(4 * atan2(1, 1)) #if defined(__GNUC__) &amp;&amp; (defined(__i386__) || defined(__amd64__)) extern double fldpi(); TESTWITH(fldpi()) #endif /* Actual tests start here. */ TESTWITH(atan2(0, -1)) TESTWITH(acos(-1)) TESTWITH(2 * asin(1)) TESTWITH(4 * atan2(1, 1)) TESTWITH(4 * atan(1)) return 0; } </code></pre> <p>And the inline assembly stuff (<code>fldpi.c</code>) that will only work for x86 and x64 systems:</p> <pre class="lang-c prettyprint-override"><code>double fldpi() { double pi; asm("fldpi" : "=t" (pi)); return pi; } </code></pre> <p>And a build script that builds all the configurations I'm testing (<code>build.sh</code>):</p> <pre><code>#!/bin/sh gcc -O3 -Wall -c -m32 -o fldpi-32.o fldpi.c gcc -O3 -Wall -c -m64 -o fldpi-64.o fldpi.c gcc -O3 -Wall -ffast-math -m32 -o pitimes1-32 pitimes.c fldpi-32.o gcc -O3 -Wall -m32 -o pitimes2-32 pitimes.c fldpi-32.o -lm gcc -O3 -Wall -fno-builtin -m32 -o pitimes3-32 pitimes.c fldpi-32.o -lm gcc -O3 -Wall -ffast-math -m64 -o pitimes1-64 pitimes.c fldpi-64.o -lm gcc -O3 -Wall -m64 -o pitimes2-64 pitimes.c fldpi-64.o -lm gcc -O3 -Wall -fno-builtin -m64 -o pitimes3-64 pitimes.c fldpi-64.o -lm </code></pre> <p>Apart from testing between various compiler flags (I've compared 32-bit against 64-bit too because the optimizations are different), I've also tried switching the order of the tests around. But still, the <code>atan2(0, -1)</code> version still comes out on top every time.</p>
[ { "answer_id": 531, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 9, "selected": true, "text": "let pi_2 iters =\n let rec loop_ a b t p i =\n if i = 0 then a,b,t,p\n else\n let a_n = (a +. b) /. ...
2008/08/01
[ "https://Stackoverflow.com/questions/19", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13/" ]
24
<p>If I have a trigger before the update on a table, how can I throw an error that prevents the update on that table?</p>
[ { "answer_id": 7189396, "author": "RuiDC", "author_id": 521586, "author_profile": "https://Stackoverflow.com/users/521586", "pm_score": 7, "selected": false, "text": "SIGNAL" }, { "answer_id": 9046539, "author": "el.atomo", "author_id": 831797, "author_profile": "http...
2008/08/01
[ "https://Stackoverflow.com/questions/24", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22/" ]
25
<p>I'm having issues getting the C sockets API to work properly in C++ on z/OS.</p> <p>Although I am including <code>sys/socket.h</code>, I still get compile time errors telling me that <code>AF_INET</code> is not defined.</p> <p>Am I missing something obvious, or is this related to the fact that being on z/OS makes my problems much more complicated?</p> <p>I discovered that there is an <code>#ifdef</code> that I'm hitting. Apparently z/OS isn't happy unless I define which &quot;type&quot; of sockets I'm using with:</p> <pre><code>#define _OE_SOCKETS </code></pre> <p>Now, I personally have no idea what this <code>_OE_SOCKETS</code> is actually for, so if any z/OS sockets programmers are out there (all 3 of you), perhaps you could give me a rundown of how this all works?</p> <p>Test App</p> <pre><code>#include &lt;sys/socket.h&gt; int main() { return AF_INET; } </code></pre> <p>Compile/Link Output:</p> <pre><code>cxx -Wc,xplink -Wl,xplink -o inet_test inet.C &quot;./inet.C&quot;, line 5.16: CCN5274 (S) The name lookup for &quot;AF_INET&quot; did not find a declaration. CCN0797(I) Compilation failed for file ./inet.C. Object file not created. </code></pre> <p>A check of sys/sockets.h does include the definition I need, and as far as I can tell, it is not being blocked by any <code>#ifdef</code> statements.</p> <p>I have however noticed it contains the following:</p> <pre><code>#ifdef __cplusplus extern &quot;C&quot; { #endif </code></pre> <p>which encapsulates basically the whole file? Not sure if it matters.</p>
[ { "answer_id": 30, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": false, "text": "#include <sys/socket.h>\n\nint\nmain()\n{\n return AF_INET;\n}\n" }, { "answer_id": 73, "author": "C. K. Young", ...
2008/08/01
[ "https://Stackoverflow.com/questions/25", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23/" ]
34
<p>How do I forcefully unload a <code>ByteArray</code> from memory using ActionScript 3?</p> <p>I have tried the following:</p> <pre><code>// First non-working solution byteArray.length = 0; byteArray = new ByteArray(); // Second non-working solution for ( var i:int=0; i &lt; byteArray.length; i++ ) { byteArray[i] = null; } </code></pre>
[ { "answer_id": 52, "author": "Jax", "author_id": 23, "author_profile": "https://Stackoverflow.com/users/23", "pm_score": 4, "selected": false, "text": "private var gcCount:int;\nprivate function startGCCycle():void{\n gcCount = 0;\n addEventListener(Event.ENTER_FRAME, doGC);\n}\npr...
2008/08/01
[ "https://Stackoverflow.com/questions/34", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
36
<p>How can I monitor an SQL Server database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> and C#.</p> <p>I'd like to be able to support any <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#Genesis" rel="noreferrer">SQL Server 2000</a> SP4 or newer. My application is a bolt-on data visualization for another company's product. Our customer base is in the thousands, so I don't want to have to put in requirements that we modify the third-party vendor's table at every installation.</p> <p>By <em>"changes to a table"</em> I mean changes to table data, not changes to table structure.</p> <p>Ultimately, I would like the change to trigger an event in my application, instead of having to check for changes at an interval.</p> <hr> <p>The best course of action given my requirements (no triggers or schema modification, SQL Server 2000 and 2005) seems to be to use the <code>BINARY_CHECKSUM</code> function in <a href="http://en.wikipedia.org/wiki/Transact-SQL" rel="noreferrer">T-SQL</a>. The way I plan to implement is this:</p> <p>Every X seconds run the following query:</p> <pre><code>SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK); </code></pre> <p>And compare that against the stored value. If the value has changed, go through the table row by row using the query:</p> <pre><code>SELECT row_id, BINARY_CHECKSUM(*) FROM sample_table WITH (NOLOCK); </code></pre> <p>And compare the returned checksums against stored values.</p>
[ { "answer_id": 82, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 4, "selected": false, "text": "select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'ABC'\n" }, { "answer_id": 352, "author": "Jon Galloway...
2008/08/01
[ "https://Stackoverflow.com/questions/36", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32/" ]
39
<p>I am aware that in <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> there are three timer types (see <em><a href="http://msdn.microsoft.com/en-us/magazine/cc164015.aspx" rel="noreferrer">Comparing the Timer Classes in the .NET Framework Class Library</a></em>). I have chosen a threaded timer as the other types can drift if the main thread is busy, and I need this to be reliable.</p> <p>The way this timer works in the control of the timer is put on another thread so it can always tick along with the work begin completed on the parent thread when it is not busy.</p> <p>The issue with this timer in a console application is that while the timer is ticking along on another thread the main thread is not doing anything to the application closes.</p> <p>I tried adding a <code>while true</code> loop, but then the main thread is too busy when the timer does go off.</p>
[ { "answer_id": 44, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 5, "selected": false, "text": "Reset()" }, { "answer_id": 45, "author": "huseyint", "author_id": 39, "author_profile": "https://Stackoverf...
2008/08/01
[ "https://Stackoverflow.com/questions/39", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33/" ]
42
<p>I am starting a new web application in PHP and this time around I want to create something that people can extend by using a plugin interface. </p> <p>How does one go about writing 'hooks' into their code so that plugins can attach to specific events?</p>
[ { "answer_id": 77, "author": "Kevin", "author_id": 40, "author_profile": "https://Stackoverflow.com/users/40", "pm_score": 8, "selected": true, "text": "<?php\n\n/** Plugin system **/\n\n$listeners = array();\n\n/* Create an entry point for plugins */\nfunction hook() {\n global $list...
2008/08/01
[ "https://Stackoverflow.com/questions/42", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37/" ]
48
<p>Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the <em>back</em> button appears first in the markup when you press <kbd>Enter</kbd>, it will use that button to submit the form.</p> <p>Example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt; &lt;!-- Put your cursor in this field and press Enter --&gt; &lt;input type="text" name="field1" /&gt; &lt;!-- This is the button that will submit --&gt; &lt;input type="submit" name="prev" value="Previous Page" /&gt; &lt;!-- But this is the button that I WANT to submit --&gt; &lt;input type="submit" name="next" value="Next Page" /&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>I would like to get to decide which button is used to submit the form when a user presses <kbd>Enter</kbd>. That way, when you press <kbd>Enter</kbd> the wizard will move to the next page, not the previous. Do you have to use <code>tabindex</code> to do this?</p>
[ { "answer_id": 56, "author": "huseyint", "author_id": 39, "author_profile": "https://Stackoverflow.com/users/39", "pm_score": 6, "selected": false, "text": "<input type=\"submit\" name=\"submitButton\" value=\"Previous Page\" />\n<input type=\"submit\" name=\"submitButton\" value=\"Next ...
2008/08/01
[ "https://Stackoverflow.com/questions/48", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40/" ]
59
<p>I have a <code>DataTable</code> with a <code>Name</code> column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the <em>order by</em> clause.</p> <pre><code>var names = (from DataRow dr in dataTable.Rows orderby (string)dr["Name"] select (string)dr["Name"]).Distinct(); </code></pre> <p>Why does the <code>orderby</code> not get enforced?</p>
[ { "answer_id": 62, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 6, "selected": false, "text": "var names = (from DataRow dr in dataTable.Rows\n select (string)dr[\"Name\"]).Distinct().OrderBy( name => name );\n" }, ...
2008/08/01
[ "https://Stackoverflow.com/questions/59", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
66
<p>How do you page through a collection in LINQ given that you have a <code>startIndex</code> and a <code>count</code>?</p>
[ { "answer_id": 68, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 6, "selected": false, "text": "Skip" }, { "answer_id": 4521, "author": "Mike Minutillo", "author_id": 358, "author_profile": "https://Stac...
2008/08/01
[ "https://Stackoverflow.com/questions/66", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17/" ]
72
<p>I want to format my existing comments as 'RDoc comments' so they can be viewed using <code>ri</code>.</p> <p>What are some recommended resources for starting out using RDoc?</p>
[ { "answer_id": 23993, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 4, "selected": false, "text": ":main:" } ]
2008/08/01
[ "https://Stackoverflow.com/questions/72", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
80
<p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL" rel="noreferrer">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application:</p> <pre><code>Create Table tRole ( roleID integer Primary Key ,roleName varchar(40) ); Create Table tFile ( fileID integer Primary Key ,fileName varchar(50) ,fileDescription varchar(500) ,thumbnailID integer ,fileFormatID integer ,categoryID integer ,isFavorite boolean ,dateAdded date ,globalAccessCount integer ,lastAccessTime date ,downloadComplete boolean ,isNew boolean ,isSpotlight boolean ,duration varchar(30) ); Create Table tCategory ( categoryID integer Primary Key ,categoryName varchar(50) ,parent_categoryID integer ); ... </code></pre> <p>I execute this in Adobe AIR using the following methods:</p> <pre><code>public static function RunSqlFromFile(fileName:String):void { var file:File = File.applicationDirectory.resolvePath(fileName); var stream:FileStream = new FileStream(); stream.open(file, FileMode.READ) var strSql:String = stream.readUTFBytes(stream.bytesAvailable); NonQuery(strSql); } public static function NonQuery(strSQL:String):void { var sqlConnection:SQLConnection = new SQLConnection(); sqlConnection.open(File.applicationStorageDirectory.resolvePath(DBPATH)); var sqlStatement:SQLStatement = new SQLStatement(); sqlStatement.text = strSQL; sqlStatement.sqlConnection = sqlConnection; try { sqlStatement.execute(); } catch (error:SQLError) { Alert.show(error.toString()); } } </code></pre> <p>No errors are generated, however only <code>tRole</code> exists. It seems that it only looks at the first query (up to the semicolon- if I remove it, the query fails). Is there a way to call multiple queries in one statement?</p>
[ { "answer_id": 124, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 5, "selected": true, "text": "var strSql:String = stream.readUTFBytes(stream.bytesAvailable); \nvar i:Number = 0;\nvar strSqlSplit:Array = strSql.split(\";\");...
2008/08/01
[ "https://Stackoverflow.com/questions/80", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
85
<p>What are the best practices around creating flat file database structures in PHP?</p> <p>A lot of more matured PHP flat file frameworks out there which I attempt to implement SQL-like query syntax which is over the top for my purposes in most cases. (I would just use a database at that point).</p> <p>Are there any elegant tricks out there to get good performance and features with a small code overhead?</p>
[ { "answer_id": 87, "author": "saint_groceon", "author_id": 59, "author_profile": "https://Stackoverflow.com/users/59", "pm_score": 4, "selected": false, "text": "./content/YYYYMMDDHHMMSS/\n" }, { "answer_id": 154, "author": "w-ll", "author_id": 146637, "author_profile...
2008/08/01
[ "https://Stackoverflow.com/questions/85", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59/" ]
88
<p>I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux).</p> <p>I have implemented <code>QueryPerformanceCounter</code> by giving the uSeconds since the process start up: </p> <pre><code>BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount) { gettimeofday(&amp;currentTimeVal, NULL); performanceCount-&gt;QuadPart = (currentTimeVal.tv_sec - startTimeVal.tv_sec); performanceCount-&gt;QuadPart *= (1000 * 1000); performanceCount-&gt;QuadPart += (currentTimeVal.tv_usec - startTimeVal.tv_usec); return true; } </code></pre> <p>This, coupled with <code>QueryPerformanceFrequency()</code> giving a constant 1000000 as the frequency, works well <b>on my machine</b>, giving me a 64-bit variable that contains <code>uSeconds</code> since the program's start-up.</p> <p>So <em>is this portable?</em> I don't want to discover it works differently if the kernel was compiled in a certain way or anything like that. I am fine with it being non-portable to something other than Linux, however.</p>
[ { "answer_id": 98, "author": "Louis Brandy", "author_id": 2089740, "author_profile": "https://Stackoverflow.com/users/2089740", "pm_score": 7, "selected": true, "text": "gettimeofday()" }, { "answer_id": 367, "author": "Mark Harrison", "author_id": 116, "author_profil...
2008/08/01
[ "https://Stackoverflow.com/questions/88", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
104
<p>In .NET perspective:</p> <ul> <li>What is a <a href="https://en.wikipedia.org/wiki/Memory_leak" rel="noreferrer">memory leak</a>?</li> <li>How can you determine whether your application leaks? What are the effects?</li> <li>How can you prevent a memory leak?</li> <li>If your application has memory leak, does it go away when the process exits or is killed? Or do memory leaks in your application affect other processes on the system even after process completion?</li> <li>And what about unmanaged code accessed via COM Interop and/or P/Invoke?</li> </ul>
[ { "answer_id": 2947, "author": "Seibar", "author_id": 357, "author_profile": "https://Stackoverflow.com/users/357", "pm_score": 3, "selected": false, "text": "StreamReader sr;\nusing(sr = new StreamReader(\"somefile.txt\"))\n{\n //do some stuff\n}\n" }, { "answer_id": 4702, ...
2008/08/01
[ "https://Stackoverflow.com/questions/104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39/" ]
109
<p>Recently our site has been deluged with the resurgence of the <a href="https://en.wikipedia.org/wiki/Asprox_botnet" rel="noreferrer">Asprox botnet</a> <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="noreferrer">SQL injection</a> attack. Without going into details, the attack attempts to execute SQL code by encoding the <a href="http://en.wikipedia.org/wiki/Transact-SQL" rel="noreferrer">T-SQL</a> commands in an ASCII encoded BINARY string. It looks something like this:</p> <pre><code>DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x44004500...06F007200%20AS%20NVARCHAR(4000));EXEC(@S);-- </code></pre> <p>I was able to decode this in SQL, but I was a little wary of doing this since I didn't know exactly what was happening at the time.</p> <p>I tried to write a simple decode tool, so I could decode this type of text without even touching <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="noreferrer">SQL&nbsp; Server</a>. The main part I need to be decoded is:</p> <pre><code>CAST(0x44004500...06F007200 AS NVARCHAR(4000)) </code></pre> <p>I've tried all of the following commands with no luck:</p> <pre><code>txtDecodedText.Text = System.Web.HttpUtility.UrlDecode(txtURLText.Text); txtDecodedText.Text = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(txtURLText.Text)); txtDecodedText.Text = Encoding.Unicode.GetString(Encoding.Unicode.GetBytes(txtURLText.Text)); txtDecodedText.Text = Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(txtURLText.Text)); txtDecodedText.Text = Encoding.Unicode.GetString(Convert.FromBase64String(txtURLText.Text)); </code></pre> <p>What is the proper way to translate this encoding without using SQL Server? Is it possible? I'll take VB.NET code since I'm familiar with that too.</p> <hr> <p>Okay, I'm sure I'm missing something here, so here's where I'm at.</p> <p>Since my input is a basic string, I started with just a snippet of the encoded portion - 4445434C41 (which translates to DECLA) - and the first attempt was to do this...</p> <pre><code>txtDecodedText.Text = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(txtURL.Text)); </code></pre> <p>...and all it did was return the exact same thing that I put in since it converted each character into is a byte.</p> <p>I realized that I need to parse every two characters into a byte manually since I don't know of any methods yet that will do that, so now my little decoder looks something like this:</p> <pre><code>while (!boolIsDone) { bytURLChar = byte.Parse(txtURLText.Text.Substring(intParseIndex, 2)); bytURL[intURLIndex] = bytURLChar; intParseIndex += 2; intURLIndex++; if (txtURLText.Text.Length - intParseIndex &lt; 2) { boolIsDone = true; } } txtDecodedText.Text = Encoding.UTF8.GetString(bytURL); </code></pre> <p>Things look good for the first couple of pairs, but then the loop balks when it gets to the "4C" pair and says that the string is in the incorrect format.</p> <p>Interestingly enough, when I step through the debugger and to the GetString method on the byte array that I was able to parse up to that point, I get ",-+" as the result.</p> <p>How do I figure out what I'm missing - do I need to do a "direct cast" for each byte instead of attempting to parse it?</p>
[ { "answer_id": 304, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 3, "selected": false, "text": "0x" }, { "answer_id": 2585, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflo...
2008/08/01
[ "https://Stackoverflow.com/questions/109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
123
<p>Is there an existing application or library in <em>Java</em> which will allow me to convert a <code>CSV</code> data file to <code>XML</code> file? </p> <p>The <code>XML</code> tags would be provided through possibly the first row containing column headings.</p>
[ { "answer_id": 133, "author": "saint_groceon", "author_id": 59, "author_profile": "https://Stackoverflow.com/users/59", "pm_score": 2, "selected": false, "text": "String.split()" }, { "answer_id": 6726, "author": "Anthony Cramp", "author_id": 488, "author_profile": "h...
2008/08/01
[ "https://Stackoverflow.com/questions/123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78/" ]
126
<p>What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method?</p> <p>I know that from outside of the object you should use a getter/setter, but from within would you just do:</p> <p>Java:</p> <pre><code>String property = this.property; </code></pre> <p>PHP:</p> <pre><code>$property = $this-&gt;property; </code></pre> <p>or would you do:</p> <p>Java:</p> <pre><code>String property = this.getProperty(); </code></pre> <p>PHP:</p> <pre><code>$property = $this-&gt;getProperty(); </code></pre> <p>Forgive me if my Java is a little off, it's been a year since I programmed in Java...</p> <p><strong>EDIT:</strong></p> <p>It seems people are assuming I am talking about private or protected variables/properties only. When I learned OO I was taught to use getters/setters for every single property even if it was public (and actually I was told never to make any variable/property public). So, I may be starting off from a false assumption from the get go. It appears that people answering this question are maybe saying that you should have public properties and that those don't need getters and setters, which goes against what I was taught, and what I was talking about, although maybe that needs to be discussed as well. That's probably a good topic for a different question though...</p>
[ { "answer_id": 139, "author": "pix0r", "author_id": 72, "author_profile": "https://Stackoverflow.com/users/72", "pm_score": 4, "selected": false, "text": "public function getName() {\n $this->incrementNameCalled();\n return $this->_getName();\n}\n\nprotected function _getName() {\n...
2008/08/01
[ "https://Stackoverflow.com/questions/126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
145
<p>Does anyone know of a good way to compress or decompress files and folders in C# quickly? Handling large files might be necessary.</p>
[ { "answer_id": 2142, "author": "Dave Anderson", "author_id": 371, "author_profile": "https://Stackoverflow.com/users/371", "pm_score": 5, "selected": false, "text": "System.IO.Compression" }, { "answer_id": 48174631, "author": "mohsen_1687", "author_id": 3311484, "aut...
2008/08/01
[ "https://Stackoverflow.com/questions/145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87/" ]
146
<p>I have a website that plays mp3s in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it. </p> <p>Is there an easy way to track how many times a particular song clip (or any binary file) has been downloaded?</p> <hr> <blockquote> <p>Is the play link a link to the actual mp3 file or to some javascript code that pops up a player?</p> <p>If the latter, you can easily add your own logging code in there to track the number of hits to it.</p> <p>If the former, you'll need something that can track the web server log itself and make that distinction. My hosting plan comes with Webalizer, which does this nicely.</p> </blockquote> <p>It's a javascript code so that answers that. </p> <p>However, it would be nice to know how to track downloads using the other method (without switching hosts).</p>
[ { "answer_id": 152, "author": "w-ll", "author_id": 146637, "author_profile": "https://Stackoverflow.com/users/146637", "pm_score": 6, "selected": true, "text": "$filename = base64_url_decode($_REQUEST['file']);\nheader(\"Cache-Control: public\");\nheader('Content-disposition: attachment;...
2008/08/01
[ "https://Stackoverflow.com/questions/146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30/" ]
163
<p>Stack Overflow has a subversion version number at the bottom:</p> <blockquote> <p>svn revision: 679</p> </blockquote> <p>I want to use such automatic versioning with my <code>.NET Web Site/Application</code>, Windows Forms, WPD projects/solutions.</p> <p>How do I implement this?</p>
[ { "answer_id": 166, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 5, "selected": false, "text": "$Id:$\n" }, { "answer_id": 9391, "author": "James Pogran", "author_id": 1083, "author_profile": "https://S...
2008/08/01
[ "https://Stackoverflow.com/questions/163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
164
<p><strong>Edit:</strong> This question was written in 2008, which was like 3 internet ages ago. If this question is still relevant to your environment, please accept my condolences. Everyone else should convert into a format <a href="https://videojs.com/html5-video-support/" rel="noreferrer">supported by your browsers</a> (That would be H.264 if Internet Explorer is needed, and probably AV1, VP8/VP9 if not) and use the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video" rel="noreferrer"><code>&lt;video&gt;</code> element</a>.</p> <hr /> <p>We are using <a href="http://en.wikipedia.org/wiki/Windows_Media_Video" rel="noreferrer">WMV</a> videos on an internal site, and we are embedding them into web sites. This works quite well on Internet Explorer, but not on Firefox. I've found ways to make it work in Firefox, but then it stops working in Internet Explorer.</p> <p>We do not want to use Silverlight just yet, especially since we cannot be sure that all clients will be running Windows XP with Windows Media Player installed.</p> <p>Is there some sort of Universal Code that embeds WMP into both Internet Explorer and Firefox, or do we need to implement some user-agent-detection and deliver different HTML for different browsers?</p>
[ { "answer_id": 167, "author": "Grant", "author_id": 30, "author_profile": "https://Stackoverflow.com/users/30", "pm_score": 3, "selected": false, "text": "<![if !IE]>\n<p> Firefox only code</p>\n<![endif]>\n\n<!--[if IE]>\n<p>Internet Explorer only code</p>\n<![endif]-->\n" }, { ...
2008/08/01
[ "https://Stackoverflow.com/questions/164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
173
<p>I want to get my databases under version control.</p> <p>I'll always want to have at least <em>some</em> data in there (as <a href="https://stackoverflow.com/users/80/alumb">alumb</a> mentions: user types and administrators). I'll also often want a large collection of generated test data for performance measurements.</p> <p>How would I apply version control to my database?</p>
[ { "answer_id": 516, "author": "ESV", "author_id": 150, "author_profile": "https://Stackoverflow.com/users/150", "pm_score": 9, "selected": true, "text": "create table VersionHistory (\n Version int primary key,\n UpgradeStart datetime not null,\n UpgradeEnd datetime\n );\n" ...
2008/08/01
[ "https://Stackoverflow.com/questions/173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
174
<p>I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free <code>.NET</code> library that will support the printing of a basic HTML page? Here is the code I have so far, which does not run properly.</p> <pre><code>public void PrintThing(string document) { if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) { Thread thread = new Thread((ThreadStart) delegate { PrintDocument(document); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else { PrintDocument(document); } } protected void PrintDocument(string document) { WebBrowser browser = new WebBrowser(); browser.DocumentText = document; while (browser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } browser.Print(); } </code></pre> <p>This works fine when called from UI-type threads, but nothing happens when called from a service-type thread. Changing <code>Print()</code> to <code>ShowPrintPreviewDialog()</code> yields the following IE script error:</p> <blockquote> <p><strong>Error:</strong> <code>dialogArguments.___IE_PrintType</code> is null or not an object. </p> <p>URL: <code>res://ieframe.dll/preview.dlg</code></p> </blockquote> <p>And a small empty print preview dialog appears.</p>
[ { "answer_id": 768, "author": "ICR", "author_id": 214, "author_profile": "https://Stackoverflow.com/users/214", "pm_score": 5, "selected": false, "text": "using (Process printProcess = new Process())\n{\n string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);...
2008/08/01
[ "https://Stackoverflow.com/questions/174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/96/" ]
175
<p>I want to be able to display a normal YouTube video with overlaid annotations, consisting of coloured rectangles for each frame. The only requirement is that this should be done programmatically. </p> <p>YouTube has annotations now, but require you to use their front end to create them by hand. I want to be able to generate them. What's the best way of doing this?</p> <p>Some ideas:</p> <blockquote> <ol> <li>Build your own Flash player (ew?)</li> <li>Somehow draw over the YouTube Flash player. Will this work?</li> <li>Reverse engineer &amp; hijack YouTube's annotation system. Either messing with the local files or redirecting its attempt to download the annotations. (using Greasemonkey? Firefox plugin?)</li> </ol> </blockquote> <p>Idea that doesn't count: </p> <blockquote> <p>download the video</p> </blockquote>
[ { "answer_id": 7157, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 3, "selected": false, "text": "annotation-thingamajig" }, { "answer_id": 65659, "author": "nerdabilly", "author_id": 8349, "author_profi...
2008/08/01
[ "https://Stackoverflow.com/questions/175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2089740/" ]
176
<p>On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php <code>error_log</code> between virtual hosts.</p> <p>Overriding this setting in the <code>&lt;Location&gt;</code> of the <code>httpd.conf</code> does not seem to do anything.</p> <p>Is there a way to have separate php <code>error_logs</code> for each Virtual Host?</p>
[ { "answer_id": 207, "author": "helloandre", "author_id": 50, "author_profile": "https://Stackoverflow.com/users/50", "pm_score": 7, "selected": true, "text": "<VirtualHost IP:Port>\n # Stuff,\n # More Stuff,\n ErrorLog /path/where/you/want/the/error.log\n</VirtualHost>\n" }, { ...
2008/08/01
[ "https://Stackoverflow.com/questions/176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
180
<p>This is something I've pseudo-solved many times and have never quite found a solution for.</p> <p>The problem is to come up with a way to generate <code>N</code> colors, that are as distinguishable as possible where <code>N</code> is a parameter.</p>
[ { "answer_id": 199, "author": "helloandre", "author_id": 50, "author_profile": "https://Stackoverflow.com/users/50", "pm_score": 2, "selected": false, "text": "//colors entered as 0-255 [R, G, B]\ncolors = []; //holds final colors to be used\nrand = new Random();\n\n//assumes n is less t...
2008/08/01
[ "https://Stackoverflow.com/questions/180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2089740/" ]
192
<p>One of the fun parts of multi-cultural programming is number formats.</p> <ul> <li>Americans use 10,000.50</li> <li>Germans use 10.000,50</li> <li>French use 10 000,50</li> </ul> <p>My first approach would be to take the string, parse it backwards until I encounter a separator and use this as my decimal separator. There is an obvious flaw with that: 10.000 would be interpreted as 10.</p> <p>Another approach: if the string contains 2 different non-numeric characters, use the last one as the decimal separator and discard the others. If I only have one, check if it occurs more than once and discards it if it does. If it only appears once, check if it has 3 digits after it. If yes, discard it, otherwise, use it as decimal separator.</p> <p>The obvious "best solution" would be to detect the User's culture or Browser, but that does not work if you have a Frenchman using an en-US Windows/Browser.</p> <p>Does the .net Framework contain some mythical black magic floating point parser that is better than <code>Double.(Try)Parse()</code> in trying to auto-detect the number format?</p>
[ { "answer_id": 210, "author": "huseyint", "author_id": 39, "author_profile": "https://Stackoverflow.com/users/39", "pm_score": 5, "selected": false, "text": "double d = double.Parse(\"100.20\", CultureInfo.CurrentCulture);\n// -- OR --\ndouble d = double.Parse(\"100.20\", CultureInfo.Cu...
2008/08/01
[ "https://Stackoverflow.com/questions/192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
227
<p>I have the following arrays:</p> <pre><code>$artist = array("the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE"); $count = array(5, 3, 9, 1, 1, 3); </code></pre> <p>I want to generate a tag cloud that will have artists with a higher number in <code>$count</code> enclosed in <code>h6</code> tags and the lowest enclosed <code>h1</code> tags.</p>
[ { "answer_id": 253, "author": "Ryan Fox", "author_id": 55, "author_profile": "https://Stackoverflow.com/users/55", "pm_score": 5, "selected": false, "text": "$artist = array(\"the roots\",\"michael jackson\",\"billy idol\",\"more\",\"and more\",\"and_YET_MORE\");\n$count = array(5,3,9,1,...
2008/08/01
[ "https://Stackoverflow.com/questions/227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146637/" ]
231
<p>How do I make it so <code>mailto:</code> links will be registered with my program?</p> <p>How would I then handle that event in my program?</p> <p>Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, such as &quot;set as default email client&quot;.</p> <p>#Edit: Removed reference to Delphi, because the answer is independent of your language.</p>
[ { "answer_id": 233, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 4, "selected": false, "text": "[HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command]" }, { "answer_id": 1812, "author": "Liron Yahdav", "author_id": ...
2008/08/01
[ "https://Stackoverflow.com/questions/231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62/" ]
234
<p>MySQL has this incredibly useful yet proprietary <code>REPLACE INTO</code> SQL Command. </p> <p>Can this easily be emulated in SQL Server 2005?</p> <p>Starting a new Transaction, doing a <code>Select()</code> and then either <code>UPDATE</code> or <code>INSERT</code> and <code>COMMIT</code> is always a little bit of a pain, especially when doing it in the application and therefore always keeping 2 versions of the statement.</p> <p>I wonder if there is an easy and <strong>universal</strong> way to implement such a function into SQL Server 2005?</p>
[ { "answer_id": 243, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 4, "selected": false, "text": "IF EXISTS (SELECT * FROM [Table] WHERE Id = X)\n UPDATE [Table] SET...\nELSE\n INSERT INTO [Table]\n" }, { "answer_id"...
2008/08/01
[ "https://Stackoverflow.com/questions/234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
260
<p>I have a little game written in C#. It uses a database as back-end. It's a <a href="http://en.wikipedia.org/wiki/Collectible_card_game" rel="noreferrer">trading card game</a>, and I wanted to implement the function of the cards as a script.</p> <p>What I mean is that I essentially have an interface, <code>ICard</code>, which a card class implements (<code>public class Card056: ICard</code>) and which contains a function that is called by the game.</p> <p>Now, to make the thing maintainable/moddable, I would like to have the class for each card as source code in the database and essentially compile it on first use. So when I have to add/change a card, I'll just add it to the database and tell my application to refresh, without needing any assembly deployment (especially since we would be talking about 1 assembly per card which means hundreds of assemblies).</p> <p>Is that possible? Register a class from a source file and then instantiate it, etc.</p> <pre><code>ICard Cards[current] = new MyGame.CardLibrary.Card056(); Cards[current].OnEnterPlay(ref currentGameState); </code></pre> <p>The language is C# but extra bonus if it's possible to write the script in any .NET language.</p>
[ { "answer_id": 7217, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 2, "selected": false, "text": "CodeDomProvider" } ]
2008/08/01
[ "https://Stackoverflow.com/questions/260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
263
<p>I have been trying to implement Win32's <code>MessageBox</code> using GTK. The app uses SDL/OpenGL, so this isn't a GTK app.</p> <p>I handle the initialization (<code>gtk_init</code>) sort of stuff inside the <code>MessageBox</code> function as follows:</p> <pre><code>int MessageBox(HWND hwnd, const char* text, const char* caption, UINT type) { GtkWidget *window = NULL; GtkWidget *dialog = NULL; gtk_init(&amp;gtkArgc, &amp;gtkArgv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), &quot;delete_event&quot;, G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(window), &quot;destroy&quot;, G_CALLBACK(destroy), NULL); // gcallback calls gtk_main_quit() gtk_init_add((GtkFunction)gcallback, NULL); if (type &amp; MB_YESNO) { dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, text); } else { dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, text); } gtk_window_set_title(GTK_WINDOW(dialog), caption); gint result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_main(); gtk_widget_destroy(dialog); if (type &amp; MB_YESNO) { switch (result) { default: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_NO: return IDNO; break; case GTK_RESPONSE_YES: return IDYES; break; } } return IDOK; } </code></pre> <p>Now, I am by no means an experienced GTK programmer, and I realize that I'm probably doing something horribly wrong.</p> <p>However, my problem is that the last dialog popped up with this function staying around until the process exits. Any ideas?</p>
[ { "answer_id": 537, "author": "Joe Shaw", "author_id": 156, "author_profile": "https://Stackoverflow.com/users/156", "pm_score": 3, "selected": false, "text": "window" }, { "answer_id": 607, "author": "Joe Shaw", "author_id": 156, "author_profile": "https://Stackoverf...
2008/08/01
[ "https://Stackoverflow.com/questions/263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
265
<p>What are the best practices for checking in BIN directories in a collaborative development environment using SVN? Should project level references be excluded from checkin? Is it easier to just add all bin directories?</p> <p>I develop a lot of DotNetNuke sites and it seems that in a multi-developer environment, it's always a huge task to get the environment setup correctly.</p> <p>The ultimate goal (of course) is to have a new developer checkout the trunk from SVN, restore the DNN database and have it all just 'work'...</p>
[ { "answer_id": 266, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 5, "selected": true, "text": "-Project\n--Project.sln\n--References\n---StructureMap.dll\n---NUnit.dll\n---System.Web.Mvc.dll\n--Project.Web\n---Project.Web.P...
2008/08/01
[ "https://Stackoverflow.com/questions/265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/105/" ]
289
<p>I often have to sort a dictionary (consisting of keys &amp; values) by value. For example, I have a hash of words and respective frequencies that I want to order by frequency.</p> <p>There is a <code>SortedList</code> which is good for a single value (say frequency), that I want to map back to the word.</p> <p><a href="http://msdn.microsoft.com/en-us/library/f7fta44c.aspx" rel="noreferrer">SortedDictionary</a> orders by key, not value. Some resort to a <a href="http://www.codeproject.com/KB/recipes/lookupcollection.aspx" rel="noreferrer">custom class</a>, but is there a cleaner way?</p>
[ { "answer_id": 291, "author": "Kalid", "author_id": 109, "author_profile": "https://Stackoverflow.com/users/109", "pm_score": 7, "selected": false, "text": "foreach (KeyValuePair<string,int> item in keywordCounts.OrderBy(key=> key.Value))\n{ \n // do something with item.Key and item.V...
2008/08/02
[ "https://Stackoverflow.com/questions/289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109/" ]
308
<p>I often run into the following problem.</p> <p>I work on some changes to a project that require new tables or columns in the database. I make the database modifications and continue my work. Usually, I remember to write down the changes so that they can be replicated on the live system. However, I don't always remember what I've changed and I don't always remember to write it down.</p> <p>So, I make a push to the live system and get a big, obvious error that there is no <code>NewColumnX</code>, ugh.</p> <p>Regardless of the fact that this may not be the best practice for this situation, is there a version control system for databases? I don't care about the specific database technology. I just want to know if one exists. If it happens to work with MS SQL Server, then great.</p>
[ { "answer_id": 38419, "author": "Mike Farmer", "author_id": 4082, "author_profile": "https://Stackoverflow.com/users/4082", "pm_score": 3, "selected": false, "text": "DBMS_METADATA.GET_DDL" }, { "answer_id": 141765, "author": "dar7yl", "author_id": 9505, "author_profi...
2008/08/02
[ "https://Stackoverflow.com/questions/308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/106/" ]
328
<p>What are some guidelines for maintaining responsible session security with PHP? There's information all over the web and it's about time it all landed in one place!</p>
[ { "answer_id": 331, "author": "cmcculloh", "author_id": 58, "author_profile": "https://Stackoverflow.com/users/58", "pm_score": 4, "selected": false, "text": "register_globals" }, { "answer_id": 1611, "author": "Teifion", "author_id": 1384652, "author_profile": "https...
2008/08/02
[ "https://Stackoverflow.com/questions/328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59/" ]
336
<p>When is it appropriate to use an unsigned variable over a signed one? What about in a <code>for</code> loop?</p> <p>I hear a lot of opinions about this and I wanted to see if there was anything resembling a consensus. </p> <pre><code>for (unsigned int i = 0; i &lt; someThing.length(); i++) { SomeThing var = someThing.at(i); // You get the idea. } </code></pre> <p>I know Java doesn't have unsigned values, and that must have been a concious decision on <a href="https://en.wikipedia.org/wiki/Sun_Microsystems" rel="noreferrer">Sun Microsystems</a>' part. </p>
[ { "answer_id": 347, "author": "helloandre", "author_id": 50, "author_profile": "https://Stackoverflow.com/users/50", "pm_score": 3, "selected": false, "text": "#declare BIT1 (unsigned int 1)\n#declare BIT32 (unsigned int reallybignumber)\n" }, { "answer_id": 354, "author": "M...
2008/08/02
[ "https://Stackoverflow.com/questions/336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
337
<p>I am about to build a piece of a project that will need to construct and post an XML document to a web service and I'd like to do it in Python, as a means to expand my skills in it. </p> <p>Unfortunately, whilst I know the XML model fairly well in .NET, I'm uncertain what the pros and cons are of the XML models in Python. </p> <p>Anyone have experience doing XML processing in Python? Where would you suggest I start? The XML files I'll be building will be fairly simple.</p>
[ { "answer_id": 342, "author": "saint_groceon", "author_id": 59, "author_profile": "https://Stackoverflow.com/users/59", "pm_score": 6, "selected": true, "text": "for" }, { "answer_id": 202259, "author": "giltay", "author_id": 21106, "author_profile": "https://Stackove...
2008/08/02
[ "https://Stackoverflow.com/questions/337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111/" ]
361
<p>How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.</p> <p>Any language would work, but it should be portable.</p>
[ { "answer_id": 362, "author": "alumb", "author_id": 80, "author_profile": "https://Stackoverflow.com/users/80", "pm_score": 7, "selected": true, "text": "list = originalString.split('')\nindex = (0,0)\nlist = [\"\"]\nfor iteration n in 1 to y:\n index = (index[1], len(list))\n for stri...
2008/08/02
[ "https://Stackoverflow.com/questions/361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
371
<p>This is a tricky one and I've always relied on techniques, such as permission-based emails (i.e. only sending to people you have permission to send to) and not using blatantly <em>spamish</em> terminology.</p> <p>Of late, some of the emails I send out programmatically have started being shuffled into people's spam folder automatically and I'm wondering what I can do about it.</p> <p>This is despite the fact that these particular emails are not ones that humans would mark as spam, specifically, they are emails that contain license keys that people have paid good money for, so I don't think they're going to consider them spam</p> <p>I figure this is a big topic in which I am essentially an ignorant simpleton.</p>
[ { "answer_id": 396, "author": "Michiel de Mare", "author_id": 136, "author_profile": "https://Stackoverflow.com/users/136", "pm_score": 9, "selected": true, "text": "\"John Smith\" <john@blacksmiths-international.com>" }, { "answer_id": 2579555, "author": "Pekka", "author...
2008/08/02
[ "https://Stackoverflow.com/questions/371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49/" ]
387
<p>In Lucene if you had multiple indexes that covered only one partition each. Why does the same search on different indexes return results with different scores? The results from different servers match exactly. </p> <p>i.e. if I searched for :</p> <ul> <li>Name - John Smith</li> <li>DOB - 11/11/1934</li> </ul> <p><strong>Partition 0</strong> would return a score of 0.345</p> <p><strong>Partition 1</strong> would return a score of 0.337</p> <p>Both match exactly on name and DOB.</p>
[ { "answer_id": 551, "author": "Joe Shaw", "author_id": 156, "author_profile": "https://Stackoverflow.com/users/156", "pm_score": 3, "selected": false, "text": "explain()" } ]
2008/08/02
[ "https://Stackoverflow.com/questions/387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134/" ]
402
<p>Please note that this question is from 2008 and now is of only historic interest.</p> <hr> <p>What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?</p> <p>Both programmatically and using the Interface Builder.</p>
[ { "answer_id": 36884, "author": "Michael Pryor", "author_id": 245, "author_profile": "https://Stackoverflow.com/users/245", "pm_score": 5, "selected": false, "text": "<key>UIInterfaceOrientation</key>\n<string>UIInterfaceOrientationLandscapeRight</string>\n" }, { "answer_id": 368...
2008/08/02
[ "https://Stackoverflow.com/questions/402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136/" ]
427
<p>Is there any way to launch IE Mobile's "Favorites" screen directly by specifying any command line parameter?</p>
[ { "answer_id": 5019863, "author": "hellkrusher", "author_id": 620104, "author_profile": "https://Stackoverflow.com/users/620104", "pm_score": 2, "selected": false, "text": "26#\"\\Windows\\iexplore.exe\" -f" } ]
2008/08/02
[ "https://Stackoverflow.com/questions/427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/123/" ]
469
<p>I am using the Photoshop's javascript API to find the fonts in a given PSD.</p> <p>Given a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.</p> <p>This is all happening in a python program running on OSX so I guess I'm looking for one of:</p> <ul> <li>Some Photoshop javascript</li> <li>A Python function</li> <li>An OSX API that I can call from python</li> </ul>
[ { "answer_id": 497, "author": "helloandre", "author_id": 50, "author_profile": "https://Stackoverflow.com/users/50", "pm_score": 3, "selected": false, "text": "locate InsertFontHere\n" }, { "answer_id": 518, "author": "jaredg", "author_id": 153, "author_profile": "htt...
2008/08/02
[ "https://Stackoverflow.com/questions/469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147/" ]
482
<p>Assume you are doing something like the following</p> <pre><code>List&lt;string&gt; myitems = new List&lt;string&gt; { "Item 1", "Item 2", "Item 3" }; ComboBox box = new ComboBox(); box.DataSource = myitems; ComboBox box2 = new ComboBox(); box2.DataSource = myitems </code></pre> <p>So now we have 2 combo boxes bound to that array, and everything works fine. But when you change the value of one combo box, it changes BOTH combo boxes to the one you just selected.</p> <p>Now, I know that Arrays are always passed by reference (learned that when i learned C :D), but why on earth would the combo boxes change together? I don't believe the combo box control is modifying the collection at all. </p> <p>As a workaround, don't this would achieve the functionality that is expected/desired</p> <pre><code>ComboBox box = new ComboBox(); box.DataSource = myitems.ToArray(); </code></pre>
[ { "answer_id": 509, "author": "Robert Höglund", "author_id": 143, "author_profile": "https://Stackoverflow.com/users/143", "pm_score": 6, "selected": true, "text": "BindingContext" }, { "answer_id": 20142, "author": "Quibblesome", "author_id": 1143, "author_profile": ...
2008/08/02
[ "https://Stackoverflow.com/questions/482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77/" ]
502
<p>I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.</p> <p>On the Mac I am spawning <a href="http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="noreferrer">sips</a>. Is there something similarly simple I can do on Windows?</p>
[ { "answer_id": 536, "author": "Federico Builes", "author_id": 161, "author_profile": "https://Stackoverflow.com/users/161", "pm_score": 4, "selected": false, "text": "Convert taxes.pdf taxes.jpg \n" }, { "answer_id": 7090, "author": "C. K. Young", "author_id": 13, "au...
2008/08/02
[ "https://Stackoverflow.com/questions/502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147/" ]
549
<blockquote> <h4>Moderator note:</h4> <p>This question is not a good fit for our question and answer format with the <a href="/help/on-topic">topicality rules</a> which currently apply for Stack Overflow. We normally use a &quot;historical lock&quot; for such questions where the content still has value. However, the answers on this question are actively maintained and a historical lock doesn't permit editing of the answers. As such, a &quot;wiki answer&quot; lock has been applied to allow the answers to be edited. You should assume the topicality issues which are normally handled by a historical lock are present (i.e. this question not a good example of an on-topic question for Stack Overflow).</p> </blockquote> <h2>Form-based authentication for websites</h2> <p>We believe that Stack Overflow should not just be a resource for very specific technical questions, but also for general guidelines on how to solve variations on common problems. &quot;Form based authentication for websites&quot; should be a fine topic for such an experiment.</p> <h3>It should include topics such as:</h3> <ul> <li>How to log in</li> <li>How to log out</li> <li>How to remain logged in</li> <li>Managing cookies (including recommended settings)</li> <li>SSL/HTTPS encryption</li> <li>How to store passwords</li> <li>Using secret questions</li> <li>Forgotten username/password functionality</li> <li>Use of <a href="https://en.wikipedia.org/wiki/Cryptographic_nonce" rel="nofollow noreferrer">nonces</a> to prevent <a href="https://en.wikipedia.org/wiki/Cross-site_request_forgery" rel="nofollow noreferrer">cross-site request forgeries (CSRF)</a></li> <li><a href="http://openid.net/" rel="nofollow noreferrer">OpenID</a></li> <li>&quot;Remember me&quot; checkbox</li> <li>Browser autocompletion of usernames and passwords</li> <li>Secret URLs (public <a href="https://en.wikipedia.org/wiki/Uniform_Resource_Locator" rel="nofollow noreferrer">URL</a> protected by digest)</li> <li>Checking password strength</li> <li>E-mail validation</li> <li><em>and much more about</em> <a href="http://en.wikipedia.org/wiki/Form-based_authentication" rel="nofollow noreferrer">form based authentication</a>...</li> </ul> <h3>It should not include things like:</h3> <ul> <li>Roles and authorization</li> <li>HTTP basic authentication</li> </ul> <h3>Please help us by:</h3> <ol> <li>Suggesting subtopics</li> <li>Submitting good articles about this subject</li> <li>Editing the official answer</li> </ol>
[ { "answer_id": 6984591, "author": "Charlie", "author_id": 139320, "author_profile": "https://Stackoverflow.com/users/139320", "pm_score": 7, "selected": false, "text": "@" }, { "answer_id": 10701801, "author": "Pieter888", "author_id": 192310, "author_profile": "https...
2008/08/02
[ "https://Stackoverflow.com/questions/549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136/" ]
561
<p>I would like to test a function with a tuple from a set of fringe cases and normal values. For example, while testing a function which returns <code>true</code> whenever given three lengths that form a valid triangle, I would have specific cases, negative / small / large numbers, values close-to being overflowed, etc.; what is more, main aim is to generate combinations of these values, <em>with</em> or <em>without</em> repetition, in order to get a set of test data.</p> <pre><code>(inf,0,-1), (5,10,1000), (10,5,5), (0,-1,5), (1000,inf,inf), ... </code></pre> <blockquote> <p><em>As a note: I actually know the answer to this, but it might be helpful for others, and a challenge for people here! --will post my answer later on.</em></p> </blockquote>
[ { "answer_id": 589, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 2, "selected": false, "text": "if f(1,2,3) returns true" }, { "answer_id": 794, "author": "nlucaroni", "author_id": 157, "author_profi...
2008/08/02
[ "https://Stackoverflow.com/questions/561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/157/" ]
564
<p>I was reading <em><a href="https://rads.stackoverflow.com/amzn/click/com/1430209879" rel="noreferrer" rel="nofollow noreferrer">More Joel on Software</a></em> when I came across <a href="http://en.wikipedia.org/wiki/Joel_Spolsky" rel="noreferrer">Joel Spolsky</a> saying something about a particular type of programmer knowing the difference between an <code>int</code> and an <code>Integer</code> in Java/C# (Object-Oriented Programming Languages).</p> <p>So, what is the difference?</p>
[ { "answer_id": 566, "author": "Matt", "author_id": 154, "author_profile": "https://Stackoverflow.com/users/154", "pm_score": 9, "selected": true, "text": "System.Int32" }, { "answer_id": 568, "author": "cmcculloh", "author_id": 58, "author_profile": "https://Stackover...
2008/08/02
[ "https://Stackoverflow.com/questions/564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
588
<p>I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used <a href="http://en.wikipedia.org/wiki/WebDAV" rel="noreferrer">WebDAV</a> to do it, but now I'm leaning away from that.</p> <p>I will be running the site on IIS OR Apache (no preference) on Windows server 2008. A few things I would need to do include adding contacts to a given user's address book, sending emails as a given user and running reports on contacts for a user.</p> <p>All of this is pretty easy to do with WebDAV, but if there is a better way that doesn't require any functionality that is likely to be deprecated any time soon.</p> <p>Any ideas?</p> <h3>Update:</h3> <p>Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...</p> <p>John, I can write a web service in C# to interface with for these functions and access it with my PHP app, but it's also a little bit out of the way.</p> <p>So far, I'm not 100% convinced that either of these is better than WebDAV...</p> <p>Can anyone show me where I'm being silly?</p>
[ { "answer_id": 611, "author": "Justin Walgran", "author_id": 173, "author_profile": "https://Stackoverflow.com/users/173", "pm_score": 3, "selected": false, "text": "$outlook = COM(\"Outlook.Application\")\n" } ]
2008/08/03
[ "https://Stackoverflow.com/questions/588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/172/" ]
594
<p>There are several ways to iterate over a result set. What are the tradeoff of each?</p>
[ { "answer_id": 595, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 7, "selected": true, "text": "curs.execute('select * from people')\nfor row in curs:\n print row\n" }, { "answer_id": 25213, "author": "And...
2008/08/03
[ "https://Stackoverflow.com/questions/594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
601
<p>I'm looking for a performant, reasonably robust RNG using no special hardware. It can use mathematical methods (Mersenne Twister, etc), it can "collect entropy" from the machine, whatever. On Linux/etc we have a <code>drand48()</code> which generates 48 random bits. I'd like a similar function/class for C++ or C# which can generate more than 32 bits of randomness and which low-order bits are equally as random as high-order bits.</p> <p>It doesn't have to be cryptographically secure but it must not use or be based on the C-language <code>rand()</code> or .NET <code>System.Random</code>.</p> <p>Any source code, links to source, etc. would be appreciated! Failing that, what TYPE of RNG should I be looking for?</p>
[ { "answer_id": 602, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 6, "selected": true, "text": "nondet_random" }, { "answer_id": 9923618, "author": "Rohit Vipin Mathews", "author_id": 1155650, "author_pro...
2008/08/03
[ "https://Stackoverflow.com/questions/601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
609
<p>An MFC application that I'm trying to migrate uses <code>afxext.h</code>, which causes <code>_AFXDLL</code> to get set, which causes this error if I set <code>/MT</code>:</p> <blockquote> <p>Please use the /MD switch for _AFXDLL builds</p> </blockquote> <p>My research to date indicates that it is impossible to build an application for execution on Windows NT 4.0 using Visual Studio (C++, in this case) 2005.</p> <p>Is this really true? Are there any workaround available?</p>
[ { "answer_id": 200955, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 2, "selected": false, "text": "GetLongPathNameW" } ]
2008/08/03
[ "https://Stackoverflow.com/questions/609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179/" ]
622
<p>I want to print the first 10000 prime numbers. Can anyone give me the most efficient code for this? Clarifications:</p> <ol> <li>It does not matter if your code is inefficient for n >10000.</li> <li>The size of the code does not matter.</li> <li>You cannot just hard code the values in any manner.</li> </ol>
[ { "answer_id": 791, "author": "engtech", "author_id": 175, "author_profile": "https://Stackoverflow.com/users/175", "pm_score": 3, "selected": false, "text": "/^1?$|^(11+?)\\1+$/\n" }, { "answer_id": 2753, "author": "GateKiller", "author_id": 383, "author_profile": "h...
2008/08/03
[ "https://Stackoverflow.com/questions/622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
626
<p>In Ruby 1.8, there are subtle differences between proc/lambda on the one hand, and <code>Proc.new</code> on the other. </p> <ul> <li>What are those differences?</li> <li>Can you give guidelines on how to decide which one to choose?</li> <li>In Ruby 1.9, proc and lambda are different. What's the deal?</li> </ul>
[ { "answer_id": 629, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 5, "selected": false, "text": "Proc.new" }, { "answer_id": 723, "author": "Joey deVilla", "author_id": 216, "author_profile": "https://St...
2008/08/03
[ "https://Stackoverflow.com/questions/626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136/" ]
644
<p>I have a database table and one of the fields (not the primary key) is having a unique index on it. Now I want to swap values under this column for two rows. How could this be done? Two hacks I know are:</p> <ol> <li>Delete both rows and re-insert them.</li> <li>Update rows with some other value and swap and then update to actual value.</li> </ol> <p>But I don't want to go for these as they do not seem to be the appropriate solution to the problem. Could anyone help me out?</p>
[ { "answer_id": 73258, "author": "Andy Irving", "author_id": 8553, "author_profile": "https://Stackoverflow.com/users/8553", "pm_score": 2, "selected": false, "text": "CREATE TABLE testing\n(\n cola int NOT NULL,\n colb CHAR(1) NOT NULL\n);\n\nCREATE UNIQUE INDEX UIX_testing_a ON te...
2008/08/03
[ "https://Stackoverflow.com/questions/644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
650
<p>I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. </p> <p>I'm also using a settings file and in earlier attempts when the assembly version changed my settings got reset to the default since the application looked for the settings file in another directory. </p> <p>I would like to be able to display a version number in the form of 1.1.38 so when a user finds a problem I can log the version they are using as well as tell them to upgrade if they have an old release.</p> <p>A short explanation of how the versioning works would also be appreciated. When does the build and revision number get incremented?</p>
[ { "answer_id": 655, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 8, "selected": true, "text": "Version v = Assembly.GetExecutingAssembly().GetName().Version;\nstring About = string.Format(CultureInfo.InvariantCulture, @\"Y...
2008/08/03
[ "https://Stackoverflow.com/questions/650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/143/" ]
651
<p>I've been having trouble getting my ASP.NET application to automatically log users into the Intranet site I'm building. No matter the googling or the experimentation I applied, there is always a login box displayed by IE7.</p> <p>I've got Windows authentication mode set in the Web.config, disabled anonymous access and configured the correct default domain in IIS, but it's still asking the user to log in and, more annoyingly, the user is required to provide the domain too (<em>DOMAIN\auser</em>), which is causing problems with non-technical visitors. Thank Zeus for password remembering functionality.</p> <p>I'm not the network administrator so it's possible that something about Active Directory is set up incorrectly, or it could just be me missing something very simple. Please note that I don't want to impersonate the user, I just need to know that the IPrincipal.Name property matches that of a valid record in my user database, hence authenticating the user to my application.</p> <p>To this end, it would be very useful to have a checklist of all configuration requirements for AD, ASP.NET and IIS to work together in this manner as a reference for debugging and hopefully reducing some user friction.</p>
[ { "answer_id": 90759, "author": "Dani", "author_id": 17330, "author_profile": "https://Stackoverflow.com/users/17330", "pm_score": 1, "selected": false, "text": "Active Directory Users and Computers" } ]
2008/08/03
[ "https://Stackoverflow.com/questions/651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
657
<p>What is the fastest, yet secure way to encrypt passwords (in PHP preferably), and for whichever method you choose, is it portable?</p> <p>In other words, if I later migrate my website to a different server, will my passwords continue to work?</p> <p>The method I am using now, as I was told, is dependent on the exact versions of the libraries installed on the server.</p>
[ { "answer_id": 85951, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 3, "selected": false, "text": "password1" }, { "answer_id": 38409027, "author": "Kamil Kiełczewski", "author_id": 860099, "author_pro...
2008/08/03
[ "https://Stackoverflow.com/questions/657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
683
<p>I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,</p> <pre><code>foo in iter_attr(array of python objects, attribute name)</code></pre> <p>I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers</p>
[ { "answer_id": 701, "author": "saalon", "author_id": 111, "author_profile": "https://Stackoverflow.com/users/111", "pm_score": 3, "selected": false, "text": " files = os.listdir(path) \n test = re.compile(\"test\\.py$\", re.IGNORECASE) \n f...
2008/08/03
[ "https://Stackoverflow.com/questions/683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/199/" ]
705
<p>I was (and still am) looking for an embedded database to be used in a .net (c#) application. The caveat: The Application (or at least the database) is stored on a Network drive, but only used by 1 user at a time.</p> <p>Now, my first idea was <a href="http://www.microsoft.com/sql/editions/compact/default.mspx" rel="nofollow noreferrer">SQL Server Compact edition</a>. That is really nicely integreated, but it can not run off a network.</p> <p><a href="http://web.archive.org/web/20100615004036/http://firebirdsql.org/dotnetfirebird/" rel="nofollow noreferrer">Firebird</a> seems to have the same issue, but the .net Integration seems to be not really first-class and is largely undocumented.</p> <p><a href="http://web.archive.org/web/20150510070451/http://www.codegear.com/products/blackfish" rel="nofollow noreferrer">Blackfish SQL</a> looks interesting, but there is no trial of the .net Version. Pricing is also OK.</p> <p>Any other suggestions of something that works well with .net <strong>and</strong> runs off a network without the need of actually installing a server software?</p>
[ { "answer_id": 737, "author": "Justin Walgran", "author_id": 173, "author_profile": "https://Stackoverflow.com/users/173", "pm_score": 3, "selected": false, "text": "Dim catalog as New ADOX.Catalog\nCatalog.Create(\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\server\\path\\to\\db.md...
2008/08/03
[ "https://Stackoverflow.com/questions/705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
717
<p>I wrote a windows service using VB that read some legacy data from Visual Foxpro Databases to be inserted in SQL 2005. The problem is this use to run fine in Windows server 2003 32-Bits, but the client recently moved to Windows 2003 64-Bits and now the service won't work. I'm getting a message the the VFP .NET OLEdb provider is not found. I researched and everything seems to point out that there is no solution. Any Help, please...</p>
[ { "answer_id": 799, "author": "Paul G", "author_id": 162, "author_profile": "https://Stackoverflow.com/users/162", "pm_score": 5, "selected": true, "text": "x86" }, { "answer_id": 877, "author": "Chris Miller", "author_id": 206, "author_profile": "https://Stackoverflo...
2008/08/03
[ "https://Stackoverflow.com/questions/717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
742
<p><a href="http://www.djangoproject.com/" rel="noreferrer">Django</a> view points to a function, which can be a problem if you want to change only a bit of functionality. Yes, I could have million keyword arguments and even more if statements in the function, but I was thinking more of an object oriented approach.</p> <p>For example, I have a page that displays a user. This page is very similar to page that displays a group, but it's still not so similar to just use another data model. Group also has members etc...</p> <p>One way would be to point views to class methods and then extend that class. Has anyone tried this approach or has any other idea? </p>
[ { "answer_id": 27792, "author": "dguaraglia", "author_id": 2384, "author_profile": "https://Stackoverflow.com/users/2384", "pm_score": 2, "selected": false, "text": "__call__" }, { "answer_id": 33957, "author": "Carl Meyer", "author_id": 3207, "author_profile": "https...
2008/08/03
[ "https://Stackoverflow.com/questions/742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189/" ]
746
<p>How do I format a string to <a href="http://www.grammar-monster.com/lessons/capital_letters_title_case.htm" rel="noreferrer">title case</a>?</p>
[ { "answer_id": 747, "author": "tags2k", "author_id": 192, "author_profile": "https://Stackoverflow.com/users/192", "pm_score": 4, "selected": false, "text": "public static string ToTitleCaseInvariant(string targetString)\n{\n return System.Threading.Thread.CurrentThread.CurrentCulture...
2008/08/03
[ "https://Stackoverflow.com/questions/746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
752
<p>One may not always know the <code>Type</code> of an object at compile-time, but may need to create an instance of the <code>Type</code>. </p> <p>How do you get a new object instance from a <code>Type</code>?</p>
[ { "answer_id": 755, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 11, "selected": true, "text": "Activator" }, { "answer_id": 26031, "author": "Tom Mayfield", "author_id": 2314, "author_profile": "https:/...
2008/08/03
[ "https://Stackoverflow.com/questions/752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
761
<p>What is the best way to localise a date format descriptor?</p> <p>As anyone from a culture which does not use the mm/dd/yyyy format knows, it is annoying to have to enter dates in this format. The .NET framework provides some very good localisation support, so it's trivial to parse dates according to the users culture, but you often want to also display a helpful hint as to the format required (especially to distinguish between yy and yyyy which is interchangeable in most cultures).</p> <p>What is the best way to do this in a way that make sense to most users (e.g. dd/M/yyy is confusing because of the change in case and the switching between one and two letters).</p>
[ { "answer_id": 762, "author": "ICR", "author_id": 214, "author_profile": "https://Stackoverflow.com/users/214", "pm_score": 3, "selected": true, "text": "Regex singleMToDoubleRegex = new Regex(\"(?<!m)m(?!m)\");\nRegex singleDToDoubleRegex = new Regex(\"(?<!d)d(?!d)\");\nCultureInfo curr...
2008/08/03
[ "https://Stackoverflow.com/questions/761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/214/" ]
766
<p>I can get Python to work with Postgresql but I cannot get it to work with MySQL. The main problem is that on the shared hosting account I have I do not have the ability to install things such as Django or PySQL, I generally fail when installing them on my computer so maybe it's good I can't install on the host.</p> <p>I found <a href="http://barryp.org/software/bpgsql/" rel="noreferrer">bpgsql</a> really good because it does not require an install, it's a single file that I can look at, read and then call the functions of. Does anybody know of something like this for MySQL?</p>
[ { "answer_id": 777, "author": "ESV", "author_id": 150, "author_profile": "https://Stackoverflow.com/users/150", "pm_score": 3, "selected": false, "text": "#!/usr/bin/python\n\nmodule_name = 'MySQLdb'\nhead = '''Content-Type: text/html\n\n%s is ''' % module_name\n\ntry:\n __import__(mo...
2008/08/03
[ "https://Stackoverflow.com/questions/766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
769
<p>I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++.</p> <p>Here's an example of the equations:</p> <pre><code>-44.3940 = a * 50.0 + b * 37.0 + tx -45.3049 = a * 43.0 + b * 39.0 + tx -44.9594 = a * 52.0 + b * 41.0 + tx </code></pre> <p>From this, I'd like to get the best approximation for <code>a</code>, <code>b</code>, and <code>tx</code>.</p>
[ { "answer_id": 26637, "author": "Baltimark", "author_id": 1179, "author_profile": "https://Stackoverflow.com/users/1179", "pm_score": 2, "selected": false, "text": "void GetInverse(const Array2D<double>& A, Array2D<double>& invA)\n {\n QR<double> qr(A); \n invA = qr.solve(I); \n ...
2008/08/03
[ "https://Stackoverflow.com/questions/769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79/" ]
773
<p>I haven't been able to find an understandable explanation of how to actually use Python's <code>itertools.groupby()</code> function. What I'm trying to do is this:</p> <ul> <li>Take a list - in this case, the children of an objectified <code>lxml</code> element</li> <li>Divide it into groups based on some criteria</li> <li>Then later iterate over each of these groups separately.</li> </ul> <p>I've reviewed <a href="https://docs.python.org/3/library/itertools.html#itertools.groupby" rel="noreferrer">the documentation</a>, but I've had trouble trying to apply them beyond a simple list of numbers.</p> <p>So, how do I use of <code>itertools.groupby()</code>? Is there another technique I should be using? Pointers to good &quot;prerequisite&quot; reading would also be appreciated.</p>
[ { "answer_id": 783, "author": "Seb", "author_id": 189, "author_profile": "https://Stackoverflow.com/users/189", "pm_score": 6, "selected": false, "text": "groups = []\nuniquekeys = []\nfor k, g in groupby(data, keyfunc):\n groups.append(list(g)) # Store group iterator as a list\n...
2008/08/03
[ "https://Stackoverflow.com/questions/773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207/" ]
810
<p>I'm trying to maintain a Setup Project in <code>Visual Studio 2003</code> (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to <code>HKCU</code> for every user on the computer. They need to be in the <code>HKCU</code> rather than <code>HKLM</code> because they are the default user settings, and they do change per user. My feeling is that</p> <ol> <li>This isn't possible</li> <li>This isn't something the installer should be doing, but something the application should be doing (after all what happens when a user profile is created after the install?).</li> </ol> <p>With that in mind, I still want to change as little as possible in the application, so my question is, <strong>is it possible to add registry entries for every user in a <code>Visual Studio 2003</code> setup project?</strong> </p> <p>And, at the moment the project lists five registry root keys (<code>HKEY_CLASSES_ROOT, HKEY_CURRENT_USER</code>, <code>HKEY_LOCAL_MACHINE</code>, <code>HKEY_USERS</code>, and User/Machine Hive). I don't really know anything about the Users root key, and haven't seen User/Machine Hive. Can anyone enlighten me on what they are? Perhaps they could solve my problem above.</p>
[ { "answer_id": 820, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 4, "selected": true, "text": "const HKEY_USERS = &H80000003\nstrComputer = \".\"\nSet objReg=GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\\" & s...
2008/08/03
[ "https://Stackoverflow.com/questions/810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/233/" ]
826
<p>You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like.</p> <p>To be clear, I'm interested in the algorithm. Feel free to post code in any language and paradigm that you like.</p>
[ { "answer_id": 840, "author": "Peter Burns", "author_id": 101, "author_profile": "https://Stackoverflow.com/users/101", "pm_score": 1, "selected": false, "text": "matrixOfSums list = [[a+b | b <- list, b >= a] | a <- list]\n\nsortedSums = foldl merge [] matrixOfSums\n\n--A normal merge, ...
2008/08/03
[ "https://Stackoverflow.com/questions/826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/101/" ]
832
<p>SQL:</p> <pre><code>SELECT u.id, u.name, isnull(MAX(h.dateCol), '1900-01-01') dateColWithDefault FROM universe u LEFT JOIN history h ON u.id=h.id AND h.dateCol&lt;GETDATE()-1 GROUP BY u.Id, u.name </code></pre>
[ { "answer_id": 837, "author": "vzczc", "author_id": 224, "author_profile": "https://Stackoverflow.com/users/224", "pm_score": 4, "selected": true, "text": "var collection=\n from u in db.Universe\n select new\n {\n u.id,\n u.name,\n MaxDate =(DateTime?)\n ...
2008/08/03
[ "https://Stackoverflow.com/questions/832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/224/" ]
833
<p>I have designed database tables (normalised, on an MS SQL server) and created a standalone windows front end for an application that will be used by a handful of users to add and edit information. We will add a web interface to allow searching accross our production area at a later date.</p> <p>I am concerned that if two users start editing the same record then the last to commit the update would be the 'winner' and important information may be lost. A number of solutions come to mind but I'm not sure if I am going to create a bigger headache.</p> <ol> <li>Do nothing and hope that two users are never going to be editing the same record at the same time. <em>- Might never happed but what if it does?</em></li> <li>Editing routine could store a copy of the original data as well as the updates and then compare when the user has finished editing. If they differ show user and comfirm update <em>- Would require two copies of data to be stored.</em></li> <li>Add last updated DATETIME column and check it matches when we update, if not then show differences. <em>- requires new column in each of the relevant tables.</em></li> <li>Create an editing table that registers when users start editing a record that will be checked and prevent other users from editing same record. <em>- would require carful thought of program flow to prevent deadlocks and records becoming locked if a user crashes out of the program.</em></li> </ol> <p>Are there any better solutions or should I go for one of these?</p>
[ { "answer_id": 1620, "author": "karlgrz", "author_id": 318, "author_profile": "https://Stackoverflow.com/users/318", "pm_score": 2, "selected": false, "text": "SELECT ... FOR UPDATE" }, { "answer_id": 10437, "author": "Guy", "author_id": 993, "author_profile": "https:...
2008/08/03
[ "https://Stackoverflow.com/questions/833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186/" ]
835
<p>I'm trying to setup CruiseControl.net at the moment. So far it works nice, but I have a Problem with the MSBuild Task.</p> <p>According to the <a href="http://confluence.public.thoughtworks.org/display/CCNET/MsBuild+Task" rel="noreferrer">Documentation</a>, it passes CCNetArtifactDirectory to MSBuild. But how do I use it?</p> <p>I tried this:</p> <pre><code>&lt;buildArgs&gt; /noconsolelogger /p:OutputPath=$(CCNetArtifactDirectory)\test &lt;/buildArgs&gt; </code></pre> <p>But that does not work. In fact, it kills the service with this error:</p> <blockquote> <p>ThoughtWorks.CruiseControl.Core.Config.Preprocessor.EvaluationException: Reference to unknown symbol CCNetArtifactDirectory</p> </blockquote> <p>Documentation is rather sparse, and google und mainly offers modifying the .sln Project file, which is what I want to avoid in order to be able to manually build this project later - I would really prefer <code>/p:OutputPath</code>.</p>
[ { "answer_id": 1023, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 4, "selected": true, "text": "<executable>c:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\MSBuild.exe</executable>\n<workingDirectory>C:\\data\\projects\\FooSolut...
2008/08/03
[ "https://Stackoverflow.com/questions/835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
845
<p>Suppose I have the following CSS rule in my page:</p> <pre class="lang-css prettyprint-override"><code>body { font-family: Calibri, Trebuchet MS, Helvetica, sans-serif; } </code></pre> <p>How could I detect which one of the defined fonts were used in the user's browser?</p> <p>For people wondering why I want to do this is because the font I'm detecting contains glyphs that are <em>not</em> available in other fonts. If the user does <em>not</em> have the font, then I want it to display a link asking the user to download that font (so they can use my web application with the correct font).</p> <p>Currently, I am displaying the download font link for all users. I want to only display this for people who do <em>not</em> have the correct font installed.</p>
[ { "answer_id": 27035, "author": "runeh", "author_id": 2906, "author_profile": "https://Stackoverflow.com/users/2906", "pm_score": 4, "selected": false, "text": "/**\n * Get the font used for a given element\n * @argument {HTMLElement} the element to check font for\n * @returns {string} T...
2008/08/03
[ "https://Stackoverflow.com/questions/845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238/" ]
871
<p>I've been using <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="nofollow noreferrer">Subversion</a> for a few years and after using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_SourceSafe" rel="nofollow noreferrer">SourceSafe</a>, I just love Subversion. Combined with <a href="http://en.wikipedia.org/wiki/TortoiseSVN" rel="nofollow noreferrer">TortoiseSVN</a>, I can't really imagine how it could be any better. </p> <p>Yet there's a growing number of developers claiming that Subversion has problems and that we should be moving to the new breed of distributed version control systems, such as <a href="http://git.or.cz/" rel="nofollow noreferrer" title="Git Distributed Version Control System">Git</a>. </p> <p>How does Git improve upon Subversion?</p>
[ { "answer_id": 162148, "author": "Andre Bossard", "author_id": 21027, "author_profile": "https://Stackoverflow.com/users/21027", "pm_score": 4, "selected": false, "text": "backup/public" }, { "answer_id": 531042, "author": "sebnow", "author_id": 64423, "author_profile...
2008/08/03
[ "https://Stackoverflow.com/questions/871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203/" ]
879
<p>Are PHP variables passed by value or by reference?</p>
[ { "answer_id": 881, "author": "cmcculloh", "author_id": 58, "author_profile": "https://Stackoverflow.com/users/58", "pm_score": 5, "selected": false, "text": "$var1 = \"test\";\n$var2 = $var1;\n$var2 = \"new test\";\n$var3 = &$var2;\n$var3 = \"final test\";\n\nprint (\"var1: $var1, var2:...
2008/08/03
[ "https://Stackoverflow.com/questions/879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
888
<p>How do you debug <strong>PHP</strong> scripts?</p> <p>I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in <strong>PHPEclipse</strong> is also quite useful.</p> <p>What is the <strong>best</strong> (in terms of fast and easy) way to debug in phpStorm or any other IDE?</p>
[ { "answer_id": 890, "author": "John Downey", "author_id": 200, "author_profile": "https://Stackoverflow.com/users/200", "pm_score": 8, "selected": true, "text": "var_dump()" }, { "answer_id": 1758, "author": "Polsonby", "author_id": 137, "author_profile": "https://Sta...
2008/08/03
[ "https://Stackoverflow.com/questions/888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131/" ]
898
<p>How have you implemented Internationalization (i18n) in actual projects you've worked on?</p> <p>I took an interest in making software cross-cultural after I read the famous post by Joel, <a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="noreferrer">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</a>. However, I have yet to able to take advantage of this in a real project, besides making sure I used Unicode strings where possible. But making all your strings Unicode and ensuring you understand what encoding everything you work with is in is just the tip of the i18n iceberg.</p> <p>Everything I have worked on to date has been for use by a controlled set of US English speaking people, or i18n just wasn't something we had time to work on before pushing the project live. So I am looking for any tips or war stories people have about making software more localized in real world projects.</p>
[ { "answer_id": 906, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 3, "selected": false, "text": "String message = \"The \" + item + \" is on sale!\";\n" } ]
2008/08/04
[ "https://Stackoverflow.com/questions/898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/200/" ]
904
<p>Given a relatively simple CSS:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>div { width: 150px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; 12333-2333-233-23339392-332332323 &lt;/div&gt;</code></pre> </div> </div> </p> <blockquote> <p>How do I make it so that the string stays constrained to the <code>width</code> of <strong>150</strong>, and wraps to a new line on the <em>hyphen</em>?</p> </blockquote>
[ { "answer_id": 911, "author": "Ryan Fox", "author_id": 55, "author_profile": "https://Stackoverflow.com/users/55", "pm_score": 7, "selected": true, "text": "&shy;\n" }, { "answer_id": 67878, "author": "Dave Rutledge", "author_id": 2486915, "author_profile": "https://S...
2008/08/04
[ "https://Stackoverflow.com/questions/904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34/" ]
930
<p>What's the simplest way to connect and query a database for a set of records in C#?</p>
[ { "answer_id": 940, "author": "Goyuix", "author_id": 243, "author_profile": "https://Stackoverflow.com/users/243", "pm_score": 4, "selected": false, "text": "using (OleDBConnection conn = new OleDbConnection())\n{\n conn.ConnectionString = \"Whatever connection string\";\n\n using (Ole...
2008/08/04
[ "https://Stackoverflow.com/questions/930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/245/" ]
935
<p>Attempting to insert an escape character into a table results in a warning. </p> <p>For example:</p> <pre><code>create table EscapeTest (text varchar(50)); insert into EscapeTest (text) values ('This is the first part \n And this is the second'); </code></pre> <p>Produces the warning:</p> <pre><code>WARNING: nonstandard use of escape in a string literal </code></pre> <p>(<em>Using PSQL 8.2</em>)</p> <p>Anyone know how to get around this?</p>
[ { "answer_id": 938, "author": "rjohnston", "author_id": 246, "author_profile": "https://Stackoverflow.com/users/246", "pm_score": 8, "selected": true, "text": "insert into EscapeTest (text) values (E'This is the first part \\n And this is the second');\n" }, { "answer_id": 104780...
2008/08/04
[ "https://Stackoverflow.com/questions/935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/246/" ]
944
<p>I'm maintaining a .NET 1.1 application and one of the things I've been tasked with is making sure the user doesn't see any unfriendly error notifications.</p> <p>I've added handlers to <code>Application.ThreadException</code> and <code>AppDomain.CurrentDomain.UnhandledException</code>, which do get called. My problem is that the standard CLR error dialog is still displayed (before the exception handler is called).</p> <p>Jeff talks about this problem on his blog <a href="https://blog.codinghorror.com/console-apps-and-appdomain-currentdomain-unhandledexception/" rel="noreferrer">here</a> and <a href="https://blog.codinghorror.com/improved-unhandled-exception-behavior-in-net-20/" rel="noreferrer">here</a>. But there's no solution. So what is the standard way in .NET 1.1 to handle uncaught exceptions and display a friendly dialog box?</p> <p>Jeff's response was marked as the correct answer because the link he provided has the most complete information on how to do what's required.</p>
[ { "answer_id": 108550, "author": "HTTP 410", "author_id": 13118, "author_profile": "https://Stackoverflow.com/users/13118", "pm_score": 3, "selected": false, "text": "App.Config" }, { "answer_id": 70889762, "author": "Umar Hassan", "author_id": 1520030, "author_profil...
2008/08/04
[ "https://Stackoverflow.com/questions/944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/233/" ]
947
<p>I have imported the <code>kernel32</code> library. So, I have the <code>createMutex</code> function available but I am not quite sure of the various parameters and return values.</p> <p>This is classic Visual Basic, not Visual Basic.NET but I can probably work with either language in the form of an answer.</p>
[ { "answer_id": 1028, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "hMutex = CreateMutex(ByVal 0&, 1, ByVal 0&)\n" }, { "answer_id": 82335, "author": "MarkJ", "author_id": 15639, ...
2008/08/04
[ "https://Stackoverflow.com/questions/947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/243/" ]
972
<p>I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python. </p> <p>I understand that it's not always good to do so. But how might one do this?</p>
[ { "answer_id": 982, "author": "John Downey", "author_id": 200, "author_profile": "https://Stackoverflow.com/users/200", "pm_score": 5, "selected": false, "text": "from SomeOtherProduct.SomeModule import SomeClass\ndef speak(self):\n return \"ook ook eee eee eee!\"\nSomeClass.speak = sp...
2008/08/04
[ "https://Stackoverflow.com/questions/972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145/" ]
1,005
<p>Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type</p> <pre><code>sudo vi filename </code></pre> <p>Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find it.</p>
[ { "answer_id": 1012, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "sudoedit" }, { "answer_id": 1065, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://...
2008/08/04
[ "https://Stackoverflow.com/questions/1005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
1,010
<p>I need to grab the <code>base64-encoded</code> representation of the <code>ViewState</code>. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.</p> <p>For example, if the output of the page includes:</p> <pre><code>&lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJODU0Njc5MD...==" /&gt; </code></pre> <p>I need a way on the server-side to get the value <code>"/wEPDwUJODU0Njc5MD...=="</code></p> <p>To clarify, I need this value when the page is being rendered, not on PostBack. e.g. I need to know the ViewState value that is being <em>sent</em> to the client, not the ViewState I'm getting back from them.</p>
[ { "answer_id": 2058, "author": "Dave Anderson", "author_id": 371, "author_profile": "https://Stackoverflow.com/users/371", "pm_score": 2, "selected": false, "text": "protected override void SavePageStateToPersistenceMedium(object viewState)\n" } ]
2008/08/04
[ "https://Stackoverflow.com/questions/1010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67/" ]
1,024
<p>After upgrading a rails 1.2 website to 2.1, the <a href="http://agilewebdevelopment.com/plugins/exception_notifier" rel="noreferrer">ExceptionNotifier plugin</a> no longer works, complaining about this error:</p> <blockquote> <p>ActionView::TemplateFinder::InvalidViewPath: Unprocessed view path found: "/path/to/appname/vendor/plugins/exception_notification/lib/../views". Set your view paths with #append_view_path, #prepend_view_path, or #view_paths=.</p> </blockquote> <p>What causes it and how do I fix it?</p>
[ { "answer_id": 1026, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "init.rb" } ]
2008/08/04
[ "https://Stackoverflow.com/questions/1024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
1,033
<p>Does anyone know any simple way to retrieve the country from a given IP Address, preferably in ISO_3166-1 format?</p>
[ { "answer_id": 2056874, "author": "Niklas Rosencrantz", "author_id": 108207, "author_profile": "https://Stackoverflow.com/users/108207", "pm_score": 2, "selected": false, "text": "latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitud...
2008/08/04
[ "https://Stackoverflow.com/questions/1033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/87/" ]
1,040
<p>I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#) then close that process before being able to complete the file delete using <code>File.Delete()</code>.</p>
[ { "answer_id": 1043, "author": "Ryan Fox", "author_id": 55, "author_profile": "https://Stackoverflow.com/users/55", "pm_score": 3, "selected": false, "text": "REGEDT32 (W2K)" }, { "answer_id": 1044, "author": "Ishmaeel", "author_id": 227, "author_profile": "https://St...
2008/08/04
[ "https://Stackoverflow.com/questions/1040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254/" ]
1,041
<p>I'm looking for a robust, easy-to-use, regular expression evaluator for native C++, either platform-independent or Windows-specific.</p> <p>Requirements:</p> <ul> <li>Can't use Boost or ACE regex libraries (unfortunately)</li> <li>Can't use .NET Regex (or any managed code)</li> </ul> <p>The main requirement is that it should be standalone and open.</p>
[ { "answer_id": 7564, "author": "martinsb", "author_id": 837, "author_profile": "https://Stackoverflow.com/users/837", "pm_score": 2, "selected": false, "text": "CAtlRegExp" }, { "answer_id": 37100978, "author": "Trevor Hickey", "author_id": 908939, "author_profile": "...
2008/08/04
[ "https://Stackoverflow.com/questions/1041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]