<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>AlternateIdea - Home</title><link>http://alternateidea.com/</link><language>en-US</language><lastBuildDate>Sun, 30 Aug 2009 10:46:39 PDT</lastBuildDate><generator>Mephisto Noh-Varr http://mephistoblog.com</generator><description></description><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>TooGame - Game Videos and Release Dates on your iPhone</title><link>http://feedproxy.google.com/~r/encytemedia/~3/e7FtdMF4fJI/toogame-game-releases-on-your-iphone</link><category>posts</category><category>ds</category><category>game releases</category><category>gaming</category><category>ps3</category><category>xbox</category><category>xbox360</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Sun, 30 Aug 2009 10:46:39 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2009-08-30:5059</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p>I’m an avid console gamer.  That means I’m always wondering when the latest and greatest game will be dropped.  It was time for an iPhone application.</p>
<p>Logging on to gaming websites on a mobile browser can be painfully slow given most of them are full of ads, images, flash and videos.   I wanted something fast and simple that would allow me to see upcoming and recent releases across a variety of popular platforms so I developed <a href="http://itunes.com/app/toogame">TooGame</a>.</p>

<p><img src="http://www.alternateidea.com/assets/2009/8/30/toogame-list.png" alt="TooGame Xbox 360 releases" />
<img src="http://www.alternateidea.com/assets/2009/8/30/toogame-detail.png" alt="TooGame Game Details" />
<img src="http://www.alternateidea.com/assets/2009/8/30/toogame-video.png" alt="TooGame Video Playback" />
<img src="http://www.alternateidea.com/assets/2009/8/30/toogame-amazon.png" alt="TooGame Amazon Reserve" /></p>

<ul>
<li>You can view upcoming and recent releases within a 30 day span</li>
<li>View YouTube videos, details, box art, and genres</li>
<li>Reserve or purchase on Amazon using amazon’s mobile site</li>
</ul>

<p>Check it out on the app store! </p>

<p><a href="http://itunes.com/app/toogame"><img src="http://www.alternateidea.com/assets/2009/8/30/appstore.png" alt="TooGame on the app store" /></a></p>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=e7FtdMF4fJI:HKJRZOsw4_g:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=e7FtdMF4fJI:HKJRZOsw4_g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;I’m an avid console gamer.  That means I’m always wondering when the latest and greatest game will be dropped.  It was time for an iPhone application.&lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2009/8/30/toogame-game-releases-on-your-iphone</feedburner:origLink></item><item><title>Introducing HTTPRiot - Easily Consume REST Resources on the iPhone and OS X</title><link>http://feedproxy.google.com/~r/encytemedia/~3/bnJvyBNxjnE/introducing-httpriot-easily-consume-rest-resources-on-the-iphone-and-os-x</link><category>posts</category><category>cocoa</category><category>http</category><category>httpriot</category><category>iphone</category><category>sdk</category><category>xcode</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 13 Jul 2009 11:26:46 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2009-07-11:5019</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p>If you’ve ever tried to do networking with Foundation you know that wrestling with NSURLConnection and NSURLRequest can be painful.   Thankfully, we’ve seen a few third party tools step up to alleviate some of this pain.  I want to introduce you to a couple of those tools and show you what I’ve been working on as well.</p>
<p><img src="http://labratrevenge.com/images/httpriot.png" alt="HTTPRiot logo" /></p>

<p><strong>UPDATED: Fixed the permission issue on the download link</strong></p>

<h3>The current crop of tools</h3>

<p>There are some excellent HTTP libraries available for the iPhone and OS X.  So why do we need another one? Balance.  There are two particularly popular libraries that I’m going to talk about: ASIHTTPRequest and ObjectiveResource.  I’ll explain the benefits and tradeoffs of each and also explain where HTTPRiot fits in to this equation. </p>

<h4><a href="http://allseeing-i.com/ASIHTTPRequest/">ASIHTTPRequest</a></h4>

<p>ASIHTTPRequest is a highly flexible lower level tool (relative to HTTPRiot &amp; ObjectiveResource).  It can do a lot of things and do them well.  Besides the basic GET, POST, PUT and DELETE you can also upload files, post form encoded data, handle basic authentication and a host of other really nice things.  Not to mention it can handle synchronous and asynchronous requests–something HTTPRiot and ObjectiveResource can’t do.  This library is all about flexibility and this flexibility doesn’t take away from how easy it is to use.  This is code you should definitely have in your bag of tricks when you’re in need of an all purpose HTTP library.</p>

<p>The tradeoff for ASIHTTPRequest is that it can’t automatically convert XML and JSON.  There is also no mechanism for setting default configuration options which results in you having to configure things like delegates and selectors for every asynchronous request.  To be fair, ASIHTTPRequest was never meant to be used this way, thus I would take these tradeoffs with a grain of salt.</p>

<h4><a href="http://iphoneonrails.com/">ObjectiveResource</a></h4>

<p>If you’ve ever used ActiveResource with Rails you’ll probably be familiar with ObjectiveResource’s style.    ObjectiveResources is a high-level library that does a lot of behind the scenes work.  It’s built specifically to consume REST resources.  It can convert to and from JSON and XML (ASIHTTPRequest can’t) and it will automatically initialize models and do all sorts of other work for you.  This makes it a great fit for working in conjunction with a Rails app.</p>

<p>The tradeoff of ObjectiveResource is that it doesn’t handle XML and JSON that’s not produced by Rails well.  I’m not sure what kind of results you’d get if you fed it something like <a href="http://www.govtrack.us/data/us/111/bills/h1.xml">Govtrack’s bill data</a>.  ObjectiveResource is also a big library with a lot of moving parts.  In addition to the networking code, the library also includes <a href="http://github.com/yfactorial/objectivesupport/tree/master">ObjectiveSupport</a>, a nice library in itself that’s loosely based on ActiveSupport.  </p>

<p>One final thought about ObjectiveResource—there are <a href="http://github.com/yfactorial/objectiveresource/blob/627b66d286fd629d8dc5458c1178274c484a39d6/Classes/lib/NSObject+ObjectiveResource.h">a lot of methods added to NSObject</a>.  Apple doesn’t explicitly say not to do this, but they do <a href="http://devworld.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW30">warn you of the consequences</a>:</p>

<blockquote>
    <p>“You can define categories that add methods to the root class, NSObject. Such methods are available to all instances and class objects that are linked into your code. Informal protocols—the basis for the Cocoa delegation mechanism—are declared as categories on NSObject. This wide exposure, however, has its dangers as well as its uses. The behavior you add to every object through a category on NSObject could have consequences that you might not be able to anticipate, leading to crashes, data corruption, or worse.”</p>
</blockquote>

<p>With all that being said, ObjectiveResource is definitely worth checking out.  I know a few people who are using it and love it.</p>

<h3><a href="http://labratrevenge.com/httpriot">HTTPRiot</a></h3>

<p>Like ObjectiveResource, HTTPRiot was inspired by its Ruby counterpart: John Nunemaker’s <a href="http://github.com/jnunemaker/httparty/tree/master">httparty</a>.  Hence the name.  HTTPRiot serves as a balance between ASIHTTPRequest and ObjectiveResource.  You get a certain amount of flexibility and a higher level api.  Like ASIHTTPRequest, you can send GET, POST, PUT, and DELETE requests, also like ObjectiveResource the XML or JSON response will automatically be converted to an Objective-C type (NSArray or NSDictionary).  </p>

<p>The tradeoff with HTTPRiot is that it makes no attempt to convert the data further or automatically compose instances of other objects for you.  It gives you the data and lets you do what you want with it.  This means that you must be aware of the data you receive because it’s up to you to decide what to do with it after it’s been converted to a native type.  For instance, if two request originate from the same model they will both use the same delegate methods to handle the response.  It’s up to you to decide what’s what.</p>

<h3>Some examples</h3>

<p>Some quick examples to give you an idea of how you use HTTPRiot.</p>

<p><strong>GET Request:</strong> Reads JSON from the server.</p>

<pre><code class="objc">[Person getPath:@&quot;/people&quot; withOptions:nil object:nil];
</code></pre>

<p><strong>POST Request:</strong> POSTs the <code>body</code> set in options to the server.</p>

<pre><code class="objc">NSDictionary *options = [NSDictionary dictionaryWithObject:[foo JSONRepresentation] forKey:@&quot;body&quot;];
[HTTPRiotRestModel postPath:@&quot;/person&quot; withOptions:options error:nil];
</code></pre>

<p><strong>Setting default options:</strong> You can subclass <code>HRRestModel</code> and set default options like basic auth, headers, params, etc.  Every request you make from <code>MyModel</code> will use these default options.</p>

<pre><code class="objc">@implementation MyModel
+(void) initialize {
    [self setBasicAuthWithUsername:@&quot;justin&quot; password:@&quot;pass&quot;];
    [self setDefaultHeaders:[NSDictionary dictionaryWithObject:@&quot;Some Header Value&quot; forKey:@&quot;My-Header&quot;]];
}
@end
</code></pre>

<h4>Implementing the delegate methods</h4>

<p>You’ll need to implement a few delegate methods to deal with the responses.  I’ll explain why I settled on this approach in another post, but for now here is sample of what you’ll have:</p>

<pre><code class="objc">
- (void)restConnection:(NSURLConnection *)connection didReturnResource:(id)resource object:(id)object {
    //resource contains the NSDictionary or NSArray version of the XML or JSON you requested
    for(id item in resource) {
        //Do something with your data
    }
}

- (void)restConnection:(NSURLConnection *)connection didReceiveError:(NSError *)error response:(NSHTTPURLResponse *)response object:(id)object {
    //Recieved a bad status code 404, 500, etc.
}
</code></pre>

<h3>Summing up</h3>

<p>All three libraries have a job they are well suited for.  Hopefully I’ve given you an idea of what to expect with each one. On a final note regarding HTTPRiot, it is a young library so there will &lt;strike>likely&lt;/strike> be bugs along the way.  If you spot one, cease development and report it to the proper authorities. </p>

<ul>
<li><a href="http://labratrevenge.com/httpriot">HTTPRiot Website</a></li>
<li><a href="http://labratrevenge.com/httpriot/docs/">Online Documentation</a></li>
<li><a href="https://github.com/Caged/httpriot/tree/master">Source Code</a></li>
<li><a href="http://justin.tenderapp.com/discussions">Report Bugs &amp; Get Help</a></li>
</ul>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=bnJvyBNxjnE:cZu5Ud5FjNQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=bnJvyBNxjnE:cZu5Ud5FjNQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;If you’ve ever tried to do networking with Foundation you know that wrestling with NSURLConnection and NSURLRequest can be painful.   Thankfully, we’ve seen a few third party tools step up to alleviate some of this pain.  I want to introduce you to a couple of those tools and show you what I’ve been working on as well.&lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2009/7/11/introducing-httpriot-easily-consume-rest-resources-on-the-iphone-and-os-x</feedburner:origLink></item><item><title>YouTube Launches House &amp; Senate Hubs</title><link>http://feedproxy.google.com/~r/encytemedia/~3/Q6HNs8EOgL0/youtube-launches-house-senate-hubs</link><category>tumble</category><category>url</category><category>congress</category><category>house</category><category>senate</category><category>transparency</category><category>youtube</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 12 Jan 2009 09:23:47 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2009-01-12:5011</guid><description>&lt;p&gt;YouTube has &lt;a href="http://www.youtube.com/blog?entry=XzRSzC2JAQA"&gt;just announced&lt;/a&gt; &lt;a href="http://www.youtube.com/user/househub"&gt;HouseHub&lt;/a&gt; and &lt;a href="http://www.youtube.com/user/senatehub"&gt;Senate Hub&lt;/a&gt;.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=Q6HNs8EOgL0:fa2D_HlPS78:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=Q6HNs8EOgL0:fa2D_HlPS78:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2009/1/12/youtube-launches-house-senate-hubs</feedburner:origLink></item><item><title>Best Practices For Cocoa and CocoaTouch</title><link>http://feedproxy.google.com/~r/encytemedia/~3/D1FLTnBp_0A/best-practices-for-cocoa-and-cocoatouch</link><category>tumble</category><category>url</category><category>cocoa</category><category>cocoatouch</category><category>objective-c</category><category>xcode</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Fri, 10 Oct 2008 09:33:19 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-10-10:4140</guid><description>&lt;p&gt;&lt;a href="http://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa#175874"&gt;Best Practices For Cocoa and CocoaTouch&lt;/a&gt;&amp;mdash;Invaluable tips from Cocoa developers.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=D1FLTnBp_0A:Mu6ef8Xwpvc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=D1FLTnBp_0A:Mu6ef8Xwpvc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/10/10/best-practices-for-cocoa-and-cocoatouch</feedburner:origLink></item><item><title>Deploying Static Websites With Net::SCP</title><link>http://feedproxy.google.com/~r/encytemedia/~3/XqDMbJl3uBs/deploying-static-websites-with-net-scp</link><category>posts</category><category>capistrano</category><category>deploy</category><category>netscp</category><category>netssh</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Wed, 08 Oct 2008 10:55:53 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-10-08:4113</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p>I recently had a couple of projects that consisted of a few static HTML files and a couple images.  I could have used a blog or lightweight CMS, but those were overkill.  I could use <code>scp</code>, but remembering the <code>scp</code> command every time I made a small change proved to be a hassle.   I could have used <a href="http://www.capify.org">Capistrano</a>, but that too, felt overboard for my simple needs.  Lucky for me, in addition to Capistrano, <a href="http://weblog.jamisbuck.org/">Jamis Buck</a> wrote <a href="http://github.com/jamis/net-scp/tree/master">Net::SCP</a> which was the perfect tool for the job.</p>
<p>From the Net:SCP documentation:</p>

<blockquote>
    <p>”Net::SCP implements the SCP (Secure CoPy) client protocol, allowing Ruby programs to securely and programmatically transfer individual files or entire directory trees to and from remote servers. It provides support for multiple simultaneous SCP copies working in parallel over the same connection, as well as for synchronous, serial copies.”</p>
</blockquote>

<p>The only thing we’re interested in is uploading, so lets get down to the code which I’ve packaged as a rake task.</p>

<pre><code class="ruby">
REMOTE_DIR = &quot;/home/caged/public/website.com/public&quot;

desc 'Upload the site'
task :deploy do
  Net::SCP.start(&quot;hostname&quot;, &quot;caged&quot;, :port =&gt; 3000) do |scp|
    scp.upload! 'site/index.html',  REMOTE_DIR
    scp.upload! 'site/stylesheets', REMOTE_DIR, :recursive =&gt; true
    scp.upload! 'site/images',      REMOTE_DIR, :recursive =&gt; true
    scp.upload! 'site/article',     REMOTE_DIR, :recursive =&gt; true
  end
end
</code></pre>

<p>Now lets take a look at the code.  If you’re not using a public-key authentication, you’ll need to set <code>:password</code> in the <code>start</code> method.  The <code>upload!</code> method is a synchronous (blocking) upload.  If you’re uploading a lot of large files, you should consider using <code>upload</code> (no !) which will return immediately and continue processing your script while the upload is in progress.  Finally, instead of specifying the name of every file inside a directory, you can set <code>:recursive =&gt; true</code> and Net::SCP will create the directory on the remote server and upload the files contained in it.</p>

<p>That’s it, the no-frills way to deploy a small static website.</p>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=XqDMbJl3uBs:MmF14aq4IrY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=XqDMbJl3uBs:MmF14aq4IrY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;I recently had a couple of projects that consisted of a few static HTML files and a couple images.  I could have used a blog or lightweight CMS, but those were overkill.  I could use &lt;code&gt;scp&lt;/code&gt;, but remembering the &lt;code&gt;scp&lt;/code&gt; command every time I made a small change proved to be a hassle.   I could have used &lt;a href="http://www.capify.org"&gt;Capistrano&lt;/a&gt;, but that too, felt overboard for my simple needs.  Lucky for me, in addition to Capistrano, &lt;a href="http://weblog.jamisbuck.org/"&gt;Jamis Buck&lt;/a&gt; wrote &lt;a href="http://github.com/jamis/net-scp/tree/master"&gt;Net::SCP&lt;/a&gt; which was the perfect tool for the job.&lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/10/8/deploying-static-websites-with-net-scp</feedburner:origLink></item><item><title>Programming Politics</title><link>http://feedproxy.google.com/~r/encytemedia/~3/aI6WWl3LudY/programming-politics</link><category>posts</category><category>apis</category><category>cnn</category><category>election</category><category>govtrack</category><category>ogosh</category><category>politics</category><category>transparency</category><category>twitter</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 12 Jan 2009 09:24:59 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-10-07:4041</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p>Could you imagine, for a moment, what the political scene would be like without the social media giants Memeorandum, Reddit, Twitter, Digg, and Youtube?  What about the old media websites that <a href="http://en.wikipedia.org/wiki/Cnn.com#Online">started as an experiment</a>, required a registration and charged for access to  content?  Yes, it’s hard to imagine, but it was only four short years ago that none of these social websites existed and the old media websites were merely second class citizens to their broadcast counterparts.  Meanwhile, while we’ve been caught up in the infinite streams of information, there has been a small, but highly motivated community of hackers opening up government in a whole new way, providing APIs ripe for mashups and experimentation.</p>
<h3>The Post-Bush vs. Kerry Boom</h3>

<ul>
<li><a href="http://en.wikipedia.org/wiki/Reddit">Reddit</a> - <em>Founded 2005</em></li>
<li><a href="http://en.wikipedia.org/wiki/Techmeme">Memeorandum &amp; Techmeme</a> - Founded September 12, 2005</li>
<li><a href="http://en.wikipedia.org/wiki/Digg">Digg</a> - Launched December 5, 2004</li>
<li><a href="http://en.wikipedia.org/wiki/Youtube">Youtube</a> - Created February 2005</li>
<li><a href="http://en.wikipedia.org/wiki/Twitter">Twitter</a> - Officially launched October 2006</li>
</ul>

<p>It’s been a whirlwind of a political season.  In 2004, we might never have seen a <a href="http://www.reddit.com/search?q=bailout&amp;amp;x=0&amp;amp;y=0&amp;amp;sort=top">hoard of angry Redditors opposing the bailout</a>;  We’d have to do some real digging to find a video of <a href="http://www.youtube.com/watch?v=nH5ixmT83JE">Jeremiah Wright saying “God Damn America”</a>;  We’d be hard pressed to find <a href="http://www.youtube.com/watch?v=Fe751kMBwms">the speech that was the tipping point for “YES WE CAN”</a> and the <a href="http://www.youtube.com/watch?v=jjXyqcx-mYY">subsequent song and video inspired by that speech</a> that went on to win an Emmy.  We may have never been able to see <a href="http://www.c-spanarchives.org/library/index.php?main_page=product_video_info&amp;amp;products_id=195195-1">Sarah Palin in the Alaskan Gubernatorial Debate in 2006</a>.  You can almost conclude that anything that has happened in the last four years of politics can be found online in some form or fashion if your Google skills are up to par.</p>

<p>Unlike today’s modern, up-to-the-minute websites, in 2004, old media websites such as <a href="http://cnn.com">CNN</a>, <a href="http://msnbc.com">MSNBC</a>, <a href="http://www.foxnews.com/">Fox News</a> were not so flattering.</p>

<p><strong>CNN - Nov 5, 2004</strong>
<img src="http://alternateidea.com/assets/2008/10/2/20081002-eckxh9s5k7nfnedpin1w1ssy97.jpg" alt="CNN Nov 5, 2004" />
<br /><span>Kudos to those who spotted Obama winning the Illinois Senate</span></p>

<p><strong>MSNBC - Oct 27, 2004</strong>
<img src="http://alternateidea.com/assets/2008/10/2/msnbc-oct-27-2004-thumb.jpg" alt="MSNBC - Oct 27, 2004" /></p>

<p><strong>FOX News - Oct 14, 2004</strong>
<img src="http://alternateidea.com/assets/2008/10/2/foxnews-oct-14-2004-thumb.jpg" alt="FOX News - Oct 14, 2004" /></p>

<h3>Pioneering the way.  Open APIs and Open Source efforts</h3>

<p>I must admit, when I started to research Open Source efforts in government, I was skeptical.  I haven’t heard of much in passing, even given my rationale that tech news will always be accompanied by political news.  But, I pressed on and I was soon exposed to a small, but extremely active and knowledgeable community of Open Source hackers and organizations committed to bringing transparency to our government.</p>

<p><strong>Govtrack: The Granddaddy of them all</strong> </p>

<p>From my research, Govtrack is the data provider for an overwhelming majority of the websites I found.  Govtrack describes itself:</p>

<blockquote>
    <blockquote>
        <blockquote>
            <p>An independent, non-partisan, non-commercial website launched in September 2004, GovTrack.us was the first website whose primary goal was to provide comprehensive legislative tracking for everyday citizens and was the first congressional transparency website to embrace Web 2.0 and principles of open data. </p>
        </blockquote>
    </blockquote>
</blockquote>

<p>Earlier this year, Joshua Tauberer, the creator and primary maintainer of Govtrack decided to <a href="http://www.govtrack.us/source.xpd">open source the Govtrack application</a>.</p>

<p><strong>Sunlight Foundation: The Incubator</strong></p>

<p>Sunlight Foundation is the YCombinator of the open government movement (in spirit).  They give <a href="http://www.sunlightfoundation.com/grants/">small grants to help fund websites</a> whose mission is to open government and provide transparency in some fashion.</p>

<h3>A List of Resources</h3>

<h4>Open Data &amp; APIs</h4>

<ul>
<li><strong><a href="http://govtrack.us/data">Govtrack Congressional Data</a></strong> <span>[XML]</span> - Everything from votes to the full text of speeches.</li>
<li><strong><a href="http://services.sunlightlabs.com/api/">Sunlight Labs API</a></strong> <span>[XML, JSON]</span> - A meta API that links candidates to external services such as Eventful, Govtrack, VoteSmart, etc.   Also provides a short bio.</li>
<li><strong><a href="http://www.votesmart.org/services_api.php">Project Votesmart API</a></strong> <span>[XML, JSON]</span> - A wealth of information including votes grouped by issues, state, etc.</li>
<li><strong><a href="http://www.votesmart.org/services_api.php">Watchdog</a></strong> <span>[N3, XML, JSON]</span> - Recently started by Reddit’s Cofounder, <a href="http://www.aaronsw.com/">Aaron Swartz</a>, contains all types of information relative to a candidate such as Interest Group Alignment, Earmark data, and Money.  This project can also be <a href="http://www.aaronsw.com/">found on GitHub</a>.</li>
<li><strong><a href="http://metavid.org/wiki/Help:Advanced#APIs">Metavid US Legislative Footage API</a></strong> <span>[RSS, XML]</span> - A nice search API for public domain legislative videos.  Find when John McCain mention’s “my friends” and when Barack Obama mentions “change”.</li>
<li><strong><a href="http://www.opensecrets.org/action/apis.php">Open Secrects</a></strong> <span>[XML, JSON]</span> - In depth tracking of campaign contributions.</li>
<li><strong><a href="ftp://ftp.fec.gov/FEC/">FEC Data</a></strong> <span>[TXT, CSV, ZIP]</span> - FTP access to all the data collected by the Federal Election Commission.</li>
<li><strong><a href="http://www.followthemoney.org/services/index.phtml">Follow The Money</a></strong> <span>[XML]</span> - State-level campaign donor data.</li>
</ul>

<h4>Mailing Lists</h4>

<ul>
<li><strong><a href="http://groups.yahoo.com/group/govtrack/">Govtrack developers list</a></strong> - Get help with Govtrack resources.</li>
<li><strong><a href="http://groups.google.com/group/openhouseproject">Open House Project</a></strong> -A non-partisan group working to enhance public access to Congressional information.</li>
<li><strong><a href="http://groups.google.com/group/poliparse">Open House Project</a></strong> -Dedicated to those who are parsing political data</li>
<li><strong><a href="http://groups.google.com/group/watchdog-volunteers">Watchdog Volunteers</a></strong> - Volunteer collaboration for <a href="http://watchdog.net">watchdog.net</a></li>
</ul>

<h4>Other Resources</h4>

<ul>
<li><strong><a href="http://www.sourcewatch.org/index.php?title=Members_of_Congress_who_Twitter">Members of Congress who Twitter</a></strong> - Group effort to track congress on twitter fostered by the Sunlight Foundation</li>
<li><strong><a href="http://www.facebook.com/group.php?gid=45606565313">oGosh Facebook Group</a></strong> - Open Government Open Source Hacking</li>
<li><strong><a href="http://publicmarkup.org">Public Markup</a></strong> - Review and comment on proposed bills before they are even introduced—or while they are pending—in Congress.</li>
</ul>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=aI6WWl3LudY:p57TRUpoyTQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=aI6WWl3LudY:p57TRUpoyTQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;Could you imagine, for a moment, what the political scene would be like without the social media giants Memeorandum, Reddit, Twitter, Digg, and Youtube?  What about the old media websites that &lt;a href="http://en.wikipedia.org/wiki/Cnn.com#Online"&gt;started as an experiment&lt;/a&gt;, required a registration and charged for access to  content?  Yes, it’s hard to imagine, but it was only four short years ago that none of these social websites existed and the old media websites were merely second class citizens to their broadcast counterparts.  Meanwhile, while we’ve been caught up in the infinite streams of information, there has been a small, but highly motivated community of hackers opening up government in a whole new way, providing APIs ripe for mashups and experimentation.&lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/10/7/programming-politics</feedburner:origLink></item><item><title>Track House And Senate Votes On Twitter</title><link>http://feedproxy.google.com/~r/encytemedia/~3/V0LbRIG34H8/track-house-and-senate-votes-on-twitter</link><category>tumble</category><category>url</category><category>government</category><category>legislate</category><category>politics</category><category>transparency</category><category>twitter</category><category>vote</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 12 Jan 2009 09:25:22 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-09-26:4040</guid><description>&lt;p&gt;&lt;a href="http://twitter.com/legislate"&gt;Track House And Senate Votes On Twitter&lt;/a&gt;.  I’ve put together a small script that parses vote data collected by &lt;a href="http://govtrack.us"&gt;Govtrack.us&lt;/a&gt; and posts to twitter.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=V0LbRIG34H8:ZP1CuQOeHuU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=V0LbRIG34H8:ZP1CuQOeHuU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/9/26/track-house-and-senate-votes-on-twitter</feedburner:origLink></item><item><title>Protip: Color grep searches in terminal</title><link>http://feedproxy.google.com/~r/encytemedia/~3/Uu-Qd3e33T0/protip-color-grep-searches-in-terminal</link><category>code</category><category>tumble</category><category>ansi</category><category>color</category><category>grep</category><category>osx</category><category>protip</category><category>snippet</category><category>terminal</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 28 Jul 2008 13:54:24 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-07-28:3974</guid><description>&lt;pre&gt;&lt;code class="javascript"&gt;
alias grep='GREP_COLOR=&amp;quot;1;37;41&amp;quot; LANG=C grep --color=auto'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Stash this away in your Z Shell (~/.zshenv) or Bash environment (~/.bashrc) and set your preferred ANSI code.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=Uu-Qd3e33T0:Of0loC8sF7U:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=Uu-Qd3e33T0:Of0loC8sF7U:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/7/28/protip-color-grep-searches-in-terminal</feedburner:origLink></item><item><title>MacRuby: The Path Forward</title><link>http://feedproxy.google.com/~r/encytemedia/~3/1Ap6Yz80iCk/macruby-the-path-forward</link><category>posts</category><category>macruby</category><category>objective-c</category><category>rubycocoa</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Fri, 20 Jun 2008 10:45:48 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-06-17:3917</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p><a href="http://ruby.macosforge.org/trac/wiki/MacRuby">MacRuby</a> is quietly making progress. Destined to replace <a href="http://rubycocoa.sourceforge.net/HomePage">RubyCocoa</a> as the de facto standard for writing Cocoa applications in Ruby; it’s shaping up to become more than just a fun experiment, it’ll soon be a viable choice.  </p>
<h3>Burn Baby Burn</h3>

<p>Unlike RubyCocoa, MacRuby is based on Ruby 1.9, powered by the YARV bytecode interpreter, resulting in significantly faster execution times.  From the <a href="http://ruby.macosforge.org/trac/wiki/WhyMacRuby">“Why MacRuby”</a> page:</p>

<blockquote>
    <p>In MacRuby, all Ruby classes and objects are actually Objective-C classes and objects. There is no need to create costly proxies, convert objects and cache instances. A Ruby object can be toll-free casted at the C level as an Objective-C object, and the Ruby VM can also handle incoming Objective-C objects without conversion.</p>
    
    <p>Also, the primitive Ruby classes, such as String, Array and Hash in MacRuby have been re-implemented on top of their Cocoa equivalents, respectively NSString, NSArray and NSDictionary. As an example, all strings in MacRuby are Cocoa strings, and can be passed to underlying C or Objective-C APIs that expect Cocoa strings without requiring a conversion. And it is possible to call any method of the String interface on any Cocoa string too.</p>
</blockquote>

<p>That’s exciting news. MacRuby applications significantly outperform RubyCocoa applications and aim to enable the creation of full-fledged Mac OS X applications which do not sacrifice performance in order to enjoy the benefits of using Ruby. </p>

<h3>Syntax</h3>

<p>Considering String, Array, and Hash/Dictionary require no conversion, we get both the Ruby methods and the Objective-C methods without needing to cast back and forth.</p>

<pre><code class="ruby">
#MacRuby
components = &quot;foo/bar/baz&quot;.pathComponents

# RubyCocoa
components = &quot;foo/bar/baz&quot;.to_ns.pathComponents
# or...
components = OSX::NSString.stringWithString(&quot;foo/bar/baz&quot;).pathComponents

#Objective-C
NSArray *components = [@&quot;foo/bar/baz&quot; pathComponents];
# or...
NSArray *components = [[NSString stringWithString:@&quot;foo/bar/baz&quot;] pathComponents];
</code></pre>

<p>And the biggest change is probably keyed arguments.  I’ve grown to like keyed arguments in Objective-C because of their descriptive nature.  Normally you can look at a method definition and determine what’s what.</p>

<pre><code class="ruby">
def fetch_url(url, timeout)
  ...
end
</code></pre>

<p>However, unless you look up the method definition in the source or documentation, you don’t fully understand what the second argument encompasses during invocation. </p>

<pre><code class="ruby">obj.fetch_url(&quot;http://foo.com&quot;, 60)</code></pre>

<p>This is where keyed arguments come into play.  Take a look at how this method would be composed in Objective-C.</p>

<pre><code class="ruby">
- (void)fetchURL:(NSURL *)url timeout:(float)theTimeout {
  ...
}

[obj fetchURL:[NSURL URLWithString:@&quot;http://foo.com&quot;] timeout:60.0];
</code></pre>

<p>And finally, we could write this method in MacRuby with the new keyed arguments syntax.</p>

<pre><code class="ruby">
def fetch_url(url, timeout:timeout)
...
end

obj.fetch_url(&quot;http://foo.com&quot;, timeout:60.0)
</code></pre>

<p>We get the added benefit of clarity at the cost of verbosity.  And finally, there is an additional nuance: CamelCase or under_score.  I think I’ve settled with camelCase for now, because it’s not possible (practical ATM) to use underscored Objective-C methods, however, I’ve been told it’s being considered.</p>

<h3>The Big Macs: macruby, macrake, macirb, macgem</h3>

<p>Once you’ve set yourself up with MacRuby, you should know your programs are given a prefix of <strong>mac</strong> unless you specify a different prefix when compiling by hand.  This means we’ll need to use <code>macruby</code> to invoke our Ruby scripts written for MacRuby.  </p>

<p>In a completely convoluted example, lets grab the name of every application running on our machine; print it’s application name, and replace “Applications” in it’s path with “FOO”.</p>

<pre><code class="ruby">
framework 'AppKit'

NSWorkspace.sharedWorkspace.launchedApplications.each do |app|
  appname  = app[&quot;NSApplicationName&quot;]
  fullpath = app[&quot;NSApplicationPath&quot;]
  puts appname
  puts fullpath.stringByReplacingOccurrencesOfString(&quot;Applications&quot;, withString:&quot;FOO&quot;)
end
</code></pre>

<p>Save this file and run with <code>macruby thisfile.rb</code>.  You should see a list of applications running and their paths, with FOO replacing Applications.  Got it?  Schweet!</p>

<p><code>framework</code> is a new method of Kernel that allows you to import any framework, including your custom frameworks.  In this example, we’re including the AppKit framework and iterating over the launched applications.</p>

<h4>Gems: A ruby in the rough</h4>

<p>At the time of writing this article, <strong>it’s not possible to use rubygems or macruby gems</strong> in the traditional <code>require</code> and run method.  However, you can vendor your gems and include them directly which should work perfectly fine.  This is a bug that will be addressed very soon.</p>

<h3>Get Involved</h3>

<p>MacRuby is an official effort by Apple to make Ruby a first class citizen in Cocoa.  It’s still very early in development and you’re definitely encouraged to start playing with it, writing about it, and <a href="http://ruby.macosforge.org/trac/wiki/MacRuby">getting involved in the project</a>.  And one final note, you can join the very helpful #ruby-osx channel on freenode.net if you’re looking for assistance.</p>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=1Ap6Yz80iCk:w4xbipS04gU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=1Ap6Yz80iCk:w4xbipS04gU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;&lt;a href="http://ruby.macosforge.org/trac/wiki/MacRuby"&gt;MacRuby&lt;/a&gt; is quietly making progress. Destined to replace &lt;a href="http://rubycocoa.sourceforge.net/HomePage"&gt;RubyCocoa&lt;/a&gt; as the de facto standard for writing Cocoa applications in Ruby; it’s shaping up to become more than just a fun experiment, it’ll soon be a viable choice.  &lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/6/17/macruby-the-path-forward</feedburner:origLink></item><item><title>ActiveRecord Ported To Objective-C</title><link>http://feedproxy.google.com/~r/encytemedia/~3/lBwYuIh0zeo/activerecord-ported-to-objective-c</link><category>tumble</category><category>url</category><category>activerecord</category><category>cocoa</category><category>objective-c</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Sun, 08 Jun 2008 13:59:19 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-06-08:3910</guid><description>&lt;p&gt;&lt;a href="http://code.google.com/p/activerecord/"&gt;ActiveRecord Ported To Objective-C&lt;/a&gt; brought to us by &lt;a href="http://ninjakitten.us"&gt;Ninja Kitten&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=lBwYuIh0zeo:bMpTmGJXFi0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=lBwYuIh0zeo:bMpTmGJXFi0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/6/8/activerecord-ported-to-objective-c</feedburner:origLink></item><item><title>Browser-based Developer Tools Come Full Circle</title><link>http://feedproxy.google.com/~r/encytemedia/~3/BbH0jFsZYpU/browser-based-developer-tools-come-full-circle</link><category>longquote</category><category>tumble</category><category>devtools</category><category>dragonfly</category><category>drosera</category><category>firebug</category><category>firefox</category><category>ie8</category><category>opera</category><category>safari</category><category>webinspector</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Tue, 06 May 2008 15:26:19 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-05-06:3755</guid><description>&lt;p&gt;With the release of Opera’s &lt;a href="http://www.opera.com/products/dragonfly/"&gt;DragonFly&lt;/a&gt;, IE 8’s &lt;a href="http://msdn.microsoft.com/en-us/library/cc304131.aspx"&gt;Developer tools&lt;/a&gt;, Safari’s/Webkit’s &lt;a href="http://webkit.org/blog/108/yet-another-one-more-thing-a-new-web-inspector/"&gt;Web Inspector&lt;/a&gt; and &lt;a href="http://trac.webkit.org/wiki/Drosera"&gt;Drosera&lt;/a&gt;; and the Grand Daddy of them all, &lt;a href="http://www.getfirebug.com/"&gt;Firebug&lt;/a&gt; – we’ve now come full circle.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=BbH0jFsZYpU:rZuaS1lzZZo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=BbH0jFsZYpU:rZuaS1lzZZo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/5/6/browser-based-developer-tools-come-full-circle</feedburner:origLink></item><item><title>Automating Rick Rolls with launchd</title><link>http://feedproxy.google.com/~r/encytemedia/~3/LlM9CpQ8Ar4/automating-rick-rolls-with-launchd</link><category>posts</category><category>launchctl</category><category>launchd</category><category>rickroll</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Thu, 01 May 2008 15:09:18 PDT</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-05-01:3747</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[
            <p>Lets face it:  Your coworkers can be a real pain in the ass sometimes.  What better way 
to remind them of this than automated Rick rolls?  They’re likely to never know what hit them.</p>
<h3>What is launchd?</h3>

<p>According to the <a href="http://developer.apple.com/macosx/launchd.html">launchd guide on Apple’s website</a>:</p>

<blockquote>
    <p>The launchd daemon takes over many tasks from cron, xinetd, mach_init, and init, 
    which are UNIX programs that traditionally have handled system initialization, called 
    systems scripts, run startup items, and generally prepared the system for the user</p>
</blockquote>

<p>launchd stores tasks in <code>plist</code> format.  You can find your agents in ~/Library/LaunchAgents.
Here is a typical launcd file that will open iTunes every 60 seconds:</p>

<pre><code class="html">
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.alternateidea.article.test&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/bin/open&lt;/string&gt;
        &lt;string&gt;-b&lt;/string&gt;
    &lt;string&gt;com.apple.iTunes&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;60&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
</code></pre>

<p>Obviously this would be seriously annoying, but for the purpose of this demonstration, 
save this file as “com.alternateidea.article.test” in your ~/Library/LaunchAgents folder.</p>

<p>This script won’t run automatically, so we need to load it up first using the <code>launchctl</code> 
program:</p>

<pre><code>launchctl load ~/Library/LaunchAgents/com.alternateidea.article.test.plist</code></pre>

<p>Our agent is loaded up now.  After 60 seconds, you should see iTunes.app open.  Pretty nice, eh?</p>

<p>Ok, so we don’t want to keep running this agent.  Lets unload it:</p>

<pre><code>launchctl unload ~/Library/LaunchAgents/com.alternateidea.article.test.plist</code></pre>

<h3>Never gonna give you up.  Never gonna automate your Mac.</h3>

<p>So, here’s the trick:  Wait until your coworker goes to lunch or you know they’ll be out of the 
office for 10 minutes or so.  Then, let the mischief begin. </p>

<p>The first thing we need to do is create our agent:</p>

<pre><code class="html">
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.youtube.rickroll&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/bin/open&lt;/string&gt;
        &lt;string&gt;-b&lt;/string&gt;
            &lt;string&gt;com.apple.Safari&lt;/string&gt;
            &lt;string&gt;http://www.youtube.com/watch?v=eBGIQ7ZuuiU&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;1800&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
</code></pre>

<p>Everything should be pretty obvious in this plist.  The <code>StartInterval</code> is in seconds.  I 
want to be an asshole every 30 minutes (1800) seconds.  If you want to be a bigger asshole 
(or <a href="http://www.youtube.com/watch?v=9xhsKB0rvXg">Son of a Bitch</a>) you could set this to run in 
shorter intervals. </p>

<p>Now, we need to save this and load it up on your coworkers computer.  Save this 
to <code>~/Library/USERNAME/LaunchAgents/com.youtube.rickroll</code>.  And load it up:</p>

<pre><code>
  launchctl load ~/Library/LaunchAgents/com.youtube.rickroll.plist
</code></pre>

<p>If you want to test and make sure everything is in working order, you can run:</p>

<pre><code>launchctl start com.youtube.rickroll</code></pre>

<p><strong>Question:</strong> Did you just Rick Roll yourself?</p>

<p>Now, if your test ran successfully slip back to your desk and wait in anticipation for that 
awesome intro.</p>

<p><strong>Disclaimer:  If you destroy your coworkers computer or end up scrapping in the street, I’m not responsible.</strong></p>
          <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/encytemedia?a=LlM9CpQ8Ar4:_BbZ2E8ToK8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/encytemedia?a=LlM9CpQ8Ar4:_BbZ2E8ToK8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded><description>&lt;p&gt;Lets face it:  Your coworkers can be a real pain in the ass sometimes.  What better way 
to remind them of this than automated Rick rolls?  They’re likely to never know what hit them.&lt;/p&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/5/1/automating-rick-rolls-with-launchd</feedburner:origLink></item><item><title>DoubleClick and Define using Apple Dictionary</title><link>http://feedproxy.google.com/~r/encytemedia/~3/liRsKz0QQbE/javascript-define-with-apple-dictionary</link><category>code</category><category>tumble</category><category>dictionary</category><category>javascript</category><category>osx</category><category>snippet</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Fri, 08 Feb 2008 14:40:45 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-02-08:3612</guid><description>&lt;pre&gt;&lt;code class="javascript"&gt;
var selection;
if(window.getSelection)
  selection = window.getSelection();
else if(document.selection)
  selection = document.selection.createRange();

document.observe(&amp;quot;dblclick&amp;quot;, function() {
  if(navigator.userAgent.include(&amp;quot;Macintosh&amp;quot;)) {
      location.href = &amp;quot;dict://&amp;quot; + selection;
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A quick (and probably dirty) Prototype-based hack allowing Mac users to get the definition of any word by double clicking it.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=liRsKz0QQbE:wNVwy9HzlvI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=liRsKz0QQbE:wNVwy9HzlvI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/2/8/javascript-define-with-apple-dictionary</feedburner:origLink></item><item><title>A strftime for Prototype</title><link>http://feedproxy.google.com/~r/encytemedia/~3/1TLVm_yk4Ok/a-strftime-for-prototype</link><category>code</category><category>tumble</category><category>javascript</category><category>prototype</category><category>snippet</category><category>strftime</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Tue, 26 Feb 2008 16:44:02 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-02-08:3645</guid><description>&lt;pre&gt;&lt;code class="javascript"&gt;
Object.extend(Date.prototype, {
  strftime: function(format) {
    var day = this.getUTCDay(), month = this.getUTCMonth();
    var hours = this.getUTCHours(), minutes = this.getUTCMinutes();
    function pad(num) { return num.toPaddedString(2); };

    return format.gsub(/\%([aAbBcdDHiImMpSwyY])/, function(part) {
      switch(part[1]) {
        case 'a': return $w(&amp;quot;Sun Mon Tue Wed Thu Fri Sat&amp;quot;)[day]; break;
        case 'A': return $w(&amp;quot;Sunday Monday Tuesday Wednesday Thursday Friday Saturday&amp;quot;)[day]; break;
        case 'b': return $w(&amp;quot;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec&amp;quot;)[month]; break;
        case 'B': return $w(&amp;quot;January February March April May June July August September October November December&amp;quot;)[month]; break;
        case 'c': return this.toString(); break;
        case 'd': return this.getUTCDate(); break;
        case 'D': return pad(this.getUTCDate()); break;
        case 'H': return pad(hours); break;
        case 'i': return (hours === 12 || hours === 0) ? 12 : (hours + 12) % 12; break;
        case 'I': return pad((hours === 12 || hours === 0) ? 12 : (hours + 12) % 12); break;
        case 'm': return pad(month + 1); break;
        case 'M': return pad(minutes); break;
        case 'p': return hours &amp;gt; 11 ? 'PM' : 'AM'; break;
        case 'S': return pad(this.getUTCSeconds()); break;
        case 'w': return day; break;
        case 'y': return pad(this.getUTCFullYear() % 100); break;
        case 'Y': return this.getUTCFullYear().toString(); break;
      }
    }.bind(this));
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Bugs fixed.  Thanks &lt;a href="http://andrewdupont.net/"&gt;Andrew&lt;/a&gt; and &lt;a href="http://www.designkitchen.com/"&gt;Stephen&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, some of my old and new code has been posted on &lt;a href="http://github.com/Caged/javascript-bits/"&gt;GitHub&lt;/a&gt;.  You might find something useful.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=1TLVm_yk4Ok:L_vDnqm3BeA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=1TLVm_yk4Ok:L_vDnqm3BeA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/2/8/a-strftime-for-prototype</feedburner:origLink></item><item><title>Processing in Action</title><link>http://feedproxy.google.com/~r/encytemedia/~3/9nXMpocil9I/processing-in-action</link><category>tumble</category><category>video</category><category>fire</category><category>flight404</category><category>music</category><category>organic</category><category>processing</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Justin</dc:creator><pubDate>Mon, 04 Feb 2008 14:17:16 PST</pubDate><guid isPermaLink="false">tag:alternateidea.com,2008-02-04:3640</guid><description>&lt;p&gt;&amp;lt;object height="225" width="400"&gt; &amp;lt;param /&gt;   &amp;lt;param /&gt;   &amp;lt;param /&gt;  &amp;lt;param /&gt;&amp;lt;/object&gt;&lt;/p&gt;

&lt;p&gt;A beautiful, organic animation by &lt;a href="http://www.flight404.com/blog/"&gt;Flight404&lt;/a&gt; created using &lt;a href="http://processing.org"&gt;Processing&lt;/a&gt;.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=9nXMpocil9I:Q3uQZmfGqvY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/encytemedia?a=9nXMpocil9I:Q3uQZmfGqvY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/encytemedia?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description><feedburner:origLink>http://alternateidea.com/blog/articles/2008/2/4/processing-in-action</feedburner:origLink></item></channel></rss>
