<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	 xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 
>

<channel>
	<title>Simeon Pilgrim</title>
	<link>http://simeonpilgrim.com/blog</link>
	<description>Not just another WordPress weblog</description>
	<pubDate>Tue, 07 Oct 2008 02:24:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>Two fantastic video&#8217;s on CDOs and Credit Default Swaps</title>
		<link>http://simeonpilgrim.com/blog/2008/10/07/two-fantastic-videos-on-cdos-and-credit-default-swaps/</link>
		<comments>http://simeonpilgrim.com/blog/2008/10/07/two-fantastic-videos-on-cdos-and-credit-default-swaps/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 02:23:41 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Finance]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/10/07/two-fantastic-videos-on-cdos-and-credit-default-swaps/</guid>
		<description><![CDATA[Two videos by Paddy Hirsch of Marketplace, that are very worth watching if you want to know what CDOs or Credit Default Swaps are.
The first: Uncorking CDOs (Collateralized Debt Obligations)


And the second: Credit Default Swaps


via Presentation Zen
]]></description>
			<content:encoded><![CDATA[<p>Two videos by Paddy Hirsch of <a href="http://marketplace.publicradio.org/">Marketplace</a>, that are very worth watching if you want to know what CDOs or Credit Default Swaps are.</p>
<p>The first: Uncorking CDOs (Collateralized Debt Obligations)</p>
<p class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:e8d2bfa6-1329-474e-879f-c7d31f497abf" style="margin: 0px; padding: 0px; display: inline">
<p id="6f63b442-0394-4f58-a3c1-d4eb4be71873" style="margin: 0px; padding: 0px; display: inline"><a href="http://www.youtube.com/watch?v=eb_R1-PqRrw&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=ja&amp;fs=1" target="_new"><img src="http://simeonpilgrim.com/images/TwofantasticvideosonCDOsandCreditDefault_D7E6/video9441b4d382ae.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('6f63b442-0394-4f58-a3c1-d4eb4be71873'); downlevelDiv.innerHTML = " name="\"movie\"" value="\"http://www.youtube.com/v/eb_R1-PqRrw&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=ja&amp;fs=1\"&gt;&lt;\/param&gt;&lt;param" type="\"application/x-shockwave-flash\"" wmode="\"transparent\"" width="425" height="355" /></a></p>
<p>And the second: Credit Default Swaps</p>
<p class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:971cd50f-abad-4662-a1cf-7a16ee6a3ddb" style="margin: 0px; padding: 0px; display: inline">
<p id="391ecd03-48c7-4cc2-a113-9c2166e73837" style="margin: 0px; padding: 0px; display: inline"><a href="http://www.youtube.com/watch?v=IGyFIvNJJ9g&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=ja&amp;fs=1" target="_new"><img src="http://simeonpilgrim.com/images/TwofantasticvideosonCDOsandCreditDefault_D7E6/video78e06add6935.jpg" galleryimg="no" onload="var downlevelDiv = document.getElementById('391ecd03-48c7-4cc2-a113-9c2166e73837'); downlevelDiv.innerHTML = " name="\"movie\"" value="\"http://www.youtube.com/v/IGyFIvNJJ9g&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=ja&amp;fs=1\"&gt;&lt;\/param&gt;&lt;param" type="\"application/x-shockwave-flash\"" wmode="\"transparent\"" width="425" height="355" /></a></p>
<p>via <a href="http://www.presentationzen.com/presentationzen/">Presentation Zen</a></p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/10/07/two-fantastic-videos-on-cdos-and-credit-default-swaps/feed/</wfw:commentRss>
	<slash:comments>4</slash:comments>
	</item>
		<item>
		<title>The Me Meme</title>
		<link>http://simeonpilgrim.com/blog/2008/10/04/the-me-meme/</link>
		<comments>http://simeonpilgrim.com/blog/2008/10/04/the-me-meme/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 21:33:59 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/10/04/the-me-meme/</guid>
		<description><![CDATA[
Take a picture of yourself right now.
Don’t change your clothes, don’t fix your hair…just take a picture. (should be super-easy with Photobooth)
Post that picture with NO editing.
Post these instructions with your picture.
Via Raganwald
]]></description>
			<content:encoded><![CDATA[<p><a href='http://simeonpilgrim.com/blog/wp-content/uploads/2008/10/photo-14.jpg' title='Me right now!'><img src='http://simeonpilgrim.com/blog/wp-content/uploads/2008/10/photo-14.thumbnail.jpg' alt='Me right now!' /></a></p>
<p>Take a picture of yourself right now.<br />
Don’t change your clothes, don’t fix your hair…just take a picture. (should be super-easy with Photobooth)<br />
Post that picture with NO editing.<br />
Post these instructions with your picture.</p>
<p>Via <a href="http://www.flickr.com/photos/raganwald/2909791653/">Raganwald</a></p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/10/04/the-me-meme/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>Update from the United States</title>
		<link>http://simeonpilgrim.com/blog/2008/09/23/update-from-the-united-states/</link>
		<comments>http://simeonpilgrim.com/blog/2008/09/23/update-from-the-united-states/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 05:18:34 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Travel]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/09/23/update-from-the-united-states/</guid>
		<description><![CDATA[Well I have not posted for a while, and that has mostly been because I have been getting ready for, traveling, or just being in the States.
So far I have had a grill (NZ BBQ) in Livermore (San Francisco), CA
Visited a mine site (but not gone out into the actual Mine) in Gillette, WY
Visited Caterpillar&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Well I have not posted for a while, and that has mostly been because I have been getting ready for, traveling, or just being in the States.</p>
<p>So far I have had a grill (NZ BBQ) in Livermore (San Francisco), CA</p>
<p>Visited a mine site (but not gone out into the actual Mine) in Gillette, WY</p>
<p>Visited Caterpillar&#8217;s massive proving grounds in Peoria, IL</p>
<p>Gotten bored in Las Vegas, NV (where I currently am).</p>
<p>After a couple of Hotels with free Wifi/Internet, free breakfast and free local calls, Las Vegas is to be a huge disappointment of what it deliveries and a huge just pay more at each step.</p>
<p>However, <a href="http://www.minexpo.com/">MinExpo 2008</a> is fantastic, and I&#8217;ll take my camera tomorrow and capture many great big machines close-up.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/09/23/update-from-the-united-states/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>TimeDirection graph</title>
		<link>http://simeonpilgrim.com/blog/2008/09/08/timedirection-graph/</link>
		<comments>http://simeonpilgrim.com/blog/2008/09/08/timedirection-graph/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 22:56:44 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/09/08/timedirection-graph/</guid>
		<description><![CDATA[A work college was wanting some trivial code to draw a time based direction plot, and insisted that I do it.
So here is my drawing class:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace LineCurve
{
    public class TimeDirection
    {
        public void Draw(Graphics g, Panel pnl, List&#60;KeyValuePair&#60;int,float&#62;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>A work college was wanting some trivial code to draw a time based direction plot, and insisted that I do it.</p>
<p>So here is my drawing class:</p>
<pre class="code"><span style="color: #0000ff">using</span> System;
<span style="color: #0000ff">using</span> System.Collections.Generic;
<span style="color: #0000ff">using</span> System.Drawing;
<span style="color: #0000ff">using</span> System.Windows.Forms;

<span style="color: #0000ff">namespace</span> LineCurve
{
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">TimeDirection
</span>    {
        <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Draw(<span style="color: #2b91af">Graphics</span> g, <span style="color: #2b91af">Panel</span> pnl, <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: #0000ff">int</span>,<span style="color: #0000ff">float</span>&gt;&gt; data, <span style="color: #0000ff">int</span> maxtime)
        {
            <span style="color: #0000ff">using</span> (<span style="color: #2b91af">Brush</span> brush = <span style="color: #0000ff">new</span> <span style="color: #2b91af">SolidBrush</span>(<span style="color: #2b91af">Color</span>.Blue))
            {
                <span style="color: #0000ff">float</span> halfx = pnl.Width / 2.0f;
                <span style="color: #0000ff">float</span> halfy = pnl.Height / 2.0f;
                <span style="color: #0000ff">float</span> scale = <span style="color: #2b91af">Math</span>.Min(halfx, halfy) / (<span style="color: #0000ff">float</span>)maxtime;

                <span style="color: #0000ff">foreach</span> (<span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: #0000ff">int</span>, <span style="color: #0000ff">float</span>&gt; kvp <span style="color: #0000ff">in</span> data)
                {
                    <span style="color: #0000ff">int</span> time = kvp.Key;
                    <span style="color: #0000ff">double</span> dir = kvp.Value / 180.0 * <span style="color: #2b91af">Math</span>.PI;

                    <span style="color: #008000">// subtrack y as 0 is top, and +y is bottom.
</span>                    <span style="color: #0000ff">float</span> fx = (<span style="color: #0000ff">float</span>)(halfx + (<span style="color: #2b91af">Math</span>.Sin(dir) * scale * time));
                    <span style="color: #0000ff">float</span> fy = (<span style="color: #0000ff">float</span>)(halfy - (<span style="color: #2b91af">Math</span>.Cos(dir) * scale * time));

                    g.FillRectangle(brush,fx, fy, 1.0f, 1.0f);
                }
            }
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And given the input:</p>
<pre class="code"><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: #0000ff">int</span>,<span style="color: #0000ff">float</span>&gt;&gt; data = <span style="color: #0000ff">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: #0000ff">int</span>,<span style="color: #0000ff">float</span>&gt;&gt;();
<span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 40; i++)
{
    data.Add(<span style="color: #0000ff">new</span> <span style="color: #2b91af">KeyValuePair</span>&lt;<span style="color: #0000ff">int</span>, <span style="color: #0000ff">float</span>&gt;(i, i * 9.0f));
}

td.Draw(g, pnl, data, 40);</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>Looks like this:</p>
<p><img src="http://simeonpilgrim.com/blog/wp-content/uploads/2008/09/time-direction.png" alt="time/direction based graph" /></p>
<p>This code is released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>, except it may not be used for web-based weather applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/09/08/timedirection-graph/feed/</wfw:commentRss>
	<slash:comments>1</slash:comments>
	</item>
		<item>
		<title>Learning to use foldl and map</title>
		<link>http://simeonpilgrim.com/blog/2008/09/02/learning-to-use-foldl-and-map/</link>
		<comments>http://simeonpilgrim.com/blog/2008/09/02/learning-to-use-foldl-and-map/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 21:48:16 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/09/02/learning-to-use-foldl-and-map/</guid>
		<description><![CDATA[ I have been working on a small line drawing project, and part of that project is indexing nested lists based on sets of indices.
Firstly I wrote a function to return the recursive nth item.  So for this data [[[1,2],[3,4]],[[5,6],[7,8]]] and the input [1,2,1] the value 3 is returned.  Here&#8217;s my original function:
point(Cube,[First&#124;Rest]) -&#62;
    [...]]]></description>
			<content:encoded><![CDATA[<p> I have been working on a small line drawing project, and part of that project is indexing nested lists based on sets of indices.</p>
<p>Firstly I wrote a function to return the recursive nth item.  So for this data [[[1,2],[3,4]],[[5,6],[7,8]]] and the input [1,2,1] the value 3 is returned.  Here&#8217;s my original function:</p>
<pre>point(Cube,[First|Rest]) -&gt;
    point(lists:nth(First,Cube),Rest);
point(Cube,[]) -&gt;
    Cube.</pre>
<p>I then had a couple of functions to return point lists for each list of points look-ups.  The first <em>line</em> was for connected points, and the second <em>lines</em> to draw separate lines.  So using the same data above, and the input [[1,2,1],[2,2,2],[1,1,1]] to <em>line</em> would generate [3,8,1], and lists of that input to <em>lines</em> creates lists of results.  Brilliant I know, here&#8217;s my code:</p>
<pre>lines(Cube,Lines) -&gt;
    lines(Cube,lists:reverse(Lines),[]).

lines(_Cube,[], Output) -&gt;
    Output;
lines(Cube,[First|Rest], Output) -&gt;
    lines(Cube,Rest,[line(Cube,First)|Output]).

line(Cube,Points) -&gt;
    line(Cube,lists:reverse(Points),[]).
line(Cube,[First|Rest],Output) -&gt;
    line(Cube,Rest,[point(Cube,First)|Output]);

line(_Cube,[],Output) -&gt;
    Output.</pre>
<p>I used a wrapper function to reverse the input, to solve the list construction order.  I was quite proud of my groking tail recursion.  But couldn&#8217;t help notice <em>line</em> and <em>lines</em> are the same, but not the same.  While reading how to do the output formatting, I came across some good examples on using foldl and map.  Surprise, the examples where like my functions, so I rewrote them like this (renaming <em>point</em> to <em>nth_nth</em>):</p>
<pre>lines(Cube,Lines) -&gt;
    lists:map(fun(Line) -&gt; line(Cube, Line) end, Lines).

line(Cube,Points) -&gt;
    lists:map(fun(Point) -&gt; nth_nth(Cube, Point) end, Points).

nth_nth(Vals,Nths) -&gt;
    lists:foldl(fun(Nth,List) -&gt; lists:nth(Nth,List) end, Vals, Nths).</pre>
<p>Much better, but I started to have a nagging feeling about using anonymous functions to just call a single function.  I then found the way to refer to <a href="http://www1.erlang.org/doc/programming_examples/funs.html#2.3">other functions</a> by name, but this does not work for the <em>map</em> as I am binding an extra variable, but for <em>foldl</em> it does work as it&#8217;s arity is 2, thus <em>nth_nth</em> can be written as:</p>
<pre>nth_nth(Vals,Nths) -&gt;
    lists:foldl({list,nth}, Vals, Nths).</pre>
<p>I thought the use of the fold function to return nested look-up results was clever. The new functions have less total lines, but each line is much denser, so may appear harder to read, but I am using standard functions so the cost to comprehend should be lower.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/09/02/learning-to-use-foldl-and-map/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>Evils of typedefs and legacy code</title>
		<link>http://simeonpilgrim.com/blog/2008/09/01/evils-of-typedefs-and-legacy-code/</link>
		<comments>http://simeonpilgrim.com/blog/2008/09/01/evils-of-typedefs-and-legacy-code/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 21:27:37 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[C++]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/08/29/evils-of-typedefs-and-legacy-code/</guid>
		<description><![CDATA[Our legacy C++ codebase once was a C codebase.  Way back then, there was no standard boolean type.  So in the wisdom of the day a type was declared
typedef int tBool;
The major problem with tBool&#8217;s is that over time enums, #define or magic constants get assigned to them, or they can be compared to said [...]]]></description>
			<content:encoded><![CDATA[<p>Our legacy C++ codebase once was a C codebase.  Way back then, there was no standard boolean type.  So in the wisdom of the day a type was declared</p>
<pre class="code"><span style="color: #0000ff">typedef int</span> tBool;</pre>
<p>The major problem with tBool&#8217;s is that over time enums, #define or magic constants get assigned to them, or they can be compared to said enums, #defines or magic constants, as they are all int&#8217;s.</p>
<p>Which works, but years later <em>*somebody*</em> came along and replaced the tBool for bool, and we started getting issues.</p>
<p>Now as in a lot of large codebases there tends to be a large amount of ignored warnings, and not enough daylight hours to remove them all.</p>
<p>So given that, and that your using Visual Studio 2005, here are the ones you should find and remove.</p>
<pre class="code"><span style="color: #0000ff">#define</span> NON_BOOL_DEFINE 42
<span style="color: #0000ff">bool</span> boolValue;

boolValue = NON_BOOL_DEFINE;</pre>
<blockquote><p>Warning C4305: &#8216;=&#8217; : truncation from &#8216;int&#8217; to &#8216;bool&#8217;</p></blockquote>
<pre class="code"><span style="color: #0000ff">if</span>( boolValue == NON_BOOL_DEFINE )</pre>
<blockquote><p>Warning C4806: &#8216;==&#8217; : unsafe operation: no value of type &#8216;bool&#8217; promoted to type &#8216;int&#8217; can equal the given constant</p></blockquote>
<p>Another hint your boolean types are being used wrong is this warning</p>
<blockquote><p>Warning C4800: &#8216;const int&#8217; : forcing value to bool &#8216;true&#8217; or &#8216;false&#8217; (performance warning)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/09/01/evils-of-typedefs-and-legacy-code/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>0&#215;1F Today</title>
		<link>http://simeonpilgrim.com/blog/2008/09/01/0x1f-today/</link>
		<comments>http://simeonpilgrim.com/blog/2008/09/01/0x1f-today/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 12:01:37 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/09/01/0x1f-today/</guid>
		<description><![CDATA[Today is my 0&#215;1F birthday.
Pre-writting this, therefore I still don&#8217;t know what I getting.  I&#8217;m taking the day off from work, so it&#8217;s looking good already.
]]></description>
			<content:encoded><![CDATA[<p>Today is my 0&#215;1F birthday.</p>
<p>Pre-writting this, therefore I still don&#8217;t know what I getting.  I&#8217;m taking the day off from work, so it&#8217;s looking good already.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/09/01/0x1f-today/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>The Olympics</title>
		<link>http://simeonpilgrim.com/blog/2008/08/29/the-olympics/</link>
		<comments>http://simeonpilgrim.com/blog/2008/08/29/the-olympics/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 18:00:53 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/08/29/the-olympics/</guid>
		<description><![CDATA[Well 2008 Olympics, and I have enjoyed it quite a bit.  I really enjoyed the opening ceremony, and it was a great chance to use the PVR to record the whole thing.
It will be good to not feel compelled to have the TV on for a while.  When so much top level competition is happening [...]]]></description>
			<content:encoded><![CDATA[<p>Well 2008 Olympics, and I have enjoyed it quite a bit.  I really enjoyed the opening ceremony, and it was a great chance to use the PVR to record the whole thing.</p>
<p>It will be good to not feel compelled to have the TV on for a while.  When so much top level competition is happening I feel that I need to enjoy it all&#8230;</p>
<p>Things I will not miss, and think should be scraped are:</p>
<p>Walking race - really how is this a sport, it&#8217;s so contrived, &#8216;<em>lets run, but without running</em>&#8216;. I mean you walk when you don&#8217;t want to run, or you run when your late and have a need to get there faster.  So running races are about going as fast as you can, yet the walk (I don&#8217;t want to go fast) race, is about going as fast as you can without going fast, how can that be a race.</p>
<p>Womans beach volleyball - lets get a great team sport, and empty the court of most of the players so that points are easy to get.  Oh and now lets skimp the togs down so people watch.  Um, if the people are not watching it&#8217;s because it&#8217;s boring.  So tarting it up means only oglers will watch - is that what the Olympics is about, perving?</p>
<p>My other major gripe I have is with sports that could be defined as a &#8216;game&#8217;.  Football, Baseball, Softball and Tennis are not really higher, longer, faster are they.  Ok, there are some team games I do like, but would be willing to loose, Volleyball, Table Tenis.  I just don&#8217;t see &#8216;games&#8217; as personal excellence.</p>
<p>My last gripe, is that TV One had four TV streams available on-line, but our Internet plan charges for traffic because &#8216;<em>international traffic is expensive</em>&#8216; yet local traffic also gets billed at these rates, because ISPs can. Nice one ISPs.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/08/29/the-olympics/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>Slow sub-select maybe LAG or LEAD might help</title>
		<link>http://simeonpilgrim.com/blog/2008/08/28/slow-sub-select-maybe-lag-or-lead-might-help/</link>
		<comments>http://simeonpilgrim.com/blog/2008/08/28/slow-sub-select-maybe-lag-or-lead-might-help/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 05:14:23 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[SQL]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/08/28/slow-sub-select-maybe-lag-or-lead-might-help/</guid>
		<description><![CDATA[One of the queries in our application is used to edit event entries.  Event entries have a start time and an end time, but when they are processed from the data files, they can be entered with just a start time (ie when the event started), but in cases of problems (crashes) these entries will [...]]]></description>
			<content:encoded><![CDATA[<p>One of the queries in our application is used to edit event entries.  Event entries have a start time and an end time, but when they are processed from the data files, they can be entered with just a start time (ie when the event started), but in cases of problems (crashes) these entries will not have matching entries with end time.</p>
<p>So in our editor, we are wanting to know the upper limit of when the event could have ended, which is the next start time.</p>
<table border="0" cellpadding="2" cellspacing="0" width="400">
<tr>
<td valign="top">ROWID</td>
<td valign="top">TIME_START</td>
<td valign="top">TIME_END</td>
<td valign="top">OTHER_FIELDS</td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">2008-1-1</td>
<td valign="top">null</td>
<td valign="top">data</td>
</tr>
<tr>
<td valign="top">2</td>
<td valign="top">2008-1-2</td>
<td valign="top">2008-1-3</td>
<td valign="top">more data</td>
</tr>
</table>
<p>So for row 1 we want 2008-1-2 as the suggested end time.</p>
<p>Originally we had a query that looked like this:</p>
<pre class="code"><span style="color: #0000ff">SELECT </span><span style="background-color: yellow">other_fields</span>,
  TIME_START,
  TIME_END,
  NVL((<span style="color: #0000ff">SELECT MIN</span>(TIME_START)          <span style="color: #0000ff">
         FROM </span><span style="background-color: yellow">some_view</span>
         <span style="color: #0000ff">WHERE</span> MACHINE_ID = T1.MACHINE_ID
           <span style="color: #0000ff">AND </span>TIME_START &gt; T1.TIME_START),
       TIME_START + 1/24) &#8220;NEXT_TIME_START&#8221;
  <span style="color: #0000ff">FROM </span><span style="background-color: yellow">some_view</span> T1
  <span style="color: #0000ff">WHERE </span>MACHINE_ID = <span style="background-color: yellow">machine_id</span>
    <span style="color: #0000ff">AND </span>NVL(TIME_END,
            NVL((<span style="color: #0000ff">SELECT MIN</span>(TIME_START)
                   <span style="color: #0000ff">FROM </span><span style="background-color: yellow">some_view</span> WHERE MACHINE_ID = T1.MACHINE_ID
                   <span style="color: #0000ff">AND </span>TIME_START &gt; T1.TIME_START),
                TIME_START + 1/24)) &gt; <span style="background-color: yellow">start_time_range</span>
    <span style="color: #0000ff">AND </span>TIME_START &lt; <span style="background-color: yellow">end_time_range</span><span style="color: #0000ff">
  ORDER BY </span>TIME_START</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>So this is a little trickier than described above as it deals with the edge case of when there is no next entry.  In that case the current start time plus 1 hour is used. I coloured all the optional/variables yellow.</p>
<p>This performs fine with small data sets, but when we had over a million rows in that view, the selection of one days data (~2700 rows) took 551 seconds (&gt;9 minutes), and this was one of many large views, so the overall effect was a &gt;30 minute wait.</p>
<p>I rewrote the query with the use of LEAD, and the performance went to 4 seconds (with data retrieval) or 0.6 seconds for a count(*) operation.  Here&#8217;s that query now using LEAD.</p>
<pre class="code"><span style="color: #0000ff">SELECT </span>*
    <span style="color: #0000ff">FROM</span>(<span style="color: #0000ff">SELECT </span><span style="background-color: yellow">other_fields</span>,
           TIME_START,
           TIME_END,
           NVL( LEAD(TIME_START) <span style="color: #0000ff">OVER </span>(PARTITION <span style="color: #0000ff">BY </span>machine_id <span style="color: #0000ff">ORDER BY </span>time_start),
                TIME_START + 1/24) <span style="color: #0000ff">AS </span>&#8220;NEXT_TIME_START&#8221;,
           <span style="color: #0000ff">FROM </span><span style="background-color: yellow">some_view</span> T1
           <span style="color: #0000ff">WHERE </span>MACHINE_ID = <span style="background-color: yellow">machine_id</span> )
    <span style="color: #0000ff">WHERE </span>NEXT_TIME_START &gt; <span style="background-color: yellow">start_time_range</span>
      <span style="color: #0000ff">AND </span>TIME_START &lt; <span style="background-color: yellow">end_time_range</span>
    <span style="color: #0000ff">ORDER BY </span>TIME_START</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Now that I review the code I notice I also rearranged the code to not repeat the next_time_start calculation, so I am now not sure all the performance improvements can be attributed to LEAD, but I&#8217;ll take that ~138 times improvement either way.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/08/28/slow-sub-select-maybe-lag-or-lead-might-help/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
		<item>
		<title>DVD Unlimited - Thanks, but no thanks</title>
		<link>http://simeonpilgrim.com/blog/2008/08/27/dvd-unlimited-thanks-but-no-thanks/</link>
		<comments>http://simeonpilgrim.com/blog/2008/08/27/dvd-unlimited-thanks-but-no-thanks/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 08:36:17 +0000</pubDate>
		<dc:creator>Simeon Pilgrim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/2008/08/27/dvd-unlimited-thanks-but-no-thanks/</guid>
		<description><![CDATA[We have just ended a three month free trial with DVD Unlimited, and we will not continue with their service.  We got the trial as part of buying our TV, so it did not hurt us to try.
Things I liked:

DVDs arrived in the mail
You could return the DVDs in the mail
You could keep a movie [...]]]></description>
			<content:encoded><![CDATA[<p>We have just ended a three month free trial with DVD Unlimited, and we will not continue with their service.  We got the trial as part of buying our TV, so it did not hurt us to try.</p>
<p>Things I liked:</p>
<ul>
<li>DVDs arrived in the mail</li>
<li>You could return the DVDs in the mail</li>
<li>You could keep a movie for as long as you want, this would work well for games (not that we got any of the games from our request list)</li>
<li>We got to see lots of foreign movies, as there seems to be no queue on these</li>
</ul>
<p>Things that I did not like:</p>
<ul>
<li>I&#8217;m not sure we ever got any DVD in the top ten of our 20+ DVD selection list</li>
<li>I&#8217;m not sure any of the DVDs we received would be &#8216;new release&#8217; at the local video shop</li>
<li>Three of the first four DVDs didn&#8217;t play error free.  While they have a good swap program, it was a disappointing start, especially when the movies were not worth replacing, but only &#8216;<em>watch it because we have it</em>&#8216; quality</li>
<li>The movie suggestion system never had any results</li>
<li>When rating movies, the &#8220;0 1 2 3 4 5&#8243; text link based ratings where hard to read, and also hard to gauge meaning of the levels.  I really like how Amazon use bright stars, with text describing the meaning of that level eg &#8220;It&#8217;s ok&#8221;, &#8220;I like it&#8221;, &#8220;I love it&#8221;.  This allows you to know others will interpret those statements the same</li>
<li>They have lots of TV series, which is good if you want that, but I don&#8217;t and there&#8217;s no way to say &#8220;stop showing me all these freaking TV shows&#8221;, well there is a &#8220;not interested&#8221; button, but that seemed to have zero effect</li>
<li>When rating lists of DVDs I found it highly disturbing how the next item is auto focused/scrolled.  Once you learned what was happening, it sort of worked, but only if you had not scrolled the window, otherwise its auto jump feature moved incorrectly</li>
<li>It was very hard to find the details of our plan, and the options on how to handle our monthly limit where not in line with our trial limit. The limiting feature told us our plan was 10, but only gave the option of &#8220;4 movies a month(your limit&#8221; which it wasn&#8217;t</li>
<li>I didn&#8217;t like their terms and conditions, one of which includes that you are not allowed to link to them. Fine no Google juice for you!</li>
<li>Over the last week, after logging on to the site, the site shows this prompt:<br />
&#8220;<em>NAME_OF_MOVIE was awesome, don&#8217;t you think?<br />
Your Rating:   0 1 2 3 4 5<br />
Write Review</em>&#8221;<br />
No, I already told you it was crap (1), so stop asking.  But there it is again</li>
<li>There is a pressure to watch DVDs when they arrive so you get your $$ worth.  I guess this happens if you rent too many movies from a rental shop also&#8230;</li>
</ul>
<p>So over all, $28 x 3 months for 20 DVDs which I&#8217;m sure I could rent for $1 each, plus fast post each way equals</p>
<p>Cost: $84 &gt; Value: $60, so even if I&#8217;m generous and cost each DVD at $2 each + pp ($2), that brings the value to $80, which still below cost.</p>
]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2008/08/27/dvd-unlimited-thanks-but-no-thanks/feed/</wfw:commentRss>
	<slash:comments>0</slash:comments>
	</item>
	</channel>
</rss>
