<?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/"
	>

<channel>
	<title>jakanapes.com</title>
	<atom:link href="http://jakanapes.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://jakanapes.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 09 Apr 2012 13:42:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Updating a zipfile comments with ruby zip</title>
		<link>http://jakanapes.com/blog/2012/04/09/updating-a-zipfile-comments-with-ruby-zip/</link>
		<comments>http://jakanapes.com/blog/2012/04/09/updating-a-zipfile-comments-with-ruby-zip/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 13:42:16 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=133</guid>
		<description><![CDATA[Recently had a situation where I wanted to update the comment on a zip archive. Easy enough if you&#8217;re on php using ZipArchive. $zip = new ZipArchive; $res = $zip->open('Archive.zip'); if ($res === TRUE) { $cbi = array(); $cbi['appID'] = "CBIPHP1.0"; $cbi['lastModified'] = date('Y-m-d H:i:s O'); $issue = array(); $issue['series'] = 'Watchmen'; $issue['title'] = "At [...]]]></description>
			<content:encoded><![CDATA[<p>Recently had a situation where I wanted to update the comment on a zip archive.</p>
<p>Easy enough if you&#8217;re on php using ZipArchive.</p>
<pre class="php">
  $zip = new ZipArchive;
  $res = $zip->open('Archive.zip');
  if ($res === TRUE) {
      $cbi = array();
      $cbi['appID'] = "CBIPHP1.0";
      $cbi['lastModified'] = date('Y-m-d H:i:s O');
      $issue = array();
      $issue['series'] = 'Watchmen';
      $issue['title'] = "At Midnight, All the Agents";
      $issue['publisher'] = "DC Comics";
      $issue['issue'] = "1";
      $cbi['ComicBookInfo/1.0'] = $issue;
      $cbi = json_encode($cbi);
      $zip->setArchiveComment($cbi);
      $zip->close();
  }
</pre>
<p>I wanted to do the same thing with ruby, so I nosed around and found the ruby gem rubyzip.</p>
<p>Unfortunately, the gem didn&#8217;t commit any changes to a zip file unless something was added to the archive.</p>
<p>Posted the issue on SO and Dylan Markow kindly fixed the gem for all to use.</p>
<pre code="ruby">
require 'zip/zip'

zf = Zip::ZipFile.open 'Archive.zip'

zf.comment = 'blah blah blah'

zf.commit
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2012/04/09/updating-a-zipfile-comments-with-ruby-zip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple manifests for the asset pipeline</title>
		<link>http://jakanapes.com/blog/2012/02/07/multiple-manifests-for-the-asset-pipeline/</link>
		<comments>http://jakanapes.com/blog/2012/02/07/multiple-manifests-for-the-asset-pipeline/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 15:32:05 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=127</guid>
		<description><![CDATA[One of the cool features introduced in Rails 3.1 was the asset pipeline (Asset Pipeline). The pipeline allows you to add js/css to manifest files and rails will precompile them into a single file, thus reducing load time. The docs mention that you can have multiple manifest files: You can have as many manifest files [...]]]></description>
			<content:encoded><![CDATA[<p>One of the cool features introduced in Rails 3.1 was the asset pipeline (<a href="http://guides.rubyonrails.org/asset_pipeline.html">Asset Pipeline</a>).  The pipeline allows you to add js/css to manifest files and rails will precompile them into a single file, thus reducing load time.</p>
<p>The docs mention that you can have multiple manifest files:</p>
<blockquote><p>You can have as many manifest files as you need. For example the admin.css and admin.js manifest could contain the JS and CSS files that are used for the admin section of an application.</p></blockquote>
<p>This is handy for any number of reasons, allowing you to have as many specific css or js files as needed.</p>
<p>However, one thing missing from the docs is how to tell the precompiler that it needs to look for additional manifest files.</p>
<p>Just add this to your application.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">assets</span>.<span style="color:#9900CC;">precompile</span> <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span> admin.<span style="color:#9900CC;">css</span> <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2012/02/07/multiple-manifests-for-the-asset-pipeline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>will_paginate and acts_as_taggable_on and bootstrap</title>
		<link>http://jakanapes.com/blog/2012/02/07/will_paginate-and-acts_as_taggable_on-and-bootstrap/</link>
		<comments>http://jakanapes.com/blog/2012/02/07/will_paginate-and-acts_as_taggable_on-and-bootstrap/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 15:26:04 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=121</guid>
		<description><![CDATA[In the process of updating my site to Rails 3.2 and decided to change up a few things. First, decided to use the bootstrap css framework from twitter (Bootstrap). There are a number of gems that allow you to use the less in rails, but the site actually has a very nice customization tool if [...]]]></description>
			<content:encoded><![CDATA[<p>In the process of updating my site to Rails 3.2 and decided to change up a few things.  First, decided to use the bootstrap css framework from twitter (<a href="http://twitter.github.com/bootstrap/" title="Bootstrap" target="_blank">Bootstrap</a>).  There are a number of gems that allow you to use the less in rails, but the site actually has a very nice customization tool if you just want to tweak it how you&#8217;d like and then download the static css.</p>
<p>In order to get will_paginate to play nicely with bootstrap, you should follow this advice (<a href="https://gist.github.com/1182136" target="_blank">will_paginate with bootstrap</a>).  Just create a will_paginate initializer to generate a new renderer for the link bar.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> WillPaginate
  <span style="color:#9966CC; font-weight:bold;">module</span> ActionView
    <span style="color:#9966CC; font-weight:bold;">def</span> will_paginate<span style="color:#006600; font-weight:bold;">&#40;</span>collection = <span style="color:#0000FF; font-weight:bold;">nil</span>, options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:renderer</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= BootstrapLinkRenderer
      <span style="color:#9966CC; font-weight:bold;">super</span>.<span style="color:#9900CC;">try</span> <span style="color:#ff3333; font-weight:bold;">:html_safe</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">class</span> BootstrapLinkRenderer <span style="color:#006600; font-weight:bold;">&lt;</span> LinkRenderer
      protected
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">def</span> html_container<span style="color:#006600; font-weight:bold;">&#40;</span>html<span style="color:#006600; font-weight:bold;">&#41;</span>
        tag <span style="color:#ff3333; font-weight:bold;">:div</span>, tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:ul</span>, html<span style="color:#006600; font-weight:bold;">&#41;</span>, container_attributes
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">def</span> page_number<span style="color:#006600; font-weight:bold;">&#40;</span>page<span style="color:#006600; font-weight:bold;">&#41;</span>
        tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span>page, page, <span style="color:#ff3333; font-weight:bold;">:rel</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> rel_value<span style="color:#006600; font-weight:bold;">&#40;</span>page<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'active'</span> <span style="color:#9966CC; font-weight:bold;">if</span> page == current_page<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">def</span> previous_or_next_page<span style="color:#006600; font-weight:bold;">&#40;</span>page, text, classname<span style="color:#006600; font-weight:bold;">&#41;</span>
        tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span>text, page <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'#'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>classname<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>..<span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>, classname, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'disabled'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> page<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">def</span> gap
         tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">super</span>, <span style="color:#996600;">'#'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'disabled'</span>
       <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I also decided to add tagging using the excellent acts_as_taggable_on gem (<a href="https://github.com/mbleigh/acts-as-taggable-on" target="_blank">Acts As Taggable On</a>).  One of the things I wanted to do was not only display all tags available, but all tags available on subsets.  And make it play nicely with pagination.</p>
<p>I tried this first:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@worlds</span> = World.<span style="color:#9900CC;">tagged_with</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:tag</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">order</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'title ASC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">page</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@tags</span> = <span style="color:#0066ff; font-weight:bold;">@worlds</span>.<span style="color:#9900CC;">tag_counts_on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:tags</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>but the query turns out to be too complex</p>
<blockquote><p>Mysql2::Error: This version of MySQL doesn&#8217;t yet support &#8216;LIMIT &#038; IN/ALL/ANY/SOME subquery&#8217;</p></blockquote>
<p>so I had to split out the actions on the relation:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@worlds</span> = World.<span style="color:#9900CC;">tagged_with</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:tag</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">order</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'title ASC'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@tags</span> = <span style="color:#0066ff; font-weight:bold;">@worlds</span>.<span style="color:#9900CC;">tag_counts_on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:tags</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@worlds</span> = <span style="color:#0066ff; font-weight:bold;">@worlds</span>.<span style="color:#9900CC;">page</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:page</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>and it works like a charm.</p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2012/02/07/will_paginate-and-acts_as_taggable_on-and-bootstrap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ajax on IE7</title>
		<link>http://jakanapes.com/blog/2011/04/21/ajax-on-ie7/</link>
		<comments>http://jakanapes.com/blog/2011/04/21/ajax-on-ie7/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 13:44:08 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=114</guid>
		<description><![CDATA[Trying to do .post() with jq 1.5 in IE7 and nothing. Exception message: &#8220;Object doesn&#8217;t support this property or method&#8221; Solution! $&#40;function &#40;&#41; &#123; $.ajaxSetup&#40;&#123; xhr: function&#40;&#41; &#123; if &#40;$.browser.msie&#41; &#123; return new ActiveXObject&#40;&#34;Microsoft.XMLHTTP&#34;&#41;; &#125; else &#123; return new XMLHttpRequest&#40;&#41;; &#125; &#125; &#125;&#41; &#125;&#41;]]></description>
			<content:encoded><![CDATA[<p>Trying to do .post() with jq 1.5 in IE7 and nothing. </p>
<p>Exception message: &#8220;Object doesn&#8217;t support this property or method&#8221;</p>
<p>Solution!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $.<span style="color: #660066;">ajaxSetup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> 
    xhr<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2011/04/21/ajax-on-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>goo.gl API with OAuth</title>
		<link>http://jakanapes.com/blog/2011/01/25/goo-gl-api-with-oauth/</link>
		<comments>http://jakanapes.com/blog/2011/01/25/goo-gl-api-with-oauth/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 19:10:44 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=100</guid>
		<description><![CDATA[Google recently added an API to their goo.gl URL shortening service. Currently, you can shorten, elongate and list your URLs. There are several ways to authenticate using the API, but I went with OAuth since it allows you to keep a list of unique shortened URLs. I decided to write a little library for use [...]]]></description>
			<content:encoded><![CDATA[<p>Google recently added an API to their goo.gl URL shortening service.</p>
<p>Currently, you can shorten, elongate and list your URLs.  There are several ways to authenticate using the API, but I went with OAuth since it allows you to keep a list of unique shortened URLs.  I decided to write a little library for use with Alternity, but first there are a few steps.</p>
<p>1.  Make sure that the URL shortening service is active in your <a href="https://code.google.com/apis/console/">Google API Console</a><br />
2.  Register your domain with Google <a href="https://www.google.com/accounts/ManageDomains">here</a></p>
<p>Registering your domain and putting in Target URL path prefix will enable your OAuth consumer key and OAuth consumer secret.</p>
<p>The next few steps will be familiar to anyone who has dealt with OAuth before, but Google has a few twists.</p>
<p>I used ruby&#8217;s oauth gem for this, currently version 0.4.4, so if you&#8217;re missing it just sudo gem install oauth.</p>
<p>Your first step is to create a consumer with your key and secret:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">consumer = <span style="color:#6666ff; font-weight:bold;">OAuth::Consumer</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>ConsumerKey, ConsumerSecret, 
<span style="color:#006600; font-weight:bold;">&#123;</span>:site <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;https://www.google.com&quot;</span>, 
<span style="color:#ff3333; font-weight:bold;">:request_token_path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/accounts/OAuthGetRequestToken&quot;</span>, 
<span style="color:#ff3333; font-weight:bold;">:access_token_path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/accounts/OAuthGetAccessToken&quot;</span>, 
<span style="color:#ff3333; font-weight:bold;">:authorize_path</span><span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/accounts/OAuthAuthorizeToken&quot;</span>, 
<span style="color:#ff3333; font-weight:bold;">:signature_method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;HMAC-SHA1&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Now you need to get your request tokens.  Google adds a scope parameter.  This can be a comma separated list of Google services, but I only care about the url shortener.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">request_token = consumer.<span style="color:#9900CC;">get_request_token</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:oauth_callback <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;http://www.SOMEURL.com&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, 
<span style="color:#006600; font-weight:bold;">&#123;</span>:scope <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;https://www.googleapis.com/auth/urlshortener&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Grab the authorization url</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">request_token.<span style="color:#9900CC;">authorize_url</span></pre></div></div>

<p>and paste that into your browser.  You&#8217;ll be taken to Google where you will be given the choice to either allow or deny access to the service.  When you select allow, Google will redirect back to your oauth_callback url and add some parameters:</p>
<p>http://www.SOMEURL.com/?oauth_verifier=big_long_string&#038;oauth_token=big_long_string</p>
<p>You&#8217;ll want to note the verifier and the token.  They&#8217;re url encoded so I decoded them.  Just ran them through php&#8217;s url_decode on the command line.  </p>
<p>php -r &#8220;echo url_decode(big_long_string);&#8221;</p>
<p>Now you need your access tokens</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">access_token = request_token.<span style="color:#9900CC;">get_access_token</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:oauth_verifier</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>OAUTHVERIFIER FROM URL ABOVE<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Pull out your access token and access secret with access_token.token and access_token.secret and save them somewhere.</p>
<p>Now when you need to use the api in your web app, it&#8217;s a two step process.</p>
<p>1.  Get the consumer using the same process as above.<br />
2.  Create the access token</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">access_token = <span style="color:#6666ff; font-weight:bold;">OAuth::AccessToken</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>consumer, ACCESSTOKEN, ACCESSSECRET<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Get your history</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">response = access_token.<span style="color:#9900CC;">get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'https://www.googleapis.com/urlshortener/v1/url/history'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
history = JSON::parse<span style="color:#006600; font-weight:bold;">&#40;</span>response.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Shorten a url</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">h = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span>
h<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;longUrl&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;http://www.something.com&quot;</span>
j = h.<span style="color:#9900CC;">to_json</span>
response = access_token.<span style="color:#9900CC;">post</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'https://www.googleapis.com/urlshortener/v1/url'</span>, j, <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">'Content-Type'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'application/json'</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
shortURL = JSON::parse<span style="color:#006600; font-weight:bold;">&#40;</span>response.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;id&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2011/01/25/goo-gl-api-with-oauth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cloud storage</title>
		<link>http://jakanapes.com/blog/2011/01/14/cloud-storage/</link>
		<comments>http://jakanapes.com/blog/2011/01/14/cloud-storage/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 19:13:02 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=97</guid>
		<description><![CDATA[I&#8217;m a big fan of DropBox, ever since I started I using it I don&#8217;t remember the last time I had to use a USB drive. Recently, I tried out SugarSync and I have to say I&#8217;m impressed. You can sync any folders you like on any number of computers you want. No more being [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of <a href="http://www.dropbox.com">DropBox</a>, ever since I started I using it I don&#8217;t remember the last time I had to use a USB drive.</p>
<p>Recently, I tried out <a href="https://www.sugarsync.com/referral?rf=fcfembrafmj44">SugarSync</a> and I have to say I&#8217;m impressed.  You can sync any folders you like on any number of computers you want.  No more being limited to the dropbox folder.  You can email a file to your storage space, push images to facebook and email files directly from the mobile app.  The devs really took their time and included a ton of useful features.  Their free plan starts at 5 gb with plenty of chances to earn more storage.</p>
<p>Competition is good and I&#8217;ll be interested to see what DropBox does in response.</p>
<p>You can sign up <a href="https://www.sugarsync.com/referral?rf=fcfembrafmj44">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2011/01/14/cloud-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL GUI</title>
		<link>http://jakanapes.com/blog/2010/12/22/mysql-gui/</link>
		<comments>http://jakanapes.com/blog/2010/12/22/mysql-gui/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 15:00:59 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=93</guid>
		<description><![CDATA[I&#8217;ve been using mysql for a long time and I&#8217;ve always preferred the command line. I&#8217;ve used tools before, like navicat, or the mysql tools (which are great for stored procedure creation, though). Even the Textmate interface doesn&#8217;t seem to quite fit my needs. Recently, though, I&#8217;ve been using Sequel Pro for some of my [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using mysql for a long time and I&#8217;ve always preferred the command line.  I&#8217;ve used tools before, like navicat, or the mysql tools (which are great for stored procedure creation, though).  Even the Textmate interface doesn&#8217;t seem to quite fit my needs.  </p>
<p>Recently, though, I&#8217;ve been using <a href="http://www.sequelpro.com/">Sequel Pro</a> for some of my quick dips into the database and I have to say that I&#8217;m impressed.  A clean interface and some nice features for queries make it a viable option.  I still like to use command line for any intensive work, because I like to know exactly what&#8217;s going on, but for a quick look at a table structure or a simple select query I&#8217;m starting to use this tool more and more.</p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2010/12/22/mysql-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Captcha on Comments</title>
		<link>http://jakanapes.com/blog/2010/12/13/new-captcha-on-comments/</link>
		<comments>http://jakanapes.com/blog/2010/12/13/new-captcha-on-comments/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 16:55:41 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=90</guid>
		<description><![CDATA[Added the monetized captchas from Solve Media to the comments. Interesting idea. I&#8217;m curious to see how it works out.]]></description>
			<content:encoded><![CDATA[<p>Added the monetized captchas from <a href="http://portal.solvemedia.com/">Solve Media</a> to the comments.</p>
<p>Interesting idea.  I&#8217;m curious to see how it works out.</p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2010/12/13/new-captcha-on-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick memory game</title>
		<link>http://jakanapes.com/blog/2010/11/16/quick-memory-game/</link>
		<comments>http://jakanapes.com/blog/2010/11/16/quick-memory-game/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 20:31:03 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jakanapes.com/blog/?p=87</guid>
		<description><![CDATA[Threw together a quick memory tile game using jquery and php. Used memotest as a starting point and then upgraded the jquery to the latest version and put in all new php to randomly select images. Once I get it more how I want it, I think I&#8217;ll try to incorporate it into my ruby [...]]]></description>
			<content:encoded><![CDATA[<p>Threw together a quick memory tile game using jquery and php.  Used <a href="http://www.jquery.wisdomplug.com/jquery-games/jquery-memotest-colorful-jquery-memory-game/">memotest</a> as a starting point and then upgraded the jquery to the latest version and put in all new php to randomly select images.  Once I get it more how I want it, I think I&#8217;ll try to incorporate it into my ruby on rails site.</p>
<p>Give it a try!</p>
<p><a href="http://jakanapes.com/MemoryGame/">Memory Game</a></p>
<p>I resized the images using thumbs up from <a href="http://www.devon-technologies.com/products/freeware/">Devon Technologies</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2010/11/16/quick-memory-game/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>S3&#8242;s object limit</title>
		<link>http://jakanapes.com/blog/2010/11/01/s3s-object-limit/</link>
		<comments>http://jakanapes.com/blog/2010/11/01/s3s-object-limit/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 15:37:43 +0000</pubDate>
		<dc:creator>Jakanapes</dc:creator>
				<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://jakanapes.com/?p=79</guid>
		<description><![CDATA[This is more to remind myself about the limit than anything else. Amazon Web Services S3 has a limit of 1000 objects returned by a request. In order to work around this, you simply loop through your objects using a marker, much like using a LIMIT clause in mysql. The marker is the last key [...]]]></description>
			<content:encoded><![CDATA[<p>This is more to remind myself about the limit than anything else.</p>
<p>Amazon Web Services S3 has a limit of 1000 objects returned by a request.  In order to work around this, you simply loop through your objects using a marker, much like using a LIMIT clause in mysql.</p>
<p>The marker is the last key you received.</p>
<p>Since I&#8217;m using the aws::s3 gem in Ruby on Rails, here&#8217;s my example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    s3_objects = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    marker = <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span> 
      list = <span style="color:#6666ff; font-weight:bold;">AWS::S3::Bucket</span>.<span style="color:#9900CC;">objects</span><span style="color:#006600; font-weight:bold;">&#40;</span>bucket, <span style="color:#ff3333; font-weight:bold;">:marker</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> marker<span style="color:#006600; font-weight:bold;">&#41;</span>
      s3_objects.<span style="color:#9900CC;">concat</span><span style="color:#006600; font-weight:bold;">&#40;</span>list<span style="color:#006600; font-weight:bold;">&#41;</span>
      marker = list.<span style="color:#9900CC;">last</span>.<span style="color:#9900CC;">key</span>
    <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#9966CC; font-weight:bold;">while</span> list.<span style="color:#9900CC;">size</span> == <span style="color:#006666;">1000</span></pre></div></div>

<p>Even after using it for several years, ruby&#8217;s version of a do&#8230;while loop still looks weird to a C++ coder.</p>
]]></content:encoded>
			<wfw:commentRss>http://jakanapes.com/blog/2010/11/01/s3s-object-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

