Dataset Viewer
Auto-converted to Parquet Duplicate
qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
sequence
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/" ]
End of preview. Expand in Data Studio

Dataset Card for "stack-exchange-preferences-code-v2"

More Information needed

Downloads last month
35