<?xml version="1.0" encoding="UTF-8"?>
<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:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>some things</title>
	<atom:link href="http://fliptoad.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://fliptoad.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Wed, 13 Apr 2011 20:06:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='fliptoad.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>some things</title>
		<link>http://fliptoad.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://fliptoad.wordpress.com/osd.xml" title="some things" />
	<atom:link rel='hub' href='http://fliptoad.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Web Scraper Pt. 02: Reading MSDN into Something Simpler</title>
		<link>http://fliptoad.wordpress.com/2009/03/07/web-scraper-pt-02-reading-msdn-into-something-simpler/</link>
		<comments>http://fliptoad.wordpress.com/2009/03/07/web-scraper-pt-02-reading-msdn-into-something-simpler/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 22:56:34 +0000</pubDate>
		<dc:creator>fliptoad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fliptoad.wordpress.com/?p=44</guid>
		<description><![CDATA[<p>Reading things from <a class="reference external" href="http://msdn.microsoft.com/en-us/library/default.aspx">msdn.microsoft.com</a> has always been difficult since they put one line of content surrounded by all kinds of other junk. I wanted a simpler representation that I could print or read without clicking on too many links.</p>
<p>So I made this webscraper which grabs content from an msdn node (eg a webpage like <a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms679320%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms679320(VS.85).aspx</a>), simplifies it, stores it locally, then tries to visit all its sub pages to do the same. The result will be an html file named after the title of the node passed to it, and a directory containing sub pages each of which may have directories containing sub pages of their own. There will also be one file named <tt class="docutils literal"><span class="pre">$title.long.html</span></tt> which will contain the text of all nodes visited.</p>
<p>This webscraper makes use of <a class="reference external" href="http://search.cpan.org/%7Epetdance/WWW-Mechanize-1.54/lib/WWW/Mechanize.pm">WWW::Mechanize</a>, <a class="reference external" href="http://search.cpan.org/%7Epetek/HTML-Tree-3.23/lib/HTML/TreeBuilder.pm">HTML::TreeBuilder</a>, <a class="reference external" href="http://search.cpan.org/%7Emirod/HTML-TreeBuilder-XPath-0.09/lib/HTML/TreeBuilder/XPath.pm">HTML::TreeBuilder::XPath</a>, and <a class="reference external" href="http://search.cpan.org/%7Eash/WWW-Mechanize-TreeBuilder-1.10000/lib/WWW/Mechanize/TreeBuilder.pm">WWW::Mechanize::TreeBuilder</a> so I have the ability to use an XPath on anything I want. Despite this, it has still been a bit difficult to figure out in all cases which links in the content of a page are the sub pages, so for the sake of time here is the imperfect script. It works for only some msdn nodes, others you will get a tree of links that are a bit off, and others this script will go in an infinite loop (if the max_depth variable is set high enough):</p>

<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=44&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Reading things from <a class="reference external" href="http://msdn.microsoft.com/en-us/library/default.aspx">msdn.microsoft.com</a> has always been difficult since they put one line of content surrounded by all kinds of other junk. I wanted a simpler representation that I could print or read without clicking on too many links.</p>
<p>So I made this webscraper which grabs content from an msdn node (eg a webpage like <a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms679320(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms679320(VS.85).aspx</a>), simplifies it, stores it locally, then tries to visit all its sub pages to do the same. The result will be an html file named after the title of the node passed to it, and a directory containing sub pages each of which may have directories containing sub pages of their own. There will also be one file named <tt class="docutils literal"><span class="pre">$title.long.html</span></tt> which will contain the text of all nodes visited.</p>
<p>This webscraper makes use of <a class="reference external" href="http://search.cpan.org/~petdance/WWW-Mechanize-1.54/lib/WWW/Mechanize.pm">WWW::Mechanize</a>, <a class="reference external" href="http://search.cpan.org/~petek/HTML-Tree-3.23/lib/HTML/TreeBuilder.pm">HTML::TreeBuilder</a>, <a class="reference external" href="http://search.cpan.org/~mirod/HTML-TreeBuilder-XPath-0.09/lib/HTML/TreeBuilder/XPath.pm">HTML::TreeBuilder::XPath</a>, and <a class="reference external" href="http://search.cpan.org/~ash/WWW-Mechanize-TreeBuilder-1.10000/lib/WWW/Mechanize/TreeBuilder.pm">WWW::Mechanize::TreeBuilder</a> so I have the ability to use an XPath on anything I want. Despite this, it has still been a bit difficult to figure out in all cases which links in the content of a page are the sub pages, so for the sake of time here is the imperfect script. It works for only some msdn nodes, others you will get a tree of links that are a bit off, and others this script will go in an infinite loop (if the max_depth variable is set high enough):</p>
<pre class="literal-block">
use strict;
use warnings;
use WWW::Mechanize;
use HTML::TreeBuilder;
use List::Util 'first';
use WWW::Mechanize::TreeBuilder;

#my $base = 'http://msdn.microsoft.com/en-us/library/ms679320(VS.85).aspx';
#my $base = 'http://msdn.microsoft.com/en-us/library/ms682584(VS.85).aspx';
#my $base = 'http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx';
my $base = shift &#64;ARGV;
$base =~ /msdn\.microsoft\.com/i or die &quot;url doesnt look like its from msdn&quot;;
my $max_depth = shift &#64;ARGV || 7;

my $mech = WWW::Mechanize-&gt;new;
WWW::Mechanize::TreeBuilder-&gt;meta-&gt;apply
    ($mech, tree_class =&gt; 'HTML::TreeBuilder::XPath');
$mech-&gt;agent_alias('Windows Mozilla');

my $lh;  #long html page containing everything
my $lhb; #body node of the lh
my $lf;  #long file name, filled out with the title of the first page
my %int_link; #holds internal links for the long document
my $toc = HTML::Element-&gt;new('ul');

rmsdn($base, undef, 0);

$lhb-&gt;unshift_content(['h3', 'Table of Contents'], $toc);
open my $fh, &quot;&gt; $lf&quot; or die &quot;cant open $lf: $!&quot;;
print $fh $lh-&gt;as_HTML(undef, '    ', {});
close $fh;

# recurse msdn
sub rmsdn {
    my ($url, $slug, $depth) = &#64;_;

    #sleep 1;
    $mech-&gt;get($url);
    my $title = $mech-&gt;findvalue('//div[&#64;class = &quot;title&quot;]');
    $slug ||= slug($title);
    my $d = $slug;
    print &quot;got $title &lt;$url&gt;\n&quot;;

    if ($depth == 0) {
        $lh = HTML::Element-&gt;new_from_lol(
            ['html',
                ['head', ['title', $title] ],
                ['body']
            ]
        );
        $lhb = $lh-&gt;findnodes('//body')-&gt;[0];
        $lf = slug($title) . '.long.html';
    }

    # real content
    my $rc = $mech-&gt;findnodes('//div[&#64;class =~ /clsServerSDKContent/i]')-&gt;[0];
    $rc ||= $mech-&gt;findnodes('//div[&#64;class =~ /ContentArea/i]')-&gt;[0];

    # prune everything after the first &lt;br&gt;

    my $n = first {ref &amp;&amp; (
        $_-&gt;tag eq 'br' ||
        $_-&gt;as_text =~ /^Send comments about this topic/i ||
        $_-&gt;as_text eq 'See Also'
    )}
    $rc-&gt;content_list;
    if (defined $n) { $_-&gt;delete for ($n, $n-&gt;right) }

    # find sub pages
    my &#64;sub_pages;
    my %h;
    for my $a
    ($rc-&gt;findnodes(
        './/*[name() =~ /^li|td|dt$/i][count(*) = 1]//' .
        'a[&#64;id =~ /ctl00_rs1_mainContentContainer_ct/]')) {
        next if defined $a-&gt;left;
        my $msdn = $a-&gt;attr('href');
        next if $h{$msdn}++;
        my $text = $a-&gt;as_text;
        my $aslug = slug($text);
        push &#64;sub_pages, { msdn =&gt; $msdn, slug =&gt; $aslug };
        $a-&gt;replace_with(
            ['a', {href =&gt; &quot;$d/$aslug.html&quot;, class =&gt; 'loc'}, $text])-&gt;delete;
        $int_link{&quot;$d/$aslug.html&quot;} = $int_link{$msdn} ||= $aslug;
    }

    # make simpler full html page
    my $h = HTML::Element-&gt;new_from_lol(
        ['html',
            ['head', ['title', $title] ],
            ['body', ['h1', $title], $rc-&gt;content_list ]
        ]
    );

    # write this page to a file
    my $file = &quot;$slug.html&quot;;
    open my $fh, &quot;&gt; $file&quot; or die &quot;cant open $file: $!&quot;;
    print $fh $h-&gt;as_HTML(undef, '    ', {});
    close $fh;

    # convert local links to internal
    for my $a ($rc-&gt;findnodes('.//a[&#64;class = &quot;loc&quot;]')) {
        $a-&gt;attr(href =&gt; '#' . $int_link{$a-&gt;attr('href')});
    }

    # demote headings to regular large text
    for my $h ($rc-&gt;findnodes('.//*[name() =~ /^h\d$/i]')) {
        $h-&gt;replace_with(
            ['p', ['font', {size =&gt; '+1'}, ['strong', $h-&gt;content_list]]]
        )-&gt;delete;
    }

    # add this rc to the long page
    $int_link{$url} ||= slug($title);
    $lhb-&gt;push_content(
        ['a', {name =&gt; $int_link{$url}}],
        ['h' . ($depth+1), $title],
        $rc-&gt;content_list);

    # add this page to the table of contents
    $toc-&gt;push_content(
        ['li', ['a', {href =&gt; '#' . $int_link{$url}}, $title]]);

    return if !&#64;sub_pages || $depth &gt;= $max_depth;

    $toc-&gt;content-&gt;[-1]-&gt;push_content(['ul']);
    $toc = $toc-&gt;content-&gt;[-1]-&gt;content-&gt;[-1];

    # recurse to all sub pages of this one
    mkdir $d;
    chdir $d or die &quot;cant chdir $d: $!&quot;;
    rmsdn($_-&gt;{msdn}, $_-&gt;{slug}, $depth+1) for &#64;sub_pages;
    chdir '..';

    $toc = $toc-&gt;parent-&gt;parent;
}

sub slug {
    $_ = shift;
    s/[,\n\\\/]//g;
    s/[\s\-]/_/g;
    $_;
}
</pre>
<div class="section" id="notes">
<h1>Notes</h1>
<ol class="arabic simple">
<li>In writing this I ran into a bug which exists in HTML::Element&#8217;s<br />
replace_with subroutine. It wasnt correctly updating the lineage of the<br />
replacement. Thankfully someone else also found it, and provided a patch<br />
on rt.cpan.org at<br />
<a class="reference external" href="http://rt.cpan.org/Public/Bug/Display.html?id=28204">http://rt.cpan.org/Public/Bug/Display.html?id=28204</a>.</li>
<li>microsoft has downloads of the msdn at<br />
<a class="reference external" href="http://www.microsoft.com/express/download/msdn/Default.aspx">http://www.microsoft.com/express/download/msdn/Default.aspx</a>. I wish I<br />
knew of this before.</li>
</ol>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fliptoad.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fliptoad.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fliptoad.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=44&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fliptoad.wordpress.com/2009/03/07/web-scraper-pt-02-reading-msdn-into-something-simpler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">fliptoad</media:title>
		</media:content>
	</item>
		<item>
		<title>Web Scraper Pt. 01: Youtube Subscription Videos</title>
		<link>http://fliptoad.wordpress.com/2009/02/18/web-scraper-pt-01-youtube-subscription-videos/</link>
		<comments>http://fliptoad.wordpress.com/2009/02/18/web-scraper-pt-01-youtube-subscription-videos/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 03:28:58 +0000</pubDate>
		<dc:creator>fliptoad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fliptoad.wordpress.com/?p=42</guid>
		<description><![CDATA[<p>It used to be that there was no way to view the newest videos released by my youtube subscriptions on my iphone. Now theve made it a bit easier that you can go to the page and click the video to pop up the youtube player program. But its still a bit complicated to navigate and you'll have to load up a few extra pages before you get to the actual video.</p>
<p>So I created a simple webscraper using perl's <a class="reference external" href="http://search.cpan.org/~petdance/WWW-Mechanize-1.54/lib/WWW/Mechanize.pm">WWW::Mechanize</a> library with parsing done by <a class="reference external" href="http://search.cpan.org/~pajas/XML-LibXML-1.69/LibXML.pod">XML::LibXML</a>'s XPath subroutines that sends an email with <a class="reference external" href="http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/Sendmail.pm">Mail::Sendmail</a> that lists links to all the newest videos.</p>
<p>I have my computer run this everyday so i can consistently get the newest vids on my phone. The user and pass listed in this script are temporary accounts at youtube i made just to test this thing works. fill in these values with account info/email info of your own.</p>
<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=42&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It used to be that there was no way to view the newest videos released by my youtube subscriptions on my iphone. Now theve made it a bit easier that you can go to the page and click the video to pop up the youtube player program. But its still a bit complicated to navigate and you&#8217;ll have to load up a few extra pages before you get to the actual video.</p>
<p>So I created a simple webscraper using perl&#8217;s <a class="reference external" href="http://search.cpan.org/~petdance/WWW-Mechanize-1.54/lib/WWW/Mechanize.pm">WWW::Mechanize</a> library with parsing done by <a class="reference external" href="http://search.cpan.org/~pajas/XML-LibXML-1.69/LibXML.pod">XML::LibXML</a>&#8216;s XPath subroutines that sends an email with <a class="reference external" href="http://search.cpan.org/~mivkovic/Mail-Sendmail-0.79/Sendmail.pm">Mail::Sendmail</a> that lists links to all the newest videos.</p>
<p>I have my computer run this everyday so i can consistently get the newest vids on my phone. The user and pass listed in this script are temporary accounts at youtube i made just to test this thing works. fill in these values with account info/email info of your own.</p>
<p>here it is:</p>
<pre class="literal-block">
#!perl
# sends an email to yourself containing all your youtube subscription videos

use warnings;
use strict;

use WWW::Mechanize;
use CGI::Pretty;
use URI::QueryParam;
use XML::LibXML;
use Mail::Sendmail;

my $user = &quot;rixscis&quot;;
my $pass = &quot;g0ft3ka.&quot;;
my $to = 'foo&#64;bar.com';
my $smtp = 'mail.optonline.net';

my $q = new CGI;

my $msg = $q-&gt;h1(&quot;Youtube Subscription Videos for $user&quot;)
        . $q-&gt;p(scalar localtime);

my $mech = WWW::Mechanize-&gt;new();
$mech-&gt;agent_alias('Windows Mozilla');

$mech-&gt;get('http://www.youtube.com/my_subscriptions');
$mech-&gt;submit_form(
    form_name =&gt; 'loginForm',
    fields =&gt; {
        username =&gt; $user,
        password =&gt; $pass
    }
);

my &#64;vid;
while (1) {
    my $c = $mech-&gt;content;

    my $x = XML::LibXML-&gt;new-&gt;parse_html_string($c,
        {suppress_errors =&gt; 1, no_network =&gt; 1, recover =&gt; 1});

    for my $n ($x-&gt;findnodes('//div[&#64;class = &quot;video&quot;]')) {
        my ($id) = $n-&gt;find('.//a[1]/&#64;onclick') =~ /'(\S+?)'/;
        my $text = $n-&gt;find('.//a[&#64;class = &quot;title&quot;]');
        my $date = $n-&gt;find(
            './/div[&#64;class = &quot;video-stat&quot;]/span[&#64;class = &quot;stat-date-added&quot;]');
        my $dur = $n-&gt;find(
            './/div[&#64;class = &quot;video-stat&quot;]/span[&#64;class = &quot;stat-duration&quot;]');
        my $chan = $n-&gt;find(
            './/div[&#64;class = &quot;video-stat&quot;]/span[&#64;class = &quot;stat-username&quot;]/a');
        push &#64;vid, {
            id   =&gt; $id,
            text =&gt; $text,
            date =&gt; $date,
            dur  =&gt; $dur,
            chan =&gt; $chan
        }
    }

=for comment
    while ($c =~ m{
        &lt;a \s+ href=&quot;\#&quot; \s+ onClick=&quot;\w+\(\['(\S+?)'\]\);
        .*? class=&quot;title&quot; .*? &gt; (.*?) &lt;/a&gt;
    }gxs) {
        push &#64;vid, {id =&gt; $1, text =&gt; $2};
    }

=cut

    last unless &#64;{[ $mech-&gt;find_all_links(text_regex =&gt; qr/next/i) ]};

    my $uri = URI-&gt;new('http://www.youtube.com/my_subscriptions');
    $uri-&gt;query_form(
        pi =&gt; ($mech-&gt;uri-&gt;query_param('pi') || 0) + 1,
        ps =&gt; 20,
        sf =&gt; 'added',
        sa =&gt; 0,
        sq =&gt; '',
        dm =&gt; 2
    );
    sleep 1;
    $mech-&gt;get($uri);
}

$msg .= $q-&gt;ol(
    $q-&gt;li( [
        map {
            $q-&gt;p(
                $q-&gt;a(
                    {href =&gt; &quot;http://www.youtube.com/watch?v=$_-&gt;{id}&quot;},
                    $_-&gt;{text}
                ),
                ' [', $_-&gt;{dur}, '] - ', $_-&gt;{chan}
            )
        } &#64;vid
    ] )
);

print &quot;$msg\n&quot;;

sendmail(
    smtp =&gt; $smtp,
    'content-type' =&gt; 'text/html',

    to   =&gt; $to,
    from =&gt; 'subscriptions&#64;youtube.com',
    subject =&gt; &quot;youtube subscriptions for $user&quot;,
    message =&gt; $msg
) or die $Mail::Sendmail::error;

print &quot;OK. Log says:\n&quot;, $Mail::Sendmail::log;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fliptoad.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fliptoad.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fliptoad.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=42&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fliptoad.wordpress.com/2009/02/18/web-scraper-pt-01-youtube-subscription-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">fliptoad</media:title>
		</media:content>
	</item>
		<item>
		<title>Animating Console Apps</title>
		<link>http://fliptoad.wordpress.com/2009/02/08/animating-console-apps/</link>
		<comments>http://fliptoad.wordpress.com/2009/02/08/animating-console-apps/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 22:48:23 +0000</pubDate>
		<dc:creator>fliptoad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fliptoad.wordpress.com/?p=38</guid>
		<description><![CDATA[I wanted to see what my options were for creating a console program with simple animations. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=38&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#options-for-animating-console-apps" id="id1">1&nbsp;&nbsp;&nbsp;Options for Animating Console Apps</a>
<ul class="auto-toc">
<li><a class="reference internal" href="#perl-win32-console" id="id2">1.1&nbsp;&nbsp;&nbsp;Perl Win32::Console</a></li>
<li><a class="reference internal" href="#windows-h-api-method" id="id3">1.2&nbsp;&nbsp;&nbsp;windows.h api method</a></li>
<li><a class="reference internal" href="#ansi-escape-code-method" id="id4">1.3&nbsp;&nbsp;&nbsp;ANSI escape code method</a></li>
</ul>
</li>
<li><a class="reference internal" href="#references" id="id5">2&nbsp;&nbsp;&nbsp;References</a></li>
</ul>
</div>
<div class="section" id="options-for-animating-console-apps">
<h1><a class="toc-backref" href="#id1">1&nbsp;&nbsp;&nbsp;Options for Animating Console Apps</a></h1>
<p>I wanted to see what my options were for creating a console program with simple animations. The output of all these programs will look like this:</p>
<p><img src="http://fliptoad.files.wordpress.com/2009/02/quicksort.gif?w=600" alt="quicksort" title="quicksort"   class="alignnone size-full wp-image-39" /></p>
<p>To do small one-line animations, I could always use <tt class="docutils literal"><span class="pre">\r</span></tt> at the end of any string to reposition the cursor back at the beginning of the line, but to make animations that are more than one line, I had to use something that gave me more control of the cursor.</p>
<p>I also wanted to avoid the other extreme of using a curses (or a curses-like) library since that would be too complicated, and i dont want to go into a full screen, or change the way keyboard input happens.</p>
<p>So I wrote the following small programs to animate a quicksort using windows api, perls Win32::Console module (which just wraps the windows api), and ansi escape codes (to be used on a system that supports them). I provide them here so that the internet may have yet another simple example of their use.</p>
<div class="section" id="perl-win32-console">
<h2><a class="toc-backref" href="#id2">1.1&nbsp;&nbsp;&nbsp;Perl Win32::Console</a></h2>
<p>There are two things that all these programs need to do:</p>
<ol class="arabic">
<li>
<p class="first">the first is that they need to position the cursor back by the number<br />
of items in <tt class="docutils literal"><span class="pre">x</span></tt> each time the array needs to be displayed.</p>
<p>This is done with Win32::Console by the following lines:</p>
<pre class="literal-block">
use Win32::Console;
...
my $con = Win32::Console-&gt;new(STD_OUTPUT_HANDLE);
...
$con-&gt;Cursor(0, ($con-&gt;Cursor)[1]-&#64;x-1) if $t++;
</pre>
</li>
<li>
<p class="first">the second is to color the two items in the array that are being<br />
swapped.</p>
<p>this is done by the following lines:</p>
<pre class="literal-block">
my $highlight = $FG_GREEN | $BG_BLACK;
...
my $normal_color = $con-&gt;Attr;
...
$con-&gt;Attr($highlight) if grep {$_ == $i} &#64;active_elements;
printf &quot;%2d: %*s [%2d]\n&quot;, $i, -$max, '#' x $x[$i], $x[$i];
$con-&gt;Attr($normal_color) if grep {$_ == $i} &#64;active_elements;
</pre>
</li>
</ol>
<p>And here is the full listing:</p>
<pre class="literal-block">
use Time::HiRes 'usleep';
use Win32::Console;

my $highlight = $FG_GREEN | $BG_BLACK;
my $max       = 55;
my $len       = 33;
my $speed     = 30000;

my &#64;x = map {int rand $max} (1) x $len;

my $con = Win32::Console-&gt;new(STD_OUTPUT_HANDLE);
my &#64;active_elements;
my $normal_color = $con-&gt;Attr;
my $count = 0;

quicksort(0, $#x);

sub disp {
    $con-&gt;Cursor(0, ($con-&gt;Cursor)[1]-&#64;x-1) if $t++;
    for my $i (0 .. $#x) {
        $con-&gt;Attr($highlight) if grep {$_ == $i} &#64;active_elements;
        printf &quot;%2d: %*s [%2d]\n&quot;, $i, -$max, '#' x $x[$i], $x[$i];
        $con-&gt;Attr($normal_color) if grep {$_ == $i} &#64;active_elements;
    }
    print &quot;It took $count iterations to sort $len elements\n&quot;;
    usleep $speed;
}

sub swap {
    my ($a, $b) = &#64;_;
    $count++;
    return if $a == $b;
    &#64;active_elements = ($a, $b); disp;
    &#64;x[$b, $a] = &#64;x[$a, $b];
    disp;
}

sub randbetw {
    my ($a, $b) = &#64;_;
    return int(rand $b - $a + 1) + $a;
}

sub quicksort {
    my ($l, $u) = &#64;_;
    return if $l &gt;= $u;
    swap($l, randbetw($l, $u));
    my $m = $l;
    for my $i ($l + 1 .. $u) {
        swap(++$m, $i) if $x[$i] &lt; $x[$l];
    }
    swap($l, $m);
    quicksort($l, $m - 1);
    quicksort($m + 1, $u);
}
</pre>
</div>
<div class="section" id="windows-h-api-method">
<h2><a class="toc-backref" href="#id3">1.2&nbsp;&nbsp;&nbsp;windows.h api method</a></h2>
<ol class="arabic">
<li>
<p class="first">The positioning of the cusor was done as follows:</p>
<pre class="literal-block">
#include &lt;windows.h&gt;
...
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
...
CONSOLE_SCREEN_BUFFER_INFO con_info;
COORD pos;
...
if (t++) {
    GetConsoleScreenBufferInfo(con, &amp;con_info);
    pos = con_info.dwCursorPosition;
    pos.Y -= LEN + 1;
    SetConsoleCursorPosition(con, pos);
}
</pre>
</li>
<li>
<p class="first">rows were colored with:</p>
<pre class="literal-block">
#define HIGHLIGHT FOREGROUND_RED | FOREGROUND_INTENSITY
...
GetConsoleScreenBufferInfo(con, &amp;con_info);
normal_color = con_info.wAttributes;
...
if (i == ae[0] || i == ae[1])
    SetConsoleTextAttribute(con, HIGHLIGHT);
... printf ...
if (i == ae[0] || i == ae[1])
    SetConsoleTextAttribute(con, normal_color);
</pre>
</li>
</ol>
<p>here is the full program:</p>
<pre class="literal-block">
#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;

#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

#define HIGHLIGHT FOREGROUND_RED | FOREGROUND_INTENSITY
#define MAX 55
#define LEN 33
#define SPEED 5

int x[LEN];

HANDLE con;
int ae[2] = {-1, -1};
WORD normal_color;
int count = 0;

void init() {
    int i;
    CONSOLE_SCREEN_BUFFER_INFO con_info;

    con = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(con, &amp;con_info);
    normal_color = con_info.wAttributes;

    srand(time(0));
    for (i=0; i &lt; LEN; i++) x[i] = rand() % MAX;
}

void disp() {
    static int t = 0;
    CONSOLE_SCREEN_BUFFER_INFO con_info;
    COORD pos;
    int i, j;

    if (t++) {
        GetConsoleScreenBufferInfo(con, &amp;con_info);
        pos = con_info.dwCursorPosition;
        pos.Y -= LEN + 1;
        SetConsoleCursorPosition(con, pos);
    }

    for (i=0; i &lt; LEN; i++) {
         if (i == ae[0] || i == ae[1])
            SetConsoleTextAttribute(con, HIGHLIGHT);

        printf(&quot;%2d: &quot;, i);
        for (j=0; j &lt; MAX; j++)printf(j &lt; x[i] ? &quot;#&quot; : &quot; &quot;);
        printf(&quot; [%2d]\n&quot;, x[i]);

        if (i == ae[0] || i == ae[1])
            SetConsoleTextAttribute(con, normal_color);
    }
    printf(&quot;It took %d iterations to sort %d elements\n&quot;, count, LEN);
    Sleep(SPEED);
}

void swap(int a, int b) {
    int t;
    count++;
    if (a == b) return;
    ae[0] = a;
    ae[1] = b;
    disp();
    t = x[a];
    x[a] = x[b];
    x[b] = t;
    disp();
}

int randbetw(int a, int b) {
    return rand() % (b - a + 1) + a;
}

/* from jon bentley in chapter 3 of beautiful code  */
void quicksort(int l, int u) {
    int i, m;
    if (l &gt;= u) return;
    swap(l, randbetw(l, u));
    m = l;
    for (i = l+1; i &lt;= u; i++)
        if (x[i] &lt; x[l])
            swap(++m, i);
    swap(l, m);
    quicksort(l, m-1);
    quicksort(m+1, u);
}

int main() {
    init();
    quicksort(0, LEN-1);
    return 0;
}
</pre>
</div>
<div class="section" id="ansi-escape-code-method">
<h2><a class="toc-backref" href="#id4">1.3&nbsp;&nbsp;&nbsp;ANSI escape code method</a></h2>
<ol class="arabic">
<li>
<p class="first">cursor was positioned with:</p>
<pre class="literal-block">
if (t++) printf(&quot;\e[%dA&quot;, LEN+1);
</pre>
</li>
<li>
<p class="first">lines were colored with:</p>
<pre class="literal-block">
#define HIGHLIGHT &quot;\e[1;36m&quot;
if (i == ae[0] || i == ae[1]) printf(HIGHLIGHT);
... printf ...
if (i == ae[0] || i == ae[1]) printf(&quot;\e[0m&quot;);
</pre>
</li>
</ol>
<p>here is the full program:</p>
<pre class="literal-block">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

#include &lt;time.h&gt;
#include &lt;unistd.h&gt;

#define HIGHLIGHT &quot;\e[1;36m&quot;
#define MAX 55
#define LEN 33
#define SPEED 30000

int x[LEN];

int ae[2] = {-1, -1};
int count = 0;

void init() {
  int i;
  srand(time(0));
  for (i=0; i &lt; LEN; i++) x[i] = rand() % MAX;
}

void disp() {
  static int t = 0;
  int i, j;
  if (t++) printf(&quot;\e[%dA&quot;, LEN+1);
  for (i=0; i &lt; LEN; i++) {
    if (i == ae[0] || i == ae[1]) printf(HIGHLIGHT);
    printf(&quot;%2d: &quot;, i);
    for (j=0; j &lt; MAX; j++) printf(j &lt; x[i] ? &quot;#&quot; : &quot; &quot;);
    printf(&quot; [%2d]\n&quot;, x[i]);
    if (i == ae[0] || i == ae[1]) printf(&quot;\e[0m&quot;);
  }
  printf(&quot;It took %d iterations to sort %d elements\n&quot;, count, LEN);
  usleep(SPEED);
}

void swap(int a, int b) {
  int t;
  count++;
  if (a == b) return;
  ae[0] = a;
  ae[1] = b;
  disp();
  t = x[a];
  x[a] = x[b];
  x[b] = t;
  disp();
}

int randbetw(int a, int b) {
  return rand() % (b - a + 1) + a;
}

/* from jon bentley in chapter 3 of beautiful code  */
void quicksort(int l, int u) {
  int i, m;
  if (l &gt;= u) return;
  swap(l, randbetw(l, u));
  m = l;
  for (i = l+1; i &lt;= u; i++)
    if (x[i] &lt; x[l])
      swap(++m, i);
  swap(l, m);
  quicksort(l, m-1);
  quicksort(m+1, u);
}

int main() {
  init();
  quicksort(0, LEN-1);
  return 0;
}
</pre>
</div>
</div>
<div class="section" id="references">
<h1><a class="toc-backref" href="#id5">2&nbsp;&nbsp;&nbsp;References</a></h1>
<ol class="arabic simple">
<li><a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx</a></li>
<li><a class="reference external" href="http://search.cpan.org/~jdb/Win32-Console-0.09/Console.pm">http://search.cpan.org/~jdb/Win32-Console-0.09/Console.pm</a></li>
<li><a class="reference external" href="http://en.wikipedia.org/wiki/ANSI_escape_code">http://en.wikipedia.org/wiki/ANSI_escape_code</a></li>
<li><a class="reference external" href="http://video.google.com/videoplay?docid=-1031789501179533828">http://video.google.com/videoplay?docid=-1031789501179533828</a></li>
</ol>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fliptoad.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fliptoad.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fliptoad.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=38&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fliptoad.wordpress.com/2009/02/08/animating-console-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">fliptoad</media:title>
		</media:content>

		<media:content url="http://fliptoad.files.wordpress.com/2009/02/quicksort.gif" medium="image">
			<media:title type="html">quicksort</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing DLLs</title>
		<link>http://fliptoad.wordpress.com/2009/01/03/writing-dlls/</link>
		<comments>http://fliptoad.wordpress.com/2009/01/03/writing-dlls/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 02:54:15 +0000</pubDate>
		<dc:creator>fliptoad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fliptoad.wordpress.com/?p=26</guid>
		<description><![CDATA[<p>I had some trouble with finding a good, quick (yet comprehensive) way to create and use dlls that didnt reference the Visual Studio IDE (I dont want to use it) and weren't full of useless general knowledge information (a dynamic link library, or dll for short, is a...). So I went ahead and jotted down some notes after i got some things working.</p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=26&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="document">
<div class="section" id="writing-a-simple-dll">
<p>I had some trouble with finding a good, quick (yet comprehensive) way to create and use dlls that didnt reference the Visual Studio IDE (I dont want to use it) and weren&#8217;t full of useless general knowledge information (a dynamic link library, or dll for short, is a&#8230;). So I went ahead and jotted down some notes after i got some things working.</p>
<div class="section" id="create-the-dll">
<h2>Create the Dll</h2>
<p>You start with some c code for your library:</p>
<pre class="literal-block">
$ cat libgreet.c

#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;

BOOL DllMain(HINSTANCE hi, DWORD dw, LPVOID lp) {
        printf(&quot;oh hai ^-^\n&quot;);
        return 1;
}

void greet() {
        printf(&quot;Hello, World!\n&quot;);
}
</pre>
<p>The DllMain function is optional but will be called automatically called when the dll is loaded and freed.</p>
<p>You may compile this to a relocatable object file:</p>
<pre class="literal-block">
$ cl -c libgreet.c
</pre>
<p>This generates an .obj file which you can use along with a .def file:</p>
<pre class="literal-block">
$ cat libgreet.def

LIBRARY libgreet
EXPORTS
        greet
</pre>
<p>Alternatively, you can forgo a .def file and use <tt class="docutils literal"><span class="pre">__declspec(dllexport)</span></tt> in front of every function you want exported.</p>
<p>You can now link the dll with:</p>
<pre class="literal-block">
$ link -out:libgreet.dll -dll -debug -machine:x86  \
  libgreet.obj -def:libgreet.def
</pre>
<p>which should create the following files <tt class="docutils literal"><span class="pre">libgreet.dll</span></tt>, <tt class="docutils literal"><span class="pre">libgreet.lib</span></tt> (the static library to interface to the dll), <tt class="docutils literal"><span class="pre">libgreet.pdb</span></tt> (allows you to step through your library&#8217;s code in a debugger), <tt class="docutils literal"><span class="pre">libgreet.exp</span></tt> (?), and <tt class="docutils literal"><span class="pre">libgreet.ppp</span></tt> (???).</p>
</div>
<div class="section" id="using-your-dll">
<h2>Using Your Dll</h2>
<p>There are two ways to use the dll. The first is to use the static .lib file to interface to the dll. Heres an example:</p>
<pre class="literal-block">
$ cat use1.c

int main() {
        greet();
        return 0;
}
</pre>
<p>You may use the <tt class="docutils literal"><span class="pre">greet()</span></tt> function as though it will just be there (because it will). You may also declare the <tt class="docutils literal"><span class="pre">greet()</span></tt> function here or in a .h file that can be used by both this function and the original library code. Those declarations may have <tt class="docutils literal"><span class="pre">extern</span></tt> in front of them or not. Compile it with:</p>
<pre class="literal-block">
$ cl use1.c libgreet.lib
</pre>
<p>Which will produce a final .exe file.</p>
<p>The other way to load a dll at run time. This does not require any files other than the dll so long as you know the interface. You can get an idea of the exports available in a dll by doing:</p>
<pre class="literal-block">
$ dumpbin /exports libgreet.dll
</pre>
<p>Then you may write code like:</p>
<pre class="literal-block">
$cat use2.c

#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;

int main() {
        HMODULE loaded_dll;
        FARPROC greet;

        printf(&quot;Hello, Erf!\n&quot;);

        loaded_dll = LoadLibrary(&quot;test.dll&quot;);
        if (loaded_dll == NULL) {
                printf(&quot;unable to load test.dll library\n&quot;);
                return 1;
        }

        greet = GetProcAddress(loaded_dll, &quot;greet&quot;);
        if (greet == NULL) {
                printf(&quot;unable to obtain greet() from test.dll\n&quot;);
                return 1;
        }

        (*greet)();

        FreeLibrary(loaded_dll);

        return 0;
}
</pre>
<p>and compile like:</p>
<pre class="literal-block">
$ cl use2.c
</pre>
</div>
</div>
<div class="section" id="references">
<h1>References</h1>
<ol class="arabic simple">
<li><a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms682589(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms682589(VS.85).aspx</a></li>
</ol>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fliptoad.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fliptoad.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fliptoad.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=26&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fliptoad.wordpress.com/2009/01/03/writing-dlls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">fliptoad</media:title>
		</media:content>
	</item>
		<item>
		<title>Star Trek Timeline</title>
		<link>http://fliptoad.wordpress.com/2008/12/22/star-trek-timeline/</link>
		<comments>http://fliptoad.wordpress.com/2008/12/22/star-trek-timeline/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 23:51:19 +0000</pubDate>
		<dc:creator>fliptoad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fliptoad.wordpress.com/?p=20</guid>
		<description><![CDATA[<p>I searched google but couldnt find a timeline of the star trek universe that just listed the approximate dates of each series and movie. So I made one based on this data which i sprunged from the internet:</p><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=20&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://fliptoad.files.wordpress.com/2008/12/star_trek_timeline.png"><img src="http://fliptoad.files.wordpress.com/2008/12/star_trek_timeline.png?w=550&#038;h=292" alt="star_trek_timeline" title="star_trek_timeline" width="550" height="292" class="alignnone size-medium wp-image-21" /></a></p>
<p>I searched google but couldnt find a timeline of the star trek universe that just listed the approximate dates of each series and movie. So I made one based on this data which i sprunged from the internet:</p>
<table border="1" class="docutils">
<caption>tv series</caption>
<col width="28%" />
<col width="72%" />
<tbody valign="top">
<tr>
<td>TOS</td>
<td>2266 &#8211; 2269</td>
</tr>
<tr>
<td>TAS</td>
<td>2269 &#8211; 2270</td>
</tr>
<tr>
<td>TNG</td>
<td>2364 &#8211; 2370</td>
</tr>
<tr>
<td>DS9</td>
<td>2369 &#8211; 2375</td>
</tr>
<tr>
<td>VGR</td>
<td>2371 &#8211; 2378</td>
</tr>
<tr>
<td>ENT</td>
<td>2151 &#8211; 2155</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils">
<caption>movies</caption>
<col width="83%" />
<col width="17%" />
<tbody valign="top">
<tr>
<td>I The Motion Picture:</td>
<td>2271</td>
</tr>
<tr>
<td>II The Wrath of Khan:</td>
<td>2285</td>
</tr>
<tr>
<td>III The Search for Spock:</td>
<td>2285</td>
</tr>
<tr>
<td>IV The Voyage Home:</td>
<td>2286</td>
</tr>
<tr>
<td>V The Final Frontier:</td>
<td>2287</td>
</tr>
<tr>
<td>VI The Undiscovered Country:</td>
<td>2293</td>
</tr>
<tr>
<td>VII Generations:</td>
<td>2371</td>
</tr>
<tr>
<td>VIII First Contact:</td>
<td>2372</td>
</tr>
<tr>
<td>IX Insurrection:</td>
<td>2375</td>
</tr>
<tr>
<td>X Nemesis:</td>
<td>2379</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fliptoad.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fliptoad.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fliptoad.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=fliptoad.wordpress.com&amp;blog=5866274&amp;post=20&amp;subd=fliptoad&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://fliptoad.wordpress.com/2008/12/22/star-trek-timeline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">fliptoad</media:title>
		</media:content>

		<media:content url="http://fliptoad.files.wordpress.com/2008/12/star_trek_timeline.png?w=550" medium="image">
			<media:title type="html">star_trek_timeline</media:title>
		</media:content>
	</item>
	</channel>
</rss>
