-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestInput.xml
101 lines (101 loc) · 114 KB
/
TestInput.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?xml version="1.0" encoding="utf-8"?>
<posts>
<row Id="4" PostTypeId="1" AcceptedAnswerId="7" CreationDate="2008-07-31T21:42:52.667" Score="421" ViewCount="28370" Body="<p>I want to use a track-bar to change a form's opacity.</p>

<p>This is my code:</p>

<pre><code>decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;
</code></pre>

<p>When I try to build it, I get this error:</p>

<blockquote>
 <p>Cannot implicitly convert type 'decimal' to 'double'.</p>
</blockquote>

<p>I tried making <code>trans</code> a <code>double</code>, but then the control doesn't work. This code has worked fine for me in VB.NET in the past. </p>
" OwnerUserId="8" LastEditorUserId="5455605" LastEditorDisplayName="Rich B" LastEditDate="2015-12-23T21:34:28.557" LastActivityDate="2016-07-17T20:33:18.217" Title="When setting a form's opacity should I use a decimal or double?" Tags="<c#><winforms><type-conversion><decimal><opacity>" AnswerCount="13" CommentCount="3" FavoriteCount="33" CommunityOwnedDate="2012-10-31T16:42:47.213" />
<row Id="6" PostTypeId="1" AcceptedAnswerId="31" CreationDate="2008-07-31T22:08:08.620" Score="189" ViewCount="13715" Body="<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 <strong>percentage-based width</strong> on the child <code>div</code>, it collapses to '0' width on <a href="http://en.wikipedia.org/wiki/Internet_Explorer_7">Internet&nbsp;Explorer&nbsp;7</a>, but not on Firefox or Safari.</p>

<p>If I use <strong>pixel width</strong>, 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 <em>pixel-based width</em> on the
child?</li>
<li>Is there an area of the CSS specification that covers this?</li>
</ol>
" OwnerUserId="9" LastEditorUserId="63550" LastEditorDisplayName="Rich B" LastEditDate="2016-03-19T06:05:48.487" LastActivityDate="2016-03-19T06:10:52.170" Title="Percentage width child element in absolutely positioned parent on Internet Explorer 7" Tags="<html><css><css3><internet-explorer-7>" AnswerCount="5" CommentCount="0" FavoriteCount="7" />
<row Id="7" PostTypeId="2" ParentId="4" CreationDate="2008-07-31T22:17:57.883" Score="305" Body="<p>An explicit cast to double isn't necessary.</p>

<pre><code>double trans = (double)trackBar1.Value / 5000.0;
</code></pre>

<p>Identifying the constant as <code>5000.0</code> (or as <code>5000d</code>) is sufficient:</p>

<pre><code>double trans = trackBar1.Value / 5000.0;
double trans = trackBar1.Value / 5000d;
</code></pre>
" OwnerUserId="9" LastEditorUserId="967315" LastEditDate="2012-10-14T11:50:16.703" LastActivityDate="2012-10-14T11:50:16.703" CommentCount="1" />
<row Id="9" PostTypeId="1" AcceptedAnswerId="1404" CreationDate="2008-07-31T23:40:59.743" Score="1313" ViewCount="336831" Body="<p>Given a <code>DateTime</code> representing a person's birthday, how do I calculate their age? </p>
" OwnerUserId="1" LastEditorUserId="1620220" LastEditorDisplayName="Rich B" LastEditDate="2015-01-15T21:43:12.603" LastActivityDate="2016-08-10T12:48:37.573" Title="How do I calculate someone's age in C#?" Tags="<c#><.net><datetime>" AnswerCount="57" CommentCount="6" FavoriteCount="316" CommunityOwnedDate="2011-08-16T19:40:43.080" />
<row Id="11" PostTypeId="1" AcceptedAnswerId="1248" CreationDate="2008-07-31T23:55:37.967" Score="1065" ViewCount="111900" Body="<p>Given a specific <code>DateTime</code> value, how do I display relative time, like:</p>

<ul>
<li>2 hours ago</li>
<li>3 days ago</li>
<li>a month ago</li>
</ul>
" OwnerUserId="1" LastEditorUserId="1136709" LastEditorDisplayName="user2370523" LastEditDate="2015-12-29T02:08:37.450" LastActivityDate="2016-07-13T23:23:58.537" Title="How can relative time be calculated in C#?" Tags="<c#><datetime><datediff><relative-time-span>" AnswerCount="33" CommentCount="4" FavoriteCount="502" CommunityOwnedDate="2009-09-04T13:15:59.820" />
<row Id="12" PostTypeId="2" ParentId="11" CreationDate="2008-07-31T23:56:41.303" Score="285" Body="<p>Well, here's how we do it on Stack Overflow.</p>

<pre class="lang-csharp prettyprint-override"><code>var ts = new TimeSpan(DateTime.UtcNow.Ticks - dt.Ticks);
double delta = Math.Abs(ts.TotalSeconds);

if (delta &lt; 60)
{
 return ts.Seconds == 1 ? "one second ago" : ts.Seconds + " seconds ago";
}
if (delta &lt; 120)
{
 return "a minute ago";
}
if (delta &lt; 2700) // 45 * 60
{
 return ts.Minutes + " minutes ago";
}
if (delta &lt; 5400) // 90 * 60
{
 return "an hour ago";
}
if (delta &lt; 86400) // 24 * 60 * 60
{
 return ts.Hours + " hours ago";
}
if (delta &lt; 172800) // 48 * 60 * 60
{
 return "yesterday";
}
if (delta &lt; 2592000) // 30 * 24 * 60 * 60
{
 return ts.Days + " days ago";
}
if (delta &lt; 31104000) // 12 * 30 * 24 * 60 * 60
{
 int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30));
 return months &lt;= 1 ? "one month ago" : months + " months ago";
}
int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365));
return years &lt;= 1 ? "one year ago" : years + " years ago";
</code></pre>

<p>Suggestions? Comments? Ways to improve this algorithm?</p>
" OwnerUserId="1" LastEditorUserId="1420197" LastEditorDisplayName="GateKiller" LastEditDate="2014-02-18T14:19:35.770" LastActivityDate="2014-02-18T14:19:35.770" CommentCount="13" CommunityOwnedDate="2009-09-04T13:15:59.820" />
<row Id="13" PostTypeId="1" AcceptedAnswerId="357" CreationDate="2008-08-01T00:42:38.903" Score="426" ViewCount="122308" Body="<p>Is there any standard way for a Web Server to be able to determine a user's timezone within a web page? Perhaps from a <code>HTTP</code> header? Or part of the user-agent string?</p>
" OwnerUserId="9" LastEditorUserId="5735775" LastEditorDisplayName="Rich B" LastEditDate="2016-05-04T03:22:38.223" LastActivityDate="2016-05-04T03:22:38.223" Title="Determine a User's Timezone" Tags="<html><browser><timezone><timezoneoffset>" AnswerCount="23" CommentCount="3" FavoriteCount="119" />
<row Id="14" PostTypeId="1" CreationDate="2008-08-01T00:59:11.177" Score="272" ViewCount="81559" Body="<p>What is the difference between <a href="http://msdn.microsoft.com/en-us/library/9a6a2sxy.aspx"><code>Math.Floor()</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx"><code>Math.Truncate()</code></a> in .NET?</p>
" OwnerUserId="11" OwnerDisplayName="Anonymous User" LastEditorUserId="23199" LastEditorDisplayName="Rich B" LastEditDate="2014-12-16T15:12:13.297" LastActivityDate="2016-04-18T19:17:38.967" Title="Difference between Math.Floor() and Math.Truncate()" Tags="<.net>" AnswerCount="8" CommentCount="1" FavoriteCount="40" />
<row Id="16" PostTypeId="1" AcceptedAnswerId="12446" CreationDate="2008-08-01T04:59:33.643" Score="68" ViewCount="68941" Body="<p>How do you expose a <strong>LINQ</strong> query as an <strong>ASMX</strong> web service? Usually, from the business tier, I can return a typed <code>DataSet</code> or <code>DataTable</code> which can be serialized for transport over <strong>ASMX</strong>.</p>

<p>How can I do the same for a <strong>LINQ</strong> query? Is there a way to populate a typed <code>DataSet</code> or <code>DataTable</code> via a <strong>LINQ</strong> query?: </p>

<pre><code>public static MyDataTable CallMySproc() 
{ 
 string conn = ...;

 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 can I get the resultset of a <strong>LINQ</strong> query into a <code>DataSet</code> or <code>DataTable</code>? Alternatively, is the <strong>LINQ</strong> query serializeable so that I can expose it as an <strong>ASMX</strong> web service?</p>
" OwnerUserId="2" LastEditorUserId="1039608" LastEditorDisplayName="Chris Fournier" LastEditDate="2012-05-04T09:01:26.053" LastActivityDate="2014-10-10T06:02:15.453" Title="Filling a DataSet or DataTable from a LINQ query result set" Tags="<c#><linq><web-services><.net-3.5>" AnswerCount="5" CommentCount="0" FavoriteCount="10" />
<row Id="17" PostTypeId="1" AcceptedAnswerId="26" CreationDate="2008-08-01T05:09:55.993" Score="103" ViewCount="43379" Body="<p>How do I store binary data in <a href="http://en.wikipedia.org/wiki/MySQL">MySQL</a>?</p>
" OwnerUserId="2" LastEditorUserId="546051" LastEditDate="2011-10-21T21:29:17.160" LastActivityDate="2016-07-31T15:32:02.653" Title="Binary Data in MySQL" Tags="<mysql><database><binary-data><data-storage>" AnswerCount="11" CommentCount="0" FavoriteCount="11" />
<row Id="18" PostTypeId="2" ParentId="17" CreationDate="2008-08-01T05:12:44.193" Score="33" Body="<p>For a table like this:</p>

<pre><code>CREATE TABLE binary_data (
 id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 description CHAR(50),
 bin_data LONGBLOB,
 filename CHAR(50),
 filesize CHAR(50),
 filetype CHAR(50)
);
</code></pre>

<p>Here is a PHP example:</p>

<pre><code>&lt;?php
 // store.php3 - by Florian Dittmer &lt;dittmer@gmx.net&gt;
 // Example php script to demonstrate the storing of binary files into
 // an sql database. More information can be found at http://www.phpbuilder.com/
?&gt;

&lt;html&gt;
 &lt;head&gt;&lt;title&gt;Store binary data into SQL Database&lt;/title&gt;&lt;/head&gt;

 &lt;body&gt;
 &lt;?php
 // Code that will be executed if the form has been submitted:

 if ($submit) {
 // Connect to the database (you may have to adjust
 // the hostname, username or password).

 mysql_connect("localhost", "root", "password");
 mysql_select_db("binary_data");

 $data = mysql_real_escape_string(fread(fopen($form_data, "r"), filesize($form_data)));

 $result = mysql_query("INSERT INTO binary_data (description, bin_data, filename, filesize, filetype) ".
 "VALUES ('$form_description', '$data', '$form_data_name', '$form_data_size', '$form_data_type')");

 $id= mysql_insert_id();
 print "&lt;p&gt;This file has the following Database ID: &lt;b&gt;$id&lt;/b&gt;";

 mysql_close();
 } else {

 // else show the form to submit new data:
 ?&gt;
 &lt;form method="post" action="&lt;?php echo $PHP_SELF; ?&gt;" enctype="multipart/form-data"&gt;
 File Description:&lt;br&gt;
 &lt;input type="text" name="form_description" size="40"&gt;
 &lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000"&gt;
 &lt;br&gt;File to upload/store in database:&lt;br&gt;
 &lt;input type="file" name="form_data" size="40"&gt;
 &lt;p&gt;&lt;input type="submit" name="submit" value="submit"&gt;
 &lt;/form&gt;

 &lt;?php
 }
 ?&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>
" OwnerDisplayName="phpguy" LastEditorUserId="126039" LastEditorDisplayName="Jeff Atwood" LastEditDate="2016-06-02T05:56:26.060" LastActivityDate="2016-06-02T05:56:26.060" CommentCount="2" />
<row Id="19" PostTypeId="1" AcceptedAnswerId="531" CreationDate="2008-08-01T05:21:22.257" Score="212" ViewCount="33308" Body="<p>Solutions are welcome in any language. :-) 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>d 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 the other versions against. 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>), noting that it 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 optimisations are different), I've also tried switching the order of the tests around. The <code>atan2(0, -1)</code> version still comes out top every time, though.</p>
" OwnerUserId="13" LastEditorUserId="635549" LastEditorDisplayName="Chris Jester-Young" LastEditDate="2015-07-11T12:15:53.303" LastActivityDate="2015-11-30T21:15:16.943" Title="What is the fastest way to get the value of π?" Tags="<performance><algorithm><language-agnostic><unix><pi>" AnswerCount="21" CommentCount="18" FavoriteCount="67" />
<row Id="21" PostTypeId="2" ParentId="9" CreationDate="2008-08-01T08:57:27.280" Score="23" Body="<p>Many years ago, to provide an <a href="http://cloud9.hedgee.com/age">age calculator gimmick</a> on my website, I wrote a function to calculate age to a fraction. This is a quick port of that function to C# (from <a href="http://hedgee.svn.sourceforge.net/viewvc/hedgee/trunk/chris/ckwww/ckage.php3">the PHP version</a>). I'm afraid I haven't been able to test the C# version, but hope you enjoy all the same!</p>

<p>(Admittedly this is a bit gimmicky for the purposes of showing user profiles on Stack Overflow, but maybe readers will find some use for it. :-))</p>

<pre><code>double AgeDiff(DateTime date1, DateTime date2) {<br> double years = date2.Year - date1.Year;<br><br> /*<br> * If date2 and date1 + round(date2 - date1) are on different sides<br> * of 29 February, then our partial year is considered to have 366<br> * days total, otherwise it's 365. Note that 59 is the day number<br> * of 29 Feb.<br> */<br> double fraction = 365<br> + (DateTime.IsLeapYear(date2.Year) &amp;&amp; date2.DayOfYear &gt;= 59<br> &amp;&amp; (date1.DayOfYear &lt; 59 || date1.DayOfYear &gt; date2.DayOfYear)<br> ? 1 : 0);<br><br> /*<br> * The only really nontrivial case is if date1 is in a leap year,<br> * and date2 is not. So let's handle the others first.<br> */<br> if (DateTime.IsLeapYear(date2.Year) == DateTime.IsLeapYear(date1.Year))<br> return years + (date2.DayOfYear - date1.DayOfYear) / fraction;<br><br> /*<br> * If date2 is in a leap year, but date1 is not and is March or<br> * beyond, shift up by a day.<br> */<br> if (DateTime.IsLeapYear(date2.Year)) {<br> return years + (date2.DayOfYear - date1.DayOfYear<br> - (date1.DayOfYear &gt;= 59 ? 1 : 0)) / fraction;<br> }<br><br> /*<br> * If date1 is not on 29 February, shift down date1 by a day if<br> * March or later. Proceed normally.<br> */<br> if (date1.DayOfYear != 59) {<br> return years + (date2.DayOfYear - date1.DayOfYear<br> + (date1.DayOfYear &gt; 59 ? 1 : 0)) / fraction;<br> }<br><br> /*<br> * Okay, here date1 is on 29 February, and date2 is not on a leap<br> * year. What to do now? On 28 Feb in date2's year, the ``age''<br> * should be just shy of a whole number, and on 1 Mar should be<br> * just over. Perhaps the easiest way is to a point halfway<br> * between those two: 58.5.<br> */<br> return years + (date2.DayOfYear - 58.5) / fraction;<br>}<br></code></pre>" OwnerUserId="13" LastEditorUserId="13" LastEditorDisplayName="Chris Jester-Young" LastEditDate="2008-08-01T12:35:11.707" LastActivityDate="2008-08-01T12:35:11.707" CommentCount="0" CommunityOwnedDate="2011-08-16T19:40:43.080" />
<row Id="22" PostTypeId="2" ParentId="9" CreationDate="2008-08-01T12:07:19.500" Score="15" Body="<p>The best way that I know of because of leap years and everything is:</p>

<pre><code>DateTime birthDate = new DateTime(2000,3,1);<br>int age = (int)Math.Floor((DateTime.Now - birthDate).TotalDays / 365.25D);<br></code></pre>

<p>Hope this helps.</p>" OwnerUserId="17" LastEditorUserId="17" LastEditorDisplayName="Nick" LastEditDate="2008-08-01T15:26:37.087" LastActivityDate="2008-08-01T15:26:37.087" CommentCount="0" CommunityOwnedDate="2011-08-16T19:40:43.080" />
<row Id="24" PostTypeId="1" AcceptedAnswerId="49" CreationDate="2008-08-01T12:12:19.350" Score="85" ViewCount="38538" Body="<p>If I have a <code>trigger</code> <code>before the update</code> on a table, how can I throw an error that prevents the update on that table?</p>
" OwnerUserId="22" LastEditorUserId="5195227" LastEditorDisplayName="Jim Anderson" LastEditDate="2016-03-11T08:26:05.063" LastActivityDate="2016-08-12T18:08:14.597" Title="Throw an error in a MySQL trigger" Tags="<mysql><database><triggers>" AnswerCount="6" CommentCount="0" FavoriteCount="16" />
<row Id="25" PostTypeId="1" AcceptedAnswerId="1443907" CreationDate="2008-08-01T12:13:50.207" Score="86" ViewCount="6724" Body="<p>I've been having issues getting the <strong>C sockets API</strong> to work properly in <code>C++</code>. Specifically, even though I'm including <code>sys/socket.h</code>, I'm still getting compile time errors telling me that <code>AF_INET</code> is not defined. Am I missing something obvious, or could this be related to the fact that I'm doing this coding on <code>z/OS</code> and my problems are much more complicated?</p>

<hr>

<p><strong>Update</strong>: Upon further investigation, I discovered that there is an <code>#ifdef</code> that I'm hitting. Apparently <code>z/OS</code> isn't happy unless I define which <em>type</em> 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 <code>z/OS</code> sockets programmers are out there (all 3 of you), perhaps you could give me a rundown on how this all works?</p>
" OwnerUserId="23" LastEditorDisplayName="user5857081" LastEditDate="2016-03-15T01:22:33.497" LastActivityDate="2016-03-15T01:22:33.497" Title="Using C socket API in C++ on z/OS" Tags="<c++><c><sockets><mainframe><zos>" AnswerCount="10" CommentCount="0" FavoriteCount="3" />
<row Id="26" PostTypeId="2" ParentId="17" CreationDate="2008-08-01T12:16:22.167" Score="80" Body="<p>The answer by phpguy is correct but I think there is a lot of confusion in the additional details there.</p>

<p>The basic answer is in a <code>BLOB</code> data type / attribute domain. <strong>BLOB</strong> is short for Binary Large Object and that column data type is specific for handling binary data.</p>

<p>See <a href="http://dev.mysql.com/doc/refman/5.7/en/blob.html">the relevant manual page for MySQL</a>.</p>
" OwnerUserId="48" OwnerDisplayName="Mat Scales" LastEditorUserId="126039" LastEditorDisplayName="Geoff Dalgas" LastEditDate="2016-06-02T05:55:17.060" LastActivityDate="2016-06-02T05:55:17.060" CommentCount="0" />
<row Id="27" PostTypeId="2" ParentId="11" CreationDate="2008-08-01T12:17:19.357" Score="26" Body="<p>@jeff</p>

<p>IMHO yours seems a little long. However it does seem a little more robust with support for "yesterday" and "years". But in my experience when this is used the person is most likely to view the content in the first 30 days. It is only the really hardcore people that come after that. So that is why I usually elect to keep this short and simple.</p>

<p>This is the method I am currently using on one of my websites. This only returns a relative day, hour, time. And then the user has to slap on "ago" in the output.</p>

<pre><code>public static string ToLongString(this TimeSpan time)<br>{<br> string output = String.Empty;<br><br> if (time.Days &gt; 0)<br> output += time.Days + " days ";<br><br> if ((time.Days == 0 || time.Days == 1) &amp;&amp; time.Hours &gt; 0)<br> output += time.Hours + " hr ";<br><br> if (time.Days == 0 &amp;&amp; time.Minutes &gt; 0)<br> output += time.Minutes + " min ";<br><br> if (output.Length == 0)<br> output += time.Seconds + " sec";<br><br> return output.Trim();<br>}<br></code></pre>" OwnerUserId="17" LastEditorUserId="17" LastEditorDisplayName="Nick Berardi" LastEditDate="2008-08-01T13:16:49.127" LastActivityDate="2008-08-01T13:16:49.127" CommentCount="0" CommunityOwnedDate="2009-09-04T13:15:59.820" />
<row Id="29" PostTypeId="2" ParentId="13" CreationDate="2008-08-01T12:19:17.417" Score="45" Body="<p>There are no HTTP headers that will report the clients timezone so far although it has been suggested to include it in the HTTP specification.</p>

<p>If it was me, I would probably try to fetch the timezone using clientside JavaScript and then submit it to the server using Ajax or something.</p>" OwnerUserId="19" LastActivityDate="2008-08-01T12:19:17.417" CommentCount="1" />
<row Id="30" PostTypeId="2" ParentId="25" CreationDate="2008-08-01T12:22:40.797" Score="21" Body="<p>I've had no trouble using the BSD sockets API in C++, in GNU/Linux. Here's the sample program I used:</p>

<pre><code>#include &lt;sys/socket.h&gt;<br><br>int<br>main()<br>{<br> return AF_INET;<br>}<br></code></pre>

<p>So my take on this is that z/OS is probably the complicating factor here, however, because I've never used z/OS before, much less programmed in it, I can't say this definitively. :-P</p>" OwnerUserId="13" LastActivityDate="2008-08-01T12:22:40.797" CommentCount="0" />
<row Id="31" PostTypeId="2" ParentId="6" CreationDate="2008-08-01T12:22:51.593" Score="93" Body="<p>The parent <code>div</code> needs to have a defined <code>width</code>, either in pixels or as a percentage. In Internet&nbsp;Explorer&nbsp;7, the parent <code>div</code> needs a defined <code>width</code> for child percentage <code>div</code>s to work correctly.</p>
" OwnerDisplayName="maclema" LastEditorUserId="63550" LastEditDate="2016-03-19T06:10:52.170" LastActivityDate="2016-03-19T06:10:52.170" CommentCount="0" />
<row Id="33" PostTypeId="2" ParentId="14" CreationDate="2008-08-01T12:26:39.773" Score="348" Body="<p><code>Math.Floor</code> rounds down, <code>Math.Ceiling</code> rounds up, and <code>Math.Truncate</code> rounds towards zero. Thus, <code>Math.Truncate</code> is like <code>Math.Floor</code> for positive numbers, and like <code>Math.Ceiling</code> for negative numbers. Here's the <a href="http://msdn.microsoft.com/en-us/library/system.math.truncate.aspx">reference</a>.</p>

<p>For completeness, <code>Math.Round</code> rounds to the nearest integer. If the number is exactly midway between two integers, then it rounds towards the even one. <a href="http://msdn.microsoft.com/en-us/library/system.math.round.aspx">Reference.</a></p>

<p>See also: <a href="http://stackoverflow.com/questions/14/whats-the-difference-between-math-floor-and-math-truncate-in-c/580252#580252">Pax Diablo's answer</a>. Highly recommended!</p>
" OwnerUserId="13" LastEditorUserId="13" LastEditDate="2009-10-14T02:09:03.030" LastActivityDate="2009-10-14T02:09:03.030" CommentCount="6" />
<row Id="34" PostTypeId="1" CreationDate="2008-08-01T12:30:57.630" Score="45" ViewCount="7055" Body="<p>How do I forcefully unload a <code>ByteArray</code> from memory in ActionScript 3?</p>

<p>I have tried (without success):</p>

<pre><code>byteArray.length = 0;
byteArray = new ByteArray();
</code></pre>

<p>And</p>

<pre><code>for ( var i:int=0; i &lt; byteArray.length; i++ ) {
 byteArray[i] = null;
}
</code></pre>
" OwnerDisplayName="maclema" LastEditorUserId="1213296" LastEditDate="2015-12-16T05:35:30.353" LastActivityDate="2016-05-28T20:12:42.107" Title="Unloading a ByteArray in Actionscript 3" Tags="<actionscript-3><flex><bytearray>" AnswerCount="8" CommentCount="0" FavoriteCount="1" />
<row Id="36" PostTypeId="1" AcceptedAnswerId="352" CreationDate="2008-08-01T12:35:56.917" Score="92" ViewCount="40343" Body="<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">.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">SQL&nbsp;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&nbsp;Server 2000 and 2005) seems to be to use the BINARY_CHECKSUM function in <a href="http://en.wikipedia.org/wiki/Transact-SQL">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>
" OwnerUserId="32" LastEditorUserId="1814657" LastEditorDisplayName="Mark Harrison" LastEditDate="2016-01-02T05:31:30.247" LastActivityDate="2016-05-16T05:08:45.590" Title="Check for changes to an SQL Server table?" Tags="<sql><sql-server><datatable><rdbms>" AnswerCount="8" CommentCount="1" FavoriteCount="21" />
<row Id="37" PostTypeId="2" ParentId="25" CreationDate="2008-08-01T12:36:00.957" Score="26" Body="<p>Sure I can post a test app.</p>

<pre><code>#include &lt;sys/socket.h&gt;<br><br>int main()<br>{<br> return AF_INET;<br>}<br></code></pre>

<p>Compile/Link Output:</p>

<p>cxx -Wc,xplink -Wl,xplink -o inet_test inet.C</p>

<p>"./inet.C", line 5.16: CCN5274 (S) The name lookup for "AF_INET" did not find a declaration.</p>

<p>CCN0797(I) Compilation failed for file ./inet.C. Object file not created.</p>

<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 #ifdef statements.</p>

<p>I have however noticed it contains a the following:</p>

<pre><code>#ifdef __cplusplus<br> extern "C" {<br>#endif<br></code></pre>

<p>which encapsulates basically the whole file. Not sure if it matters.</p>" OwnerUserId="23" LastEditorUserId="23" LastEditorDisplayName="Jax" LastEditDate="2008-08-01T12:42:32.113" LastActivityDate="2008-08-01T12:42:32.113" CommentCount="0" />
<row Id="39" PostTypeId="1" AcceptedAnswerId="45" CreationDate="2008-08-01T12:43:11.503" Score="52" ViewCount="3642" Body="<p>I am aware that in <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a> there are three timer types (see <em><a href="http://msdn.microsoft.com/en-us/magazine/cc164015.aspx">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 so 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>
" OwnerUserId="33" LastEditorUserId="63550" LastEditorDisplayName="Jim Anderson" LastEditDate="2012-05-25T20:55:43.157" LastActivityDate="2014-01-17T09:33:10.450" Title="Reliable timer in a console application" Tags="<c#><.net><vb.net><timer>" AnswerCount="2" CommentCount="0" FavoriteCount="2" />
<row Id="42" PostTypeId="1" AcceptedAnswerId="77" CreationDate="2008-08-01T12:50:18.587" Score="202" ViewCount="25005" Body="<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>
" OwnerUserId="37" LastEditorUserId="4595675" LastEditorDisplayName="Vaibhav" LastEditDate="2015-12-14T20:05:51.823" LastActivityDate="2016-05-15T16:03:48.047" Title="Best way to allow plugins for a PHP application" Tags="<php><plugins><architecture><hook>" AnswerCount="8" CommentCount="0" FavoriteCount="100" />
<row Id="44" PostTypeId="2" ParentId="39" CreationDate="2008-08-01T12:55:42.413" Score="9" Body="<p>Consider using a <a href="http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx">ManualResetEvent</a> to block the main thread at the end of its processing, and call <code>Reset()</code> on it once the timer's processing has finished. If this is something that needs to run constantly, consider moving this into a service process instead of a console app.</p>
" OwnerUserId="35" LastEditorUserId="967315" LastEditDate="2012-10-14T12:20:15.140" LastActivityDate="2012-10-14T12:20:15.140" CommentCount="0" />
<row Id="45" PostTypeId="2" ParentId="39" CreationDate="2008-08-01T12:56:37.920" Score="33" Body="<p>You can use something like <code>Console.ReadLine()</code> to block the main thread, so other background threads (like timer threads) will still work. You may also use an <a href="http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx">AutoResetEvent</a> to block the execution, then (when you need to) you can call Set() method on that AutoResetEvent object to release the main thread. Also ensure that your reference to Timer object doesn't go out of scope and garbage collected.</p>
" OwnerUserId="39" LastEditorUserId="967315" LastEditorDisplayName="huseyint" LastEditDate="2012-10-14T12:20:06.700" LastActivityDate="2012-10-14T12:20:06.700" CommentCount="0" />
<row Id="48" PostTypeId="1" AcceptedAnswerId="31910" CreationDate="2008-08-01T13:01:17.303" Score="183" ViewCount="171550" Body="<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 Enter it will use that button to submit the form. </p>

<p>Example:</p>

<pre><code>&lt;form&gt;
 &lt;input type="text" name="field1" /&gt; &lt;!-- put your cursor in this field and press Enter --&gt;

 &lt;input type="submit" name="prev" value="Previous Page" /&gt; &lt;!-- This is the button that will submit --&gt;
 &lt;input type="submit" name="next" value="Next Page" /&gt; &lt;!-- But this is the button that I WANT to submit --&gt;
&lt;/form&gt;
</code></pre>

<p>What I would like to do, is get to decide which button is used to submit the form when a user presses Enter. That way, when you press Enter the Wizard will move to the next page, not the previous. Do you have to use <code>tabindex</code> to do this?</p>
" OwnerUserId="40" LastEditorUserId="2354564" LastEditorDisplayName="kevin d" LastEditDate="2014-07-14T07:46:45.920" LastActivityDate="2016-06-01T19:32:07.673" Title="Multiple submit buttons in an HTML form" Tags="<html><form-submit><html-form><submit-button>" AnswerCount="20" CommentCount="0" FavoriteCount="29" />
<row Id="49" PostTypeId="2" ParentId="24" CreationDate="2008-08-01T13:02:51.900" Score="33" Body="<p><a href="http://www.brokenbuild.com/blog/2006/08/15/mysql-triggers-how-do-you-abort-an-insert-update-or-delete-with-a-trigger/">Here is one hack</a> that may work. It isn't clean, but it looks like it might work:</p>

<p>Essentially, you just try to update a column that doesn't exist.</p>
" OwnerUserId="43" LastEditorUserId="957909" LastEditDate="2012-12-24T21:24:41.017" LastActivityDate="2012-12-24T21:24:41.017" CommentCount="1" />
<row Id="51" PostTypeId="2" ParentId="36" CreationDate="2008-08-01T13:07:52.810" Score="18" Body="<p>Why don't you want to use triggers. They are a good thing if you use them correctly. If you use them as a way to enforce referential integrity that is when they go from good to bad. But if you use them for monitoring, they are not really considered taboo.</p>" OwnerUserId="17" LastActivityDate="2008-08-01T13:07:52.810" CommentCount="0" />
<row Id="52" PostTypeId="2" ParentId="34" CreationDate="2008-08-01T13:08:59.127" Score="11" Body="<p>Have a look at this article</p>

<p><a href="http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html">http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html</a></p>

<p>IANA actionscript programmer, however the feeling I'm getting is that, because the garbage collector might not run when you want it to.</p>

<p>Hence
<a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/">http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</a></p>

<p>So I'd recommend trying out their collection code and see if it helps</p>

<pre><code>private var gcCount:int;<br>private function startGCCycle():void{<br> gcCount = 0;<br> addEventListener(Event.ENTER_FRAME, doGC);<br>}<br>private function doGC(evt:Event):void{<br> flash.system.System.gc();<br> if(++gcCount &gt; 1){<br> removeEventListener(Event.ENTER_FRAME, doGC);<br> setTimeout(lastGC, 40);<br> }<br>}<br>private function lastGC():void{<br> flash.system.System.gc();<br>}<br></code></pre>" OwnerUserId="23" LastActivityDate="2008-08-01T13:08:59.127" CommentCount="0" />
<row Id="53" PostTypeId="2" ParentId="34" CreationDate="2008-08-01T13:08:59.487" Score="16" Body="<p>(I'm not positive about this, but...)</p>

<p>AS3 uses a non-deterministic garbage collection. Which means that unreferenced memory will be freed up whenever the runtime feels like it (typically not unless there's a reason to run, since it's an expensive operation to execute). This is the same approach used by most modern garbage collected languages (like C# and Java as well).</p>

<p>Assuming there are no other references to the memory pointed to by <code>byteArray</code> or the items within the array itself, the memory will be freed at some point after you exit the scope where <code>byteArray</code> is declared.</p>

<p>You can force a garbage collection, though you really shouldn't. If you do, do it only for testing... if you do it in production, you'll hurt performance much more than help it.</p>

<p>To force a GC, try (yes, twice):</p>

<pre><code>flash.system.System.gc();
flash.system.System.gc();
</code></pre>

<p><a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/">You can read more here</a>.</p>
" OwnerUserId="34" LastEditorUserId="1668244" LastEditDate="2014-07-10T21:03:46.907" LastActivityDate="2014-07-10T21:03:46.907" CommentCount="0" />
<row Id="56" PostTypeId="2" ParentId="48" CreationDate="2008-08-01T13:10:16.473" Score="48" Body="<p>Give your submit buttons same name like this:</p>

<pre><code>&lt;input type="submit" name="submitButton" value="Previous Page" /&gt;
&lt;input type="submit" name="submitButton" value="Next Page" /&gt;
</code></pre>

<p>When the user presses enter and the <em>Request</em> goes to server, you can check the value for <code>submitButton</code> on your server-side code which contains a collection of form <code>name/value</code> pairs. For example in classic ASP:</p>

<pre class="lang-vb prettyprint-override"><code>If Request.Form("submitButton") = "Previous Page" Then
 ' Code for Previous Page
ElseIf Request.Form("submitButton") = "Next Page" Then
 ' Code for Next Page
End If
</code></pre>

<p>Reference: <a href="http://www.chami.com/tips/internet/042599I.html">Using multiple submit buttons on a single form</a></p>
" OwnerUserId="39" LastEditorUserId="2354564" LastEditDate="2014-07-14T07:55:42.730" LastActivityDate="2014-07-14T07:55:42.730" CommentCount="2" />
<row Id="58" PostTypeId="2" ParentId="48" CreationDate="2008-08-01T13:14:30.303" Score="50" Body="<p>Would it be possible for you to change the previous button type into a button like this: </p>

<pre><code>&lt;input type="button" name="prev" value="Previous Page" /&gt;
</code></pre>

<p>Now the Next button would be the default, plus you could also add the <code>default</code> attribute to it so that your browser will highlight it like so:</p>

<pre><code>&lt;input type="submit" name="next" value="Next Page" default /&gt;
</code></pre>

<p>Hope that helps.</p>
" OwnerUserId="37" LastEditorUserId="875317" LastEditDate="2015-07-06T22:50:09.980" LastActivityDate="2015-07-06T22:50:09.980" CommentCount="6" />
<row Id="59" PostTypeId="1" AcceptedAnswerId="43110" CreationDate="2008-08-01T13:14:33.797" Score="60" ViewCount="20960" Body="<p>Let's say I have a <code>DataTable</code> with a <code>Name</code> column. I want to have a collection of the unique names ordered alphabetically. The following query ignores the order by 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>
" OwnerUserId="45" LastEditorUserId="885318" LastEditorDisplayName="Keith" LastEditDate="2014-01-01T16:43:44.793" LastActivityDate="2014-08-19T23:17:56.597" Title="How do I get a distinct, ordered list of names from a DataTable using LINQ?" Tags="<c#><linq><.net-3.5>" AnswerCount="5" CommentCount="0" FavoriteCount="2" />
<row Id="60" PostTypeId="2" ParentId="34" CreationDate="2008-08-01T13:14:40.007" Score="10" Body="<p>Unfortunately when it comes to memory management in <em>Flash/actionscript</em> there isn't a whole lot you can do. ActionScript was designed to be easy to use (so they didn't want people to have to worry about memory management)</p>

<p>The following is a workaround, instead of creating a <code>ByteArray</code> variable try this.</p>

<pre><code>var byteObject:Object = new Object();

byteObject.byteArray = new ByteArray();

...

//Then when you are finished delete the variable from byteObject
delete byteObject.byteArray;
</code></pre>

<p>Where <code>byteArray</code> is a dynamic property of <code>byteObject</code>, you can free the memory that was allocated for it.</p>
" OwnerUserId="41" LastEditorUserId="2354564" LastEditDate="2014-07-11T14:58:07.480" LastActivityDate="2014-07-11T14:58:07.480" CommentCount="0" />
<row Id="61" PostTypeId="1" CreationDate="2008-08-01T13:17:20.640" Score="28" ViewCount="2094" Body="<p>Where can I find a list of the MIME types and identifying characters for Office 2007 files?</p>

<p>I have an upload form that is restricting uploads based on extension and identifying characters, but I cannot seem to find the Office 2007 MIME types.</p>
" OwnerDisplayName="maclema" LastEditorUserId="1454806" LastEditorDisplayName="Mark Biek" LastEditDate="2013-04-11T20:15:23.130" LastActivityDate="2016-03-27T18:01:42.623" Title="Office 2007 File Type, Mime Types and Identifying Characters" Tags="<office-2007><file-type>" AnswerCount="1" CommentCount="0" FavoriteCount="2" CommunityOwnedDate="2013-04-11T20:15:23.130" />
<row Id="62" PostTypeId="2" ParentId="59" CreationDate="2008-08-01T13:18:37.640" Score="39" Body="<p><strong>The problem is that the Distinct
 operator does not grant that it will
 maintain the original order of
 values.</strong></p>

<p>So your query will need to work like this</p>

<pre><code>var names = (from DataRow dr in dataTable.Rows
 select (string)dr["Name"]).Distinct().OrderBy( name =&gt; name );
</code></pre>
" OwnerUserId="45" LastEditorUserId="1248536" LastEditDate="2014-08-19T23:17:56.597" LastActivityDate="2014-08-19T23:17:56.597" CommentCount="0" />
<row Id="65" PostTypeId="2" ParentId="61" CreationDate="2008-08-01T13:20:44.283" Score="12" Body="<p><a href="http://www.bram.us/2007/05/25/office-2007-mime-types-for-iis/">Office 2007 MIME Types for IIS</a></p>

<ul>
<li>.docm, application/vnd.ms-word.document.macroEnabled.12</li>
<li>.docx, application/vnd.openxmlformats-officedocument.wordprocessingml.document</li>
<li>.dotm, application/vnd.ms-word.template.macroEnabled.12</li>
<li>.dotx, application/vnd.openxmlformats-officedocument.wordprocessingml.template</li>
<li>.potm, application/vnd.ms-powerpoint.template.macroEnabled.12</li>
<li>.potx, application/vnd.openxmlformats-officedocument.presentationml.template</li>
<li>.ppam, application/vnd.ms-powerpoint.addin.macroEnabled.12</li>
<li>.ppsm, application/vnd.ms-powerpoint.slideshow.macroEnabled.12</li>
<li>.ppsx, application/vnd.openxmlformats-officedocument.presentationml.slideshow</li>
<li>.pptm, application/vnd.ms-powerpoint.presentation.macroEnabled.12</li>
<li>.pptx, application/vnd.openxmlformats-officedocument.presentationml.presentation</li>
<li>.xlam, application/vnd.ms-excel.addin.macroEnabled.12</li>
<li>.xlsb, application/vnd.ms-excel.sheet.binary.macroEnabled.12</li>
<li>.xlsm, application/vnd.ms-excel.sheet.macroEnabled.12</li>
<li>.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</li>
<li>.xltm, application/vnd.ms-excel.template.macroEnabled.12</li>
<li>.xltx, application/vnd.openxmlformats-officedocument.spreadsheetml.template</li>
</ul>
" OwnerUserId="35" LastEditorUserId="2354564" LastEditDate="2014-07-14T07:43:54.163" LastActivityDate="2014-07-14T07:43:54.163" CommentCount="0" />
<row Id="66" PostTypeId="1" AcceptedAnswerId="4521" CreationDate="2008-08-01T13:20:46.890" Score="52" ViewCount="3875" Body="<p>How do you page through a collection in LINQ given that you have a <code>startIndex</code> and a <code>count</code>?</p>
" OwnerUserId="17" LastEditorUserId="1039608" LastEditorDisplayName="Keith" LastEditDate="2012-05-04T09:03:54.213" LastActivityDate="2016-02-07T00:24:49.107" Title="Paging a collection with LINQ" Tags="<linq><.net-3.5>" AnswerCount="4" CommentCount="0" FavoriteCount="5" />
<row Id="68" PostTypeId="2" ParentId="66" CreationDate="2008-08-01T13:22:04.483" Score="52" Body="<p>It is very simple with the <code>Skip</code> and <code>Take</code> extension methods.</p>

<pre><code>var query = from i in ideas
 select i;

var paggedCollection = query.Skip(startIndex).Take(count);
</code></pre>
" OwnerUserId="17" LastEditorUserId="1039608" LastEditDate="2012-05-04T09:04:26.523" LastActivityDate="2012-05-04T09:04:26.523" CommentCount="2" />
<row Id="71" PostTypeId="2" ParentId="19" CreationDate="2008-08-01T13:37:59.723" Score="59" Body="<p>Here's a general description of a technique for calculating pi that I learnt in high school.</p>

<p>I only share this because I think it is simple enough that anyone can remember it, indefinitely, plus it teaches you the concept of "Monte-Carlo" methods -- which are statistical methods of arriving at answers that don't immediately appear to be deducible through random processes.</p>

<p>Draw a square, and inscribe a quadrant (one quarter of a semi-circle) inside that square (a quadrant with radius equal to the side of the square, so it fills as much of the square as possible)</p>

<p>Now throw a dart at the square, and record where it lands -- that is, choose a random point anywhere inside the square. Of course, it landed inside the square, but is it inside the semi-circle? Record this fact.</p>

<p>Repeat this process many times -- and you will find there is a ratio of the number of points inside the semi-circle versus the total number thrown, call this ratio x.</p>

<p>Since the area of the square is r times r, you can deduce that the area of the semi circle is x times r times r (that is, x times r squared). Hence x times 4 will give you pi. </p>

<p>This is not a quick method to use. But it's a nice example of a Monte Carlo method. And if you look around, you may find that many problems otherwise outside your computational skills can be solved by such methods.</p>
" OwnerUserId="49" OwnerDisplayName="Leon Bambrick" LastEditorUserId="63550" LastEditDate="2012-05-25T21:09:03.593" LastActivityDate="2012-05-25T21:09:03.593" CommentCount="1" />
<row Id="72" PostTypeId="1" CreationDate="2008-08-01T13:38:27.133" Score="25" ViewCount="1047" Body="<p>I've got all these comments that I want to make into 'RDoc comments', so they can be formatted appropriately and viewed using <code>ri</code>. Can anyone get me started on understanding how to use RDoc?</p>
" OwnerUserId="25" LastEditorUserId="219883" LastEditorDisplayName="Gaius" LastEditDate="2013-05-05T00:24:51.110" LastActivityDate="2013-05-05T00:24:51.110" Title="How do I add existing comments to RDoc in Ruby?" Tags="<ruby><rdoc>" AnswerCount="2" CommentCount="1" />
<row Id="73" PostTypeId="2" ParentId="25" CreationDate="2008-08-01T13:40:16.443" Score="9" Body="<p>@Jax: The <code>extern "C"</code> thing matters, very very much. If a header file doesn't have one, then (unless it's a C++-only header file), you would have to enclose your <code>#include</code> with it:</p>

<pre><code>extern "C" {<br>#include &lt;sys/socket.h&gt;<br>// include other similarly non-compliant header files<br>}<br></code></pre>

<p>Basically, anytime where a C++ program wants to link to C-based facilities, the <code>extern "C"</code> is vital. In practical terms, it means that the names used in external references will not be mangled, like normal C++ names would. <a href="http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html">Reference.</a></p>" OwnerUserId="13" LastEditorUserId="13" LastEditorDisplayName="Chris Jester-Young" LastEditDate="2008-08-01T13:54:25.510" LastActivityDate="2008-08-01T13:54:25.510" CommentCount="0" />
<row Id="76" PostTypeId="2" ParentId="42" CreationDate="2008-08-01T13:44:35.843" Score="6" Body="<p>I believe the easiest way would be to follow Jeff's own advice and have a look around existing code. Try looking at Wordpress, Drupal, Joomla and other well known PHP-based CMS's to see how their API hooks look and feel. This way you can even get ideas you may have not thought of previously to make things a little more rubust.</p>

<p>A more direct answer would be to write general files that they would "include_once" into their file that would provide the usability they would need. This would be broken up into categories and NOT provided in one MASSIVE "hooks.php" file. Be careful though, because what ends up happening is that files that they include end up having more and more dependencies and functionality improves. Try to keep API dependencies low. I.E fewer files for them to include.</p>" OwnerUserId="50" LastActivityDate="2008-08-01T13:44:35.843" CommentCount="1" />
<row Id="77" PostTypeId="2" ParentId="42" CreationDate="2008-08-01T13:46:00.097" Score="120" Body="<p>You could use an Observer pattern. A simple functional way to accomplish this:</p>

<pre><code>&lt;?php<br><br>/** Plugin system **/<br><br>$listeners = array();<br><br>/* Create an entry point for plugins */<br>function hook(){<br> global $listeners;<br><br> $num_args = func_num_args();<br> $args = func_get_args();<br><br> if($num_args &lt; 2)<br> trigger_error("Insufficient arguments", E_USER_ERROR);<br><br> // Hook name should always be first argument<br> $hook_name = array_shift($args);<br><br> if(!isset($listeners[$hook_name]))<br> return; // No plugins have registered this hook<br><br> foreach($listeners[$hook_name] as $func){<br> $args = $func($args); <br> }<br><br> return $args;<br>}<br><br>/* Attach a function to a hook */<br>function add_listener($hook, $function_name){<br> global $listeners;<br><br> $listeners[$hook][] = $function_name;<br>}<br><br><br>/////////////////////////<br><br>/** Sample Plugin **/<br>add_listener('a_b', 'my_plugin_func1');<br>add_listener('str', 'my_plugin_func2');<br><br>function my_plugin_func1($args){<br> return array(4, 5);<br>}<br>function my_plugin_func2($args){<br> return str_replace('sample', 'CRAZY', $args[0]);<br>}<br><br>/////////////////////////<br><br>/** Sample Application **/<br><br>$a = 1;<br>$b = 2;<br><br>list($a, $b) = hook('a_b', $a, $b);<br><br>$str = "This is my sample application\n";<br>$str .= "$a + $b = ".($a+$b)."\n";<br>$str .= "$a * $b = ".($a*$b)."\n";<br><br>$str = hook('str', $str);<br><br>echo $str;<br><br>?&gt;<br></code></pre>

<p><strong>Output:</strong></p>

<pre><code>This is my CRAZY application<br>4 + 5 = 9<br>4 * 5 = 20<br></code></pre>

<p><strong>Notes:</strong></p>

<p>For this example source code, you must declare all your plugins before the actual source code that you want to be extendable. I've included an example of how to handle single or multiple values being passed to the plugin. The hardest part of this is writing the actual documentation which lists what arguments get passed to each hook.</p>

<p>This is just one method of accomplishing a plugin system in PHP. There are better alternatives, I suggest you check out the WordPress Documentation for more information.</p>

<p><em>Sorry, it appears underscore characters are replaced by HTML entities by Markdown? I can re-post this code when this bug gets fixed.</em></p>

<p><em>Edit: Nevermind, it only appears that way when you are editing</em></p>" OwnerUserId="40" LastActivityDate="2008-08-01T13:46:00.097" CommentCount="2" CommunityOwnedDate="2011-02-10T01:43:58.203" />
<row Id="78" PostTypeId="2" ParentId="4" CreationDate="2008-08-01T13:53:06.357" Score="35" Body="<p>It sounds like <code>this.Opacity</code> is a double value, and the compiler doesn't like you trying to cram a decimal value into it.</p>
" OwnerUserId="55" LastEditorUserId="967315" LastEditDate="2012-10-14T11:54:40.347" LastActivityDate="2012-10-14T11:54:40.347" CommentCount="0" />
<row Id="79" PostTypeId="1" AcceptedAnswerId="62853" CreationDate="2008-08-01T13:56:33.837" Score="25" ViewCount="10556" Body="<p>The version of <strong>Subclipse (1.2.4)</strong> currently available through Aptana's automatic <em>Plugins Manager</em> does not work with the newest version of Subversion.</p>

<p>I see on the Subclipse website however that they have 1.4.2 out for Eclipse. So I added a <a href="http://subclipse.tigris.org/update_1.4.x">new remote update site</a> to my Update manager. When I tried to install it, it told me I needed <strong>Mylyn 3.0.0</strong>. So after much searching I found Mylyn 3.0.0 and added <a href="http://download.eclipse.org/tools/mylyn/update/e3.3">another new remote update site</a> to my update manager. Then when I tried to install that, it told me I needed <strong>org.eclipse.ui 3.3.0</strong> or equivalent.</p>

<p>Looking at the configuration details for Aptana, it looks like it is built against eclipse 3.2.2.</p>

<p>Does anyone know if there is a way to upgrade the version of Eclipse Aptana that is built against to 3.3.0? Or if there is some other way to get Subclipse to work with the very newest version of Subversion?</p>

<p>I know this isn't necessarily a "programming" question, but I hope it's ok since it's highly relevant to the programming experience.</p>
" OwnerUserId="58" OwnerDisplayName="Christopher McCulloh" LastEditorUserId="415755" LastEditorDisplayName="Gaius" LastEditDate="2016-03-10T03:47:08.200" LastActivityDate="2016-03-10T03:47:08.200" Title="Getting Subclipse in Aptana to work with the newest release of Subversion" Tags="<eclipse><svn><aptana><subclipse>" AnswerCount="4" CommentCount="0" FavoriteCount="1" />
<row Id="80" PostTypeId="1" AcceptedAnswerId="124" CreationDate="2008-08-01T13:57:07.033" Score="26" ViewCount="4384" Body="<p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime">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>
" OwnerUserId="26" LastEditorUserId="243557" LastEditorDisplayName="modesty" LastEditDate="2013-10-04T01:18:16.957" LastActivityDate="2013-10-04T01:18:16.957" Title="SQLStatement.execute() - multiple queries in one statement" Tags="<flex><actionscript-3><air>" AnswerCount="3" CommentCount="0" FavoriteCount="2" />
<row Id="81" PostTypeId="2" ParentId="34" CreationDate="2008-08-01T14:03:22.230" Score="10" Body="<p>I believe you have answered your own question...</p>

<p><code>System.totalMemory</code> gives you the total amount of memory being "used", not allocated. It is accurate that your application may only be using 20mb, but it has 5mb that is free for future allocations.</p>

<p>I'm not sure if the Adobe docs would shed light on the way that it manages memory...</p>
" OwnerUserId="41" LastEditorUserId="967315" LastEditDate="2012-10-14T12:18:19.590" LastActivityDate="2012-10-14T12:18:19.590" CommentCount="0" />
<row Id="82" PostTypeId="2" ParentId="36" CreationDate="2008-08-01T14:06:28.560" Score="13" Body="<p>Have a DTS job (or a job that is started by a windows service) that runs at a given interval. Each time it is run, it gets information about the given table by using the system <a href="http://msdn.microsoft.com/en-us/library/ms186778.aspx">INFORMATION_SCHEMA</a> tables, and records this data in the data repository. Compare the data returned regarding the structure of the table with the data returned the previous time. If it is different, then you know that the structure has changed.</p>

<p>Example query to return information regarding all of the columns in table ABC (ideally listing out just the columns from the INFORMATION_SCHEMA table that you want, instead of using <em>select *</em> like I do here):</p>

<pre><code>select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'ABC'
</code></pre>

<p>You would monitor different columns and INFORMATION_SCHEMA views depending on how exactly you define "changes to a table".</p>" OwnerUserId="51" LastActivityDate="2008-08-01T14:06:28.560" CommentCount="1" />
<row Id="84" PostTypeId="2" ParentId="16" CreationDate="2008-08-01T14:10:55.757" Score="5" Body="<p>If you use a return type of <code>IEnumerable</code>, you can return your <strong>query</strong> variable directly.</p>
" OwnerUserId="60" LastEditorUserId="5469" LastEditorDisplayName="Kilhoffer" LastEditDate="2008-10-18T18:26:59.070" LastActivityDate="2008-10-18T18:26:59.070" CommentCount="0" />
<row Id="85" PostTypeId="1" AcceptedAnswerId="154" CreationDate="2008-08-01T14:19:52.510" Score="76" ViewCount="32501" Body="<p>What are your best practices around creating flat file database structures in PHP? A lot of the more mature PHP flat file frameworks I see out there 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 the small code overhead one would want by taking on this problem in the first place?</p>" OwnerUserId="59" LastEditorUserId="243557" LastEditorDisplayName="saint_groceon" LastEditDate="2013-10-04T01:17:44.297" LastActivityDate="2015-08-24T17:50:22.107" Title="Flat File Databases" Tags="<php><sql><database><flat-file>" AnswerCount="13" CommentCount="0" FavoriteCount="15" ClosedDate="2015-10-22T13:43:51.340" />
<row Id="86" PostTypeId="2" ParentId="4" CreationDate="2008-08-01T14:23:28.087" Score="82" Body="<p>A more generic answer for the generic question "Decimal vs Double?": <strong>Decimal</strong> for monetary calculations to preserve the precision, <strong>Double</strong> for scientific calculations that do not get affected by small differences. Since Double is a type which is native to the CPU (internal representation is stored in <em>base 2</em>), calculations made with Double perform better then Decimal (which is represented in <em>base 10</em> internally).</p>
" OwnerUserId="39" LastEditorUserId="2354564" LastEditorDisplayName="huseyint" LastEditDate="2014-07-11T14:42:28.547" LastActivityDate="2014-07-11T14:42:28.547" CommentCount="0" />
<row Id="87" PostTypeId="2" ParentId="85" CreationDate="2008-08-01T14:26:22.793" Score="7" Body="<p>One framework I'm considering would be for a blogging platform. Since just about any possible view of data you would want would be sorted by date, I was thinking about this structure:</p>

<p>One directory per content node:</p>

<pre><code>./content/YYYYMMDDHHMMSS/
</code></pre>

<p>Subdirectories of each node including </p>

<pre><code>/tags 
/authors 
/comments 
</code></pre>

<p>As well as simple text files in the node directory for pre- and post-rendered content and the like.</p>

<p>This would allow a simple PHP <a href="http://us3.php.net/glob" rel="nofollow"><code>glob()</code></a> call (and probably a reversal of the result array) to query on just about anything within the content structure:</p>

<pre><code>glob("content/*/tags/funny"); 
</code></pre>

<p>Would return paths including all articles tagged "funny".</p>
" OwnerUserId="59" LastEditorUserId="4551041" LastEditDate="2015-08-24T17:19:04.537" LastActivityDate="2015-08-24T17:19:04.537" CommentCount="0" />
<row Id="88" PostTypeId="1" AcceptedAnswerId="98" CreationDate="2008-08-01T14:36:18.640" Score="67" ViewCount="32734" Body="<p>So I find myself 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). 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. 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>
" OwnerUserId="61" LastEditorDisplayName="user1645055" LastEditDate="2012-11-27T07:20:52.437" LastActivityDate="2016-02-11T04:02:08.480" Title="Is gettimeofday() guaranteed to be of microsecond resolution?" Tags="<linux><winapi><visual-c++><unix><timer>" AnswerCount="10" CommentCount="0" FavoriteCount="15" />
<row Id="89" PostTypeId="2" ParentId="79" CreationDate="2008-08-01T14:41:01.110" Score="4" Body="<p>I've had problems with JavaHL in Eclipse Ganymede, when it worked fine in Eclipse Europa. I'm not sure how Aptana is different, but try either upgrading JavaHL or switching to the pure-java SVNKit implementation within the Subclipse config.</p>" OwnerDisplayName="Ted Dziuba" LastActivityDate="2008-08-01T14:41:01.110" CommentCount="0" />
<row Id="90" PostTypeId="1" CreationDate="2008-08-01T14:41:24.277" Score="143" ViewCount="53362" Body="<p>Are there any really good tutorials explaining <a href="http://svnbook.red-bean.com/en/1.8/svn.branchmerge.html" rel="nofollow">branching and merging</a> with Apache Subversion? </p>

<p>All the better if it's specific to TortoiseSVN client.</p>
" OwnerUserId="58" OwnerDisplayName="Christopher McCulloh" LastEditorUserId="761095" LastEditorDisplayName="Gaius" LastEditDate="2016-06-23T13:23:04.250" LastActivityDate="2016-06-23T13:23:04.250" Title="Good branching and merging tutorials for TortoiseSVN?" Tags="<svn><tortoisesvn><branch><branching-and-merging>" AnswerCount="3" CommentCount="0" FavoriteCount="92" ClosedDate="2012-12-26T03:45:49.847" />
<row Id="92" PostTypeId="2" ParentId="90" CreationDate="2008-08-01T14:45:37.403" Score="12" Body="<p><a href="http://svnbook.red-bean.com/">Version Control with Subversion</a></p>

<p>A very good resource for source control in general. Not really TortoiseSVN specific, though.</p>" OwnerUserId="61" LastActivityDate="2008-08-01T14:45:37.403" CommentCount="0" />
<row Id="93" PostTypeId="2" ParentId="88" CreationDate="2008-08-01T14:46:53.097" Score="2" Body="<p>From my experience, and from what I've read across the internet, the answer is "No," it is not guaranteed. It depends on CPU speed, operating system, flavor of Linux, etc.</p>" OwnerUserId="25" LastEditorUserId="25" LastEditorDisplayName="Chris Reath" LastEditDate="2008-08-01T15:01:13.003" LastActivityDate="2008-08-01T15:01:13.003" CommentCount="0" />
<row Id="97" PostTypeId="2" ParentId="85" CreationDate="2008-08-01T14:52:53.537" Score="19" Body="<p>One way to store flat-file content would be to save literal arrays to php files. For example:</p>

<pre><code>$data = array();

if( $_POST ) {
 $data = $_POST;

 $content = "&lt;?php\n";
 $content .= '$data=' . var_export($data, true) . "\n";
 $content .= "?&gt;";

 save_to_file($filename, $content);
}

// echo form
</code></pre>
" OwnerUserId="40" LastEditorUserId="967315" LastEditorDisplayName="kevin d" LastEditDate="2012-10-14T12:26:49.687" LastActivityDate="2012-10-14T12:26:49.687" CommentCount="4" />
<row Id="98" PostTypeId="2" ParentId="88" CreationDate="2008-08-01T14:53:47.497" Score="45" Body="<p>Maybe. But you have bigger problems. <code>gettimeofday()</code> can result in incorrect timings if there are processes on your system that change the timer (ie, ntpd). On a "normal" linux, though, I believe the resolution of <code>gettimeofday()</code> is 10us. It can jump forward and backward and time, consequently, based on the processes running on your system. This effectively makes the answer to your question no.</p>

<p>You should look into <code>clock_gettime(CLOCK_MONOTONIC)</code> for timing intervals. It suffers from several less issues due to things like multi-core systems and external clock settings.</p>

<p>Also, look into the <code>clock_getres()</code> function.</p>
" OwnerUserId="2089740" LastEditorUserId="967315" LastEditorDisplayName="lbrandy" LastEditDate="2012-10-14T12:28:51.043" LastActivityDate="2012-10-14T12:28:51.043" CommentCount="5" />
<row Id="99" PostTypeId="2" ParentId="88" CreationDate="2008-08-01T14:55:08.477" Score="6" Body="<blockquote>
 <p>The actual resolution of gettimeofday() depends on the hardware architecture. Intel processors as well as SPARC machines offer high resolution timers that measure microseconds. Other hardware architectures fall back to the system’s timer, which is typically set to 100 Hz. In such cases, the time resolution will be less accurate. </p>
</blockquote>

<p>I obtained this answer from <a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=272">High Resolution Time Measurement and Timers, Part I</a></p>" OwnerUserId="25" LastActivityDate="2008-08-01T14:55:08.477" CommentCount="0" />
<row Id="100" PostTypeId="2" ParentId="85" CreationDate="2008-08-01T14:58:15.430" Score="12" Body="<p>That's true. <code>serialize()</code> can be pretty useful for that as well.</p>

<p>I think the trick to coming up with a viable system is finding some way to index the data nodes without killing yourself with complexity.</p>
" OwnerUserId="59" LastEditorUserId="967315" LastEditDate="2012-10-14T12:28:29.997" LastActivityDate="2012-10-14T12:28:29.997" CommentCount="0" />
<row Id="103" PostTypeId="2" ParentId="13" CreationDate="2008-08-01T15:11:59.987" Score="40" Body="<p>Javascript is the easiest way to get the client's local time. I would suggest using an <code>XMLHttpRequest</code> to send back the local time, and if that fails, fall back to the timezone detected based on their IP address.</p>

<p>As far as geolocation, I've used <a href="http://www.maxmind.com/app/ip-location">MaxMind GeoIP</a> on several projects and it works well, though I'm not sure if they provide timezone data. It's a service you pay for and they provide monthly updates to your database. They provide wrappers in several web languages.</p>
" OwnerUserId="72" LastEditorUserId="1039608" LastEditDate="2012-05-04T08:59:38.580" LastActivityDate="2012-05-04T08:59:38.580" CommentCount="3" />
<row Id="104" PostTypeId="1" AcceptedAnswerId="112" CreationDate="2008-08-01T15:12:34.837" Score="132" ViewCount="9795" Body="<p>In .NET perspective:</p>

<ul>
<li>What is a <strong><a href="http://en.wikipedia.org/wiki/Memory_leak">Memory Leak</a></strong>?</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>

<p>I have some answers for these questions myself, but they are incomplete. What do you think?</p>
" OwnerUserId="39" LastEditorDisplayName="user1645055" LastEditDate="2012-11-27T07:26:29.273" LastActivityDate="2016-01-19T10:30:03.883" Title="Anatomy of a "Memory Leak"" Tags="<.net><performance><memory-leaks><com-interop>" AnswerCount="15" CommentCount="0" FavoriteCount="61" />
<row Id="107" PostTypeId="2" ParentId="104" CreationDate="2008-08-01T15:19:25.900" Score="9" Body="<p>I guess in a managed environment, a leak would be you keeping an unnecessary reference to a large chunk of memory around. </p>" OwnerUserId="61" LastActivityDate="2008-08-01T15:19:25.900" CommentCount="0" />
<row Id="108" PostTypeId="1" AcceptedAnswerId="111" CreationDate="2008-08-01T15:22:29.467" Score="33" ViewCount="14495" Body="<p>I've been using <a href="http://tortoisesvn.tigris.org/">TortoiseSVN </a> in a Windows environment for quite some time. It seems very feature-complete and nicely integrated into the Windows shell, and more importantly, it's fairly painless to teach to colleagues with little or no experience with source control. <strong>However</strong>, since we have moved to Windows Vista 64bit, Tortoise has been very buggy and has seemed to cause lots of explorer.exe abnormalities and crashes. This has happened both with older versions of the software and the latest version (1.5.1 build 13563).</p>

<p>I was curious if anyone has suggestions for other Subversion clients that will run on Windows (specifically Vista 64bit). Developers here use a variety of text editors so using Visual Studio or Dreamweaver for SVN is not ideal.</p>

<p>I have heard great things about <a href="http://www.zennaware.com/cornerstone/">Cornerstone</a>, and would love something similar for Windows if it exists.</p>

<hr>

<p>I'm correlating the Vista/explorer problems with Tortoise because they normally occur when I'm using the functionality in Tortoise. Sometimes bringing up the "merge" screen will cause the GUI to start acting very strange and eventually hang or crash.</p>

<p>I did not see 1.5.2 -- I'm installing now, maybe that will fix some of my issues.</p>
" OwnerUserId="72" LastEditorUserId="1288" LastEditorDisplayName="Adam Mitz" LastEditDate="2011-11-20T13:46:24.733" LastActivityDate="2013-11-07T16:52:15.250" Title="Best Subversion clients for Windows Vista (64bit)" Tags="<windows><svn><64bit>" AnswerCount="8" CommentCount="0" FavoriteCount="2" ClosedDate="2012-08-15T19:45:13.350" />
<row Id="109" PostTypeId="1" AcceptedAnswerId="2585" CreationDate="2008-08-01T15:23:05.190" Score="30" ViewCount="4248" Body="<p>Recently our site has been deluged with the resurgence of the <a href="https://en.wikipedia.org/wiki/Asprox_botnet">Asprox botnet</a> <a href="http://en.wikipedia.org/wiki/SQL_injection">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">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">SQL&nbsp;Server</a>. The main part I need 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 byte.</p>

<p>I realized that I need to parse each 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>
" OwnerUserId="71" LastEditorUserId="63550" LastEditorDisplayName="Jeff Atwood" LastEditDate="2015-01-08T16:27:49.863" LastActivityDate="2015-01-08T17:02:44.503" Title="Decoding T-SQL CAST in C#/VB.NET" Tags="<c#><sql><vb.net><ascii><hex>" AnswerCount="2" CommentCount="3" />
<row Id="110" PostTypeId="2" ParentId="104" CreationDate="2008-08-01T15:23:33.817" Score="5" Body="<p>I will concur with Bernard as to in .net what a mem leak would be.</p>

<p>You could profile your application to see its memory use, and determine that if its managing a lot of memory when it should not be you could say it has a leak.</p>

<p>In managed terms I will put my neck on the line to say it does go away once the process is killed/removed.</p>

<p>Unmanaged code is its own beast and if a leak exists within it, it will follow a standard mem. leak definition.</p>
" OwnerUserId="36" LastEditorUserId="3393505" LastEditDate="2015-11-30T21:14:09.740" LastActivityDate="2015-11-30T21:14:09.740" CommentCount="0" />
<row Id="111" PostTypeId="2" ParentId="108" CreationDate="2008-08-01T15:27:23.093" Score="35" Body="<p>I have been using the 64Bit version of TortoiseSVN for ages and I have never had issues with it on Windows 64Bit or Vista 64Bit. I am currently not aware of any other similiar SVN clients that do work on Vista. Is it possible the problem could lie within the configuration of TortoiseSVN or even the installation of Vista? Is the problem occurring on Vista native or SP 1?</p>" OwnerUserId="146270" OwnerDisplayName="Diago" LastActivityDate="2008-08-01T15:27:23.093" CommentCount="2" />
<row Id="112" PostTypeId="2" ParentId="104" CreationDate="2008-08-01T15:28:12.543" Score="86" Body="<p>The best explanation I've seen is in Chapter 7 of the free <a href="http://codebetter.com/files/folders/codebetter_downloads/entry179694.aspx">Foundations of Programming ebook</a>.</p>

<p>Basically, in .NET a memory leak occurs when referenced objects are rooted and thus cannot be garbage collected. This occurs accidentally when you hold on to references beyond the intended scope.</p>

<p>You'll know that you have leaks when you start getting outofmemoryexceptions or your memory usage goes up beyond what you'd expect (perfmon has nice memory counters). </p>

<p>Understanding .NET's memory model is your best way of avoiding it. Specifically, understanding how the garbage collector works and how references work (again, I refer you to chapter 7 of the ebook). Also, be mindful of common pitfalls, probably the most common being events. If object A registered to an event on object B, then object A will stick around until object B disappears because B holds a reference to A. The solution is to unregister your events when you're done. </p>

<p>Of course, a good memory profile will let you see your object graphs and explore the nesting/referencing of your objects to see where references are coming from and what root object is responsible (<a href="http://www.red-gate.com/products/ants_memory_profiler/index.htm">red-gate ants profile</a>, JetBrains dotMemory, <a href="http://memprofiler.com/">memprofiler</a> are really good choices, or you can use the text-only windbg and sos, but I'd strongly recommend a commercial/visual product unless you're a real guru).</p>

<p>I believe unmanaged code is subject to typical memory leaks of unamanged code, except that references shared between the two are managed by the garbage collector. Could be wrong about this last point.</p>
" OwnerUserId="34" LastEditorUserId="80274" LastEditorDisplayName="GateKiller" LastEditDate="2015-11-30T21:55:33.390" LastActivityDate="2015-11-30T21:55:33.390" CommentCount="7" />
<row Id="113" PostTypeId="2" ParentId="108" CreationDate="2008-08-01T15:32:11.337" Score="6" Body="<p>I'll second Diago's answer. I use TortoiseSVN on Vista x64 pretty heavily.</p>

<p>I did upgrade directly from an older version to 1.5.2 though, and never used 1.5.1. Have you tried 1.5.2?</p>" OwnerUserId="60" LastActivityDate="2008-08-01T15:32:11.337" CommentCount="3" />
<row Id="114" PostTypeId="2" ParentId="108" CreationDate="2008-08-01T15:32:42.473" Score="9" Body="<p>TortoiseSVN in combination with VisualSVN for Visual Studio.</p>
" OwnerUserId="17" LastEditorUserId="761095" LastEditDate="2013-11-07T16:52:15.250" LastActivityDate="2013-11-07T16:52:15.250" CommentCount="0" />
<row Id="116" PostTypeId="2" ParentId="108" CreationDate="2008-08-01T15:34:43.873" Score="4" Body="<p>I too get explorer crashes in Vista (I'm not in the 64Bit version though). I'm using Vista Super Saijen (or whatever they are calling the most expensive version). I'm not having any bugs with Tortoise.</p>

<p>My explorer does, however, crash about every other day (sometimes multiple times a day if it's having an "off" day). I'm not positive it's being caused by TortoiseSVN though. From what I hear, the explorer just crashes a lot in Vista...</p>

<p>Have you tried uninstalling Tortoise and using Windows for a day or two and seeing if it still crashes? Do you restart your computer at least once a day (It seems the longer I go between restarts, the worse the crashes get)?</p>" OwnerUserId="58" LastActivityDate="2008-08-01T15:34:43.873" CommentCount="0" />
<row Id="120" PostTypeId="1" CreationDate="2008-08-01T15:50:08.537" Score="21" ViewCount="1115" Body="<p>Has anyone got experience creating <strong>SQL-based ASP.NET</strong> site-map providers?</p>

<p>I've got the default XML file <code>web.sitemap</code> working properly with my Menu and <strong>SiteMapPath</strong> controls, but I'll need a way for the users of my site to create and modify pages dynamically.</p>

<p>I need to tie page viewing permissions into the standard <code>ASP.NET</code> membership system as well.</p>
" OwnerUserId="83" OwnerDisplayName="Zack" LastEditorUserId="6127411" LastEditorDisplayName="Leon Bambrick" LastEditDate="2016-06-08T07:59:49.047" LastActivityDate="2016-06-08T07:59:49.047" Title="ASP.NET Site Maps" Tags="<sql><asp.net><sitemap>" AnswerCount="1" CommentCount="0" FavoriteCount="2" />
<row Id="123" PostTypeId="1" AcceptedAnswerId="183" CreationDate="2008-08-01T16:08:52.353" Score="72" ViewCount="57044" Body="<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>
" OwnerUserId="78" LastEditorUserId="2553431" LastEditorDisplayName="Jeff Atwood" LastEditDate="2015-10-27T09:34:09.503" LastActivityDate="2016-04-10T20:56:11.613" Title="Java lib or app to convert CSV to XML file?" Tags="<java><xml><csv><data-conversion>" AnswerCount="16" CommentCount="2" FavoriteCount="17" />
<row Id="124" PostTypeId="2" ParentId="80" CreationDate="2008-08-01T16:09:47.687" Score="11" Body="<p>I wound up using this. It is a kind of a hack, but it actually works pretty well. The only thing is you have to be very careful with your semicolons. : D</p>

<pre><code>var strSql:String = stream.readUTFBytes(stream.bytesAvailable); 
var i:Number = 0;
var strSqlSplit:Array = strSql.split(";");
for (i = 0; i &lt; strSqlSplit.length; i++){
 NonQuery(strSqlSplit[i].toString());
}
</code></pre>
" OwnerUserId="26" LastEditorUserId="63550" LastEditDate="2013-08-09T17:23:42.920" LastActivityDate="2013-08-09T17:23:42.920" CommentCount="2" />
<row Id="126" PostTypeId="1" AcceptedAnswerId="127" CreationDate="2008-08-01T16:10:30.337" Score="58" ViewCount="7891" Body="<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>
" OwnerUserId="58" LastEditorUserId="202431" LastEditorDisplayName="Gaius" LastEditDate="2010-01-20T08:27:13.130" LastActivityDate="2015-11-15T17:36:30.327" Title="How would you access Object properties from within an object method?" Tags="<java><php><oop><theory>" AnswerCount="18" CommentCount="0" FavoriteCount="4" ClosedDate="2012-05-08T18:11:27.270" />
<row Id="127" PostTypeId="2" ParentId="126" CreationDate="2008-08-01T16:13:47.600" Score="51" Body="<p>This has religious war potential, but it seems to me that if you're using a getter/setter, you should use it internally as well - using both will lead to maintenance problems down the road (e.g. somebody adds code to a setter that <em>needs</em> to run every time that property is set, and the property is being set internally w/o that setter being called).</p>" OwnerUserId="35" LastEditorUserId="35" LastEditorDisplayName="Greg" LastEditDate="2008-08-01T16:32:17.110" LastActivityDate="2008-08-01T16:32:17.110" CommentCount="2" />
<row Id="128" PostTypeId="2" ParentId="126" CreationDate="2008-08-01T16:19:04.283" Score="14" Body="<p>It depends on how the property is used. For example, say you have a student object that has a name property. You could use your Get method to pull the name from the database, if it hasn't been retrieved already. This way you are reducing unnecessary calls to the database.</p>

<p>Now let's say you have a private integer counter in your object that counts the number of times the name has been called. You may want to not use the Get method from inside the object because it would produce an invalid count.</p>" OwnerUserId="26" LastActivityDate="2008-08-01T16:19:04.283" CommentCount="2" />
<row Id="129" PostTypeId="1" CreationDate="2008-08-01T16:22:42.420" Score="65" ViewCount="90730" Body="<p>I've been banging my head against <code>SQL Server 2005</code> trying to get a lot of data out. I've been given a database with nearly 300 tables in it and I need to turn this into a MySQL database. My first call was to use bcp but unfortunately it doesn't produce valid CSV - strings aren't encapsulated, so you can't deal with any row that has a string with a comma in it (or whatever you use as a delimiter) and I would still have to hand write all of the create table statements, as obviously CSV doesn't tell you anything about the data types.</p>

<p>What would be better is if there was some tool that could connect to both SQL Server and MySQL, then do a copy. You lose views, stored procedures, trigger, etc, but it isn't hard to copy a table that only uses base types from one DB to another... is it?</p>

<p>Does anybody know of such a tool? I don't mind how many assumptions it makes or what simplifications occur, as long as it supports integer, float, datetime and string. I have to do a lot of pruning, normalising, etc. anyway so I don't care about keeping keys, relationships or anything like that, but I need the initial set of data in fast!</p>
" OwnerUserId="48" LastEditorUserId="4800955" LastEditorDisplayName="Mark Harrison" LastEditDate="2015-10-10T10:25:12.217" LastActivityDate="2015-10-10T10:25:12.217" Title="How to export data from SQL Server 2005 to MySQL" Tags="<mysql><sql-server><csv><sql-server-2005><bcp>" AnswerCount="5" CommentCount="5" FavoriteCount="22" ClosedDate="2012-07-03T14:30:16.880" />
<row Id="133" PostTypeId="2" ParentId="123" CreationDate="2008-08-01T16:31:43.430" Score="1" Body="<p>This may be too basic or limited of a solution, but couldn't you do a <a href="http://java.sun.com/j2se/7/docs/api/java/lang/String.html#split%28java.lang.String%29" rel="nofollow"><code>String.split()</code></a> on each line of the file, remembering the result array of the first line to generate the XML, and just spit each line's array data out with the proper XML elements padding each iteration of a loop?</p>
" OwnerUserId="59" LastEditorUserId="1102512" LastEditDate="2013-11-26T00:02:16.310" LastActivityDate="2013-11-26T00:02:16.310" CommentCount="1" />
<row Id="134" PostTypeId="1" AcceptedAnswerId="206" CreationDate="2008-08-01T16:33:38.183" Score="18" ViewCount="675" Body="<p>I have a pretty standard table set-up in a current application using the <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow">.NET</a> <a href="http://en.wikipedia.org/wiki/XML_Schema_%28W3C%29" rel="nofollow">XSD</a> <code>DataSet</code> and <code>TableAdapter</code> features. My <code>contracts</code> table consists of some standard contract information, with a column for the <code>primary department</code>. This column is a <a href="http://en.wikipedia.org/wiki/Foreign_key" rel="nofollow">foreign key</a> to my <code>Departments</code> table, where I store the basic <code>department name</code>, <code>id</code>, <code>notes</code>. This is all setup and functioning in my <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow">SQL Server</a>.</p>

<p>When I use the XSD tool, I can drag both tables in at once and it auto detects/creates the foreign key I have between these two tables. This works great when I'm on my main page and am viewing contract data.</p>

<p>However, when I go to my administrative page to modify the department data. I typically do something like this:</p>

<pre><code>Dim dtDepartment As New DepartmentDataTable()
Dim taDepartment As New DepartmentTableAdapter()

taDepartment.Fill(dtDepartment)
</code></pre>

<p>However, at this point an exception is thrown saying to the effect that there is a foreign key reference broken here, I'm guessing since I don't have the <code>Contract</code> <code>DataTable</code> filled. </p>

<p>How can I fix this problem? I know I can simply remove the foreign key from the XSD to make things work fine, but having the additional integrity check there and having the XSD schema match the SQL schema in the database is nice.</p>
" OwnerUserId="71" LastEditorUserId="3787519" LastEditorDisplayName="Jim Anderson" LastEditDate="2015-12-29T06:30:26.233" LastActivityDate="2016-03-23T12:07:52.153" Title="XSD DataSets and ignoring foreign keys" Tags="<.net><database><xsd>" AnswerCount="1" CommentCount="0" />
<row Id="135" PostTypeId="2" ParentId="129" CreationDate="2008-08-01T16:36:42.080" Score="5" Body="<p>Rolling your own PHP solution will certainly work though I'm not sure if there is a good way to automatically duplicate the schema from one DB to the other (maybe this was your question).</p>

<p>If you are just copying data, and/or you need custom code anyway to convert between modified schemas between the two DB's, I would recommend using PHP 5.2+ and the PDO libraries. You'll be able to connect using PDO ODBC (and use MSSQL drivers). I had a lot of problems getting large text fields and multi-byte characters from MSSQL into PHP using other libraries.</p>" OwnerUserId="72" LastActivityDate="2008-08-01T16:36:42.080" CommentCount="0" />
<row Id="139" PostTypeId="2" ParentId="126" CreationDate="2008-08-01T16:43:30.880" Score="10" Body="<blockquote>
 <p>Am I just going overboard here?</p>
</blockquote>

<p>Perhaps ;)</p>

<p>Another approach would be to utilize a private/protected method to actually do the getting (caching/db/etc), and a public wrapper for it that increments the count:</p>

<p>PHP:</p>

<pre><code>public function getName() {<br> $this-&gt;incrementNameCalled();<br> return $this-&gt;_getName();<br>}<br><br>protected function _getName() {<br> return $this-&gt;name;<br>}<br></code></pre>

<p>and then from within the object itself:</p>

<p>PHP:</p>

<pre><code>$name = $this-&gt;_getName();<br></code></pre>

<p>This way you can still use that first argument for something else (like sending a flag for whether or not to used cached data here perhaps). </p>" OwnerUserId="72" LastActivityDate="2008-08-01T16:43:30.880" CommentCount="0" />
<row Id="141" PostTypeId="2" ParentId="129" CreationDate="2008-08-01T16:47:54.927" Score="3" Body="<p>Another tool to try would be the SQLMaestro suite - http://www.sqlmaestro.com It is a little tricky nailing down the precise tool, but they have a variety of tools, both free and for purchase that handle a wide variety of tasks for multiple database platforms. I'd suggest trying the Data Wizard tool first for MySQL, since I believe that will have the proper "import" tool you need.</p>" OwnerUserId="71" LastActivityDate="2008-08-01T16:47:54.927" CommentCount="0" />
<row Id="142" PostTypeId="2" ParentId="126" CreationDate="2008-08-01T16:56:55.830" Score="5" Body="<P>Well, it seems with C# 3.0 properties' default implementation, the decision is taken for you; you HAVE to set the property using the (possibly private) property setter.</P>
<P>I personally only use the private member-behind when not doing so would cause the object to fall in an less than desirable state, such as when initializing or when caching/lazy loading is involved.</P>" OwnerUserId="42" LastActivityDate="2008-08-01T16:56:55.830" CommentCount="0" />
<row Id="143" PostTypeId="2" ParentId="126" CreationDate="2008-08-01T17:01:27.240" Score="4" Body="<p>As stated in some of the comments: Sometimes you should, sometimes you shouldn't. The great part about private variables is that you are able to see all the places they are used when you change something. If your getter/setter does something you need, use it. If it doesn't matter you decide.</p>

<p>The opposite case could be made that if you use the getter/setter and somebody changes the getter/setter they have to analyze all the places the getter and setter is used internally to see if it messes something up. </p>" OwnerUserId="86" LastActivityDate="2008-08-01T17:01:27.240" CommentCount="0" />
<row Id="145" PostTypeId="1" CreationDate="2008-08-01T17:13:08.933" Score="30" ViewCount="2199" Body="<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>

<p><img src="http://i.stack.imgur.com/O0LGd.png" alt=""></p>
" OwnerUserId="87" LastEditorUserId="87" LastEditorDisplayName="kevin d" LastEditDate="2014-09-13T13:14:05.237" LastActivityDate="2016-01-20T15:31:50.297" Title="Compressing / Decompressing Folders & Files" Tags="<c#><.net><compression><decompression>" AnswerCount="8" CommentCount="0" FavoriteCount="1" CommunityOwnedDate="2014-04-04T13:02:49.830" />
<row Id="146" PostTypeId="1" AcceptedAnswerId="152" CreationDate="2008-08-01T17:14:58.337" Score="46" ViewCount="13697" Body="<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 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>
" OwnerUserId="30" LastEditorUserId="3001352" LastEditDate="2016-04-22T05:33:06.060" LastActivityDate="2016-06-09T09:38:50.137" Title="How do I track file downloads" Tags="<php><apache><logging><download><analytics>" AnswerCount="8" CommentCount="0" FavoriteCount="7" />
<row Id="147" PostTypeId="2" ParentId="42" CreationDate="2008-08-01T17:23:43.777" Score="21" Body="<p>The <em>hook</em> and <em>listener</em> method is the most commonly used, but there are other things you can do. Depending on the size of your app, and who your going to allow see the code (is this going to be a FOSS script, or something in house) will influence greatly how you want to allow plugins.</p>

<p>kdeloach has a nice example, but his implementation and hook function is a little unsafe. I would ask for you to give more information of the nature of php app your writing, And how you see plugins fitting in. </p>

<p>+1 to kdeloach from me.</p>" OwnerUserId="146637" OwnerDisplayName="dubayou" LastActivityDate="2008-08-01T17:23:43.777" CommentCount="0" />
<row Id="148" PostTypeId="2" ParentId="146" CreationDate="2008-08-01T17:24:24.290" Score="3" Body="<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>" OwnerUserId="71" LastActivityDate="2008-08-01T17:24:24.290" CommentCount="0" />
<row Id="149" PostTypeId="2" ParentId="145" CreationDate="2008-08-01T17:28:24.253" Score="8" Body="<p>As of .Net 1.1 the only available method is reaching into the java libraries.<br>
<a href="http://msdn.microsoft.com/en-ca/magazine/cc164129.aspx">Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#</a><br>
Not sure if this has changed in recent versions.</p>" OwnerUserId="80" LastActivityDate="2008-08-01T17:28:24.253" CommentCount="0" />
<row Id="151" PostTypeId="2" ParentId="145" CreationDate="2008-08-01T17:30:56.277" Score="17" Body="<p>I've always used the SharpZip Library.</p>

<p><a href="http://sharpdevelop.net/OpenSource/SharpZipLib/Download.aspx">Here's a link</a></p>
" OwnerUserId="44" LastEditorUserId="1525840" LastEditorDisplayName="Jeff Atwood" LastEditDate="2012-12-04T20:29:28.010" LastActivityDate="2012-12-04T20:29:28.010" CommentCount="1" />
<row Id="152" PostTypeId="2" ParentId="146" CreationDate="2008-08-01T17:33:58.750" Score="28" Body="<p>The funny thing is i wrote a php media gallery for all my music 2 days ago. I had a similar problem. Im using <a href="http://musicplayer.sourceforge.net/">http://musicplayer.sourceforge.net/</a> for the player. and the playlis are built via php. all music request go there a script called xfer.php?file=WHATEVER</p>

<pre><code>$filename = base64_url_decode($_REQUEST['file']);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($filename));

// Put either file counting code here. either a db or static files

//

readfile($filename); //and spit the user the file


function base64_url_decode($input) {
 return base64_decode(strtr($input, '-_,', '+/='));
}
</code></pre>

<p>And when you call files use something like </p>

<pre><code>function base64_url_encode($input) {
 return strtr(base64_encode($input), '+/=', '-_,');
}
</code></pre>

<p><a href="http://us.php.net/manual/en/function.base64-encode.php">http://us.php.net/manual/en/function.base64-encode.php</a></p>

<p>If you are using some javascript or a flash player (JW player for example) that requires the actual link to be an mp3 file or whatever, you can append the text "&amp;type=.mp3" so the final linke becomes something like "www.example.com/xfer.php?file=34842ffjfjxfh&amp;type=.mp3". That way it looks like it ends with an mp3 extension without affecting the file link.</p>
" OwnerUserId="146637" OwnerDisplayName="dubayou" LastEditorUserId="30" LastEditorDisplayName="Grant" LastEditDate="2008-08-10T12:16:40.330" LastActivityDate="2008-08-10T12:16:40.330" CommentCount="4" />
</posts>