Andrew Harvey's Blog - Entries from January 2010Entries from January 2010
//tianjara.net/blog/
en-auThe content on this blog by Andrew Harvey, unless otherwise noted is licensed under a Creative Commons Attribution 3.0 Australia License.Chronicle/blog/img/blog-icon.pngAndrew Harvey's Blog
//tianjara.net/blog/
anonymous FTP
/blog/archive/2010/01/anonymous_ftp.html
/blog/archive/2010/01/anonymous_ftp.htmlFri, 22 Jan 2010 10:17:36 +1100<p>So I've started reading a book about networks, and to complement this I've been taking a closer look at my network traffic in Wireshark (really great tool, by the way.).</p>
<p>So I pick an ftp site that I know, ftp://download.nvidia.com/ and see what happens in Wireshark when I visit it in Firefox. At the FTP application level this is what happens,</p>
<pre>ftpsite to me: 220 spftp/1.0.0000 Server [69.31.121.43]\r\n
me to ftpsite: USER anonymous\r\n
ftpsite to me: 331 Password required for USER.\r\n
me to ftpsite: PASS mozilla@example.com\r\n
ftpsite to me: 230- \r\n
230- ---------------------------------------------------------------------------\r\n
230- WARNING: This is a restricted access system. If you do not have explicit\r\n
230- permission to access this system, please disconnect immediately!\r\n
230 ----------------------------------------------------------------------------\r\n
</pre>
<p>But Firefox does not disconnect. So I did some more research and I found no references to "anonymous" users in either RFC 959 (FTP) or RFC 3659 (extensions to FTP). (Though there are references in latter RFCs, see <a href="http://tools.ietf.org/html/rfc2228">RFC 2228</a>).</p>
<p>The thing I find disconcerting is that I don't think I have "explicit permission" to access this system. I (or rather Firefox) just guessed a username and password and they happened to let me in (what if I guessed a different username and password that wasn't anonymous and it let me in?). If the RFC specified that a user of anonymous requires no password, or any password, then I would assume that the FTP server is granting me permission, but I assume rather people just started using anonymous as the user and it caught on...</p>
<p>The real problem here is that there are<a href="http://www.austlii.edu.au/au/legis/nsw/consol_act/ca190082/s308h.html"> laws which govern such areas</a>, and it doesn't help that that I don't understand what PART 6 - COMPUTER OFFENCES of the <a href="http://www.austlii.edu.au/au/legis/nsw/consol_act/ca190082/index.html">CRIMES ACT 1900</a> (NSW) is saying.</p>
<pre>
</pre>
To fix broken audio, unplug faulty USB device.
/blog/archive/2010/01/to_fix_broken_audio__unplug_faulty_usb_device_.html
/blog/archive/2010/01/to_fix_broken_audio__unplug_faulty_usb_device_.htmlTue, 19 Jan 2010 09:08:02 +1100<p>How weird is this, just recently when I started up my computer lots of stuff was broken, no audio (and /proc/asound/cards was empty, normally it has "0 [Intel ]: HDA-Intel - HDA Intel\nHDA Intel at 0xfa100000 irq 22"), libsensors weren't reporting any values (eg. no CPU temp reported), eth0 dissapeared from NetworkManager, and probably a host of other things that I didn't notice. Restarting didn't fix it.</p>
<p>Well long story short, it turns out that everything magically fixed when I unplugged a USB hard drive that was plugged in. I had seen a lot of concerning messages sent to /var/log/messages from the kernel about it,</p>
<p>Jan 19 09:45:00 host kernel: [ 564.100026] usb 1-3: reset high speed USB device using ehci_hcd and address 2
Jan 19 09:45:00 host kernel: [ 564.237716] sd 8:0:0:0: [sdd] Unhandled error code
Jan 19 09:45:00 host kernel: [ 564.237719] sd 8:0:0:0: [sdd] Result: hostbyte=DID_ABORT driverbyte=DRIVER_OK</p>
<p>that repeated every so often, but I never thought that a dodgy USB device would break the kernel from doing some of its job.</p>
A Maths Problem: Transformed Horizontal Lines
/blog/archive/2010/01/a_maths_problem__transformed_horizontal_lines.html
/blog/archive/2010/01/a_maths_problem__transformed_horizontal_lines.htmlThu, 7 Jan 2010 18:09:40 +1100<p>This is the kind of post that I originally envisioned that I would post about when I started this blog. But after trying to complete this post I realised why I don't do this very much, because I can't always solve the problems I come up with. Anyway...</p>
<p>You can generate a funky kind of grid by taking a Cartesian coordinate system, joining lines from $latex (0, t)$ to $latex (t, 0)$ for some values <em>t</em>. Here are some examples,</p>
<p><a href="/blog/attachments/2010/01/montage_2.png"><img class="aligncenter size-full wp-image-981" title="Transformed Grid Montage" src="/blog/attachments/2010/01/montage_2.png" alt="Transformed Grid Montage" width="412" height="1236" /></a></p>
<p>If you draw lots of lines you get something like,</p>
<p>[caption id="attachment_982" align="aligncenter" width="500" caption="Generated using code at http://github.com/andrewharvey/cairomisc/blob/bd41c8feb1beba38849878aed566c6f45a70856b/curved_grid_simple.pl"]<a href="/blog/attachments/2010/01/inc050.png"><img class="size-full wp-image-982" title="Transformed Grid 50 lines" src="/blog/attachments/2010/01/inc050.png" alt="Transformed Grid (50 lines)" width="500" height="500" /></a>[/caption]</p>
<p style="text-align:left;">This is also what you get if you take a bunch of horizontal lines from $latex x = 0$ to $latex x = 1$ (where the horizontal lines are equally spaced above each other), and take all the endpoints from the line $latex x = 1$ and rotate them $latex 90^\circ$ about the point $latex 1, 0$.</p>
<p style="text-align:left;">The thing I was interested in was as you draw more and more of these lines it looks like a curve emerges on the boundary. I imagined that if you drew infinitely many lines like these you would get a nice smooth curve. I want to know what is the formula for that curve. But as I started to try to work it out, it didn't seem so simple.</p>
<p style="text-align:left;">I tried a lot of approaches, none of which seemed to work. So after a few initial set backs I tried to take a parametric approach taking <em>t</em> to be a value between 0 and 1 where this <em>t</em> indicates the line with start point $latex (0, t)$. The point on the curve for this <em>t</em> is some point on that line. I tried to get that point via the intersection with the next line, ie. the point on this line that is also on the curve is between the intersection of that line and the line for $latex t + \phi$ and $latex t - \phi$ for some really small $latex \phi$. But when I tried this approach as you make $latex \phi$ zero, then we get infinitely many points of intersection.</p>
<p style="text-align:left;">That didn't work so easy but then I realised that if the point is on this line then (although I have not proved this but it seems obvious from the picture) that I have the gradient.</p>
<p style="text-align:left;">So all those lines as shown above have equation $latex y = \frac{-t}{\left ( 1 - t \right )}x + t$. (Except for t = 1 where we'll just use a y value of 1). We can use this same <em>t</em> to define a point on the curve (which I call $latex f$ from here on) parametrically. So I assumed that the gradient of $latex f$ is given as $latex f'(t) = \frac{-t}{1-t}$. But now I'm not so sure that I have enough rigour here.</p>
<p style="text-align:left;">But then I got stuck again. I can try to go some integrals but this won't work because you don't know the relation between increasing <em>t</em> and the length along the curved you have moved. As you could have two different parametric functions which both have the same derivative function (ignoring the +c constant that disappears when you differentiate), just knowing the function defining the derivative of $latex f$ parametrically won't tell me the equation of the original curve.</p>
<p style="text-align:left;">Moving on I now tried to calculate the area under the curve. I could partition it like how a Riemann integral is done.</p>
<p style="text-align:center;"><a href="/blog/attachments/2010/01/discret_areas_axis_withdots.png"><img class="aligncenter size-full wp-image-988" title="discret_areas_axis_withdots" src="/blog/attachments/2010/01/discret_areas_axis_withdots.png" alt="discret_areas_axis_withdots" width="585" height="560" /></a></p>
<p style="text-align:left;">We can easily calculate the area of any of these trapezoids (bounded by red). $latex A = \frac{x_n - x_{(n-1)}}{2}(y_{x_n} + y_{x_{(n-1)}})$. We can get the <em>x</em> values by finding the point of intersection of the 2 lines that intersect at that <em>x</em> (and have the largest <em>y</em> value if there are several points of intersection for that <em>x</em>). Each line for some value <em>t</em> will have a point of intersection of the line before and after it (based on the <em>t</em> value). When I say the area of <em>t</em> = some number, I mean the area of the trapezoid starting with the intersection of the previous <em>t</em> line and ending with the intersection of the next <em>t</em> line. So the area of t = 1 is zero (because <em>x</em><sub>0</sub> and <em>x</em><sub>1</sub> are the same). The diagram above has $latex \phi = 0.125$. So,</p>
<p style="text-align:left;">Point A is the intersection of $latex y = \frac{-t}{\left ( 1-t \right )}x + t$ and $latex y = \frac{- \left ( t + \phi \right )}{1-\left ( t + \phi\right )}x + t + \phi$, which is,</p>
<p style="text-align:left;">$latex x_A = (1-t)(1-t-\phi)$
$latex y_A = t(t+\phi)$</p>
<p style="text-align:left;">Point B is the intersection of $latex y = \frac{-t}{\left ( 1-t \right )}x + t$ and $latex y = \frac{- \left ( t - \phi \right )}{1-\left ( t - \phi\right )}x + t - \phi$, which is,</p>
<p style="text-align:left;">$latex x_B = (1-t)(1-t+\phi)$
$latex y_B = t(t-\phi)$</p>
<p style="text-align:left;">So the area of this trapezoid is $latex \frac{x_B - x_A}{2}(y_A + y_B)$, which is $latex 2t^2\phi(1-t)$</p>
<p style="text-align:left;">But then I got stuck here. I can compute a value for the approximate area.</p>
<pre style="text-align:left;padding-left:30px;">phi = 0.0001;
area = 0;
for (t = 1; t > 0; t -= phi) {
area += 2*t*t*phi*(1-t);
}
print area;
</pre>
<p>Which gives a value very close to 1/6, and if I integrate that area equation for <em>t</em> = 0..1 you get $latex \frac{1}{6}\phi$. But I don't want the area, I want the formula that defines the area from <em>x</em> = 0 to some value <em>x</em> so that I can then differentiate this to get the equation of the original curve. So this is where I give up, and leave this for another day. If you work it out please post in the comments!</p>
<p>Oh and there is <a href="http://github.com/andrewharvey/cairomisc/tree/master/curved_grid_1/">some rough code I wrote to make those images here</a>. And a nice <a href="http://github.com/andrewharvey/cairomisc/raw/master/curved_grid_1/2to300lines.mp4">animation too</a>.</p>
Law + Revision Control + Wiki
/blog/archive/2010/01/law___revision_control___wiki.html
/blog/archive/2010/01/law___revision_control___wiki.htmlMon, 4 Jan 2010 14:53:38 +1100<p>What happens when you mix a service like <a href="http://www.austlii.edu.au/au/legis/cth/consol_act/">AustLii</a> with version control system like Git with a wiki like editing system, and deliver it to the people through the web?</p>
<p>Well I haven't tried, but it sounds like a good idea. You get a service that,</p>
<ul>
<li>allows anyone to propose changes to laws (and work on branches) or draft and new laws, and</li>
<li>keeps track of the law and when it was changed (and which politicians/parties introduced those changes, who voted for them, etc...).</li>
</ul>