<?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>Gittr</title>
	<atom:link href="http://www.gittr.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gittr.com</link>
	<description>eval("eval(\"eval(\\\"puts 'a ruby weblog'\\\")\")")</description>
	<lastBuildDate>Thu, 22 Oct 2009 12:54:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sinatra Cookie handling in 0.9.4</title>
		<link>http://www.gittr.com/index.php/archive/sinatra-cookie-handling-in-0-9-4/</link>
		<comments>http://www.gittr.com/index.php/archive/sinatra-cookie-handling-in-0-9-4/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 15:33:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=109</guid>
		<description><![CDATA[I had an older post about cookie handling with Sinatra, and a few details are out of date.  This is a current view (as of September 2009) of how cookies work in&#160;Sinatra.
First, you need to set cookies via the response object, as Sinatra no longer has a helper for&#160;it.

response.set_cookie&#40;&#34;foo&#34;, &#34;bar&#34;&#41;

Second, set_cookie always takes two arguments. [...]]]></description>
			<content:encoded><![CDATA[<p>I had an <a href="http://www.gittr.com/index.php/archive/setting-and-getting-cookies-in-sinatra/">older post</a> about cookie handling with Sinatra, and a few details are out of date.  This is a current view (as of September 2009) of how cookies work in&nbsp;Sinatra.</p>
<p>First, you need to set cookies via the response object, as Sinatra no longer has a helper for&nbsp;it.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">response.<span style="color:#9900CC;">set_cookie</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;foo&quot;</span>, <span style="color:#996600;">&quot;bar&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Second, set_cookie always takes two arguments. If you need to set advanced options, pass a&nbsp;hash:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># the large number is several years in the future, in seconds</span>
response.<span style="color:#9900CC;">set_cookie</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;foo&quot;</span>, <span style="color:#006600; font-weight:bold;">&#123;</span>:value <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;bar&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:expiration</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">today</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">94608000</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>There are a good handful of options available.  One gotcha with the expires option is that it must respond to .gmtime, which the Date object does not. So you need to use Time or DateTime as far as I can&nbsp;tell.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">set_cookie<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;thing&quot;</span>, <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:value</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;thing2&quot;</span>,
                      <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> myDomain,
                      <span style="color:#ff3333; font-weight:bold;">:path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> myPath,
                      <span style="color:#ff3333; font-weight:bold;">:expires</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">today</span>,
                      <span style="color:#ff3333; font-weight:bold;">:secure</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>,
                      <span style="color:#ff3333; font-weight:bold;">:httponly</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>To read the underlying code for setting cookies, it&#8217;s in the rack gem, rack-1.0.0/lib/rack/response.rb line&nbsp;56.</p>
<p>To fetch cookies, it&#8217;s simply calling the cookie&nbsp;method:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">cookies<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;foo&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#008000; font-style:italic;"># =&gt; &quot;bar&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/sinatra-cookie-handling-in-0-9-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CouchDB Skeleton for Monk</title>
		<link>http://www.gittr.com/index.php/archive/couchdb-skeleton-for-monk/</link>
		<comments>http://www.gittr.com/index.php/archive/couchdb-skeleton-for-monk/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 17:37:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=104</guid>
		<description><![CDATA[Monk is starting to take off, and people are already starting to make new skeletons specific for their own needs. Check out lazybones by TobyJoe for a CouchDB based skeleton. (Github)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.monkrb.com">Monk</a> is starting to take off, and people are already starting to make new skeletons specific for their own needs. Check out <a href="http://www.tobyjoe.com/2009/08/monkrb-skeleton-for-couchdb-and-sinatra/">lazybones</a> by TobyJoe for a CouchDB based skeleton. (<a href="http://github.com/tobyjoe/lazybones/tree/master">Github</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/couchdb-skeleton-for-monk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monk &#8211; Quickstart Sinatra Projects</title>
		<link>http://www.gittr.com/index.php/archive/monk-quickstart-sinatra-projects/</link>
		<comments>http://www.gittr.com/index.php/archive/monk-quickstart-sinatra-projects/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 22:25:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=92</guid>
		<description><![CDATA[A few coworkers at Citrusbyte (@soveran, @djanowski) have been working on Monk, a new open source web framework.  At its core is Sinatra, with a set of bundled technologies to help new projects get moving as quick as possible.  It helps you figure out the best structure for your Sinatra app, and gets you moving [...]]]></description>
			<content:encoded><![CDATA[<p>A few coworkers at <a href="http://www.citrusbyte.com">Citrusbyte</a> (<a href="http://twitter.com/soveran">@soveran</a>, <a href="http://twitter.com/djanowski">@djanowski</a>) have been working on <a href="http://www.monkrb.com"><strong>Monk</strong></a>, a new open source web framework.  At its core is Sinatra, with a set of bundled technologies to help new projects get moving as quick as possible.  It helps you figure out the best structure for your Sinatra app, and gets you moving quickly with logging, settings, and&nbsp;testing. </p>
<h3>Monk consists of several&nbsp;components:</h3>
<h4>Monk&nbsp;Binary</h4>
<p>At the core of Monk is a command line tool for starting new projects.  Think of the <em>rails</em> command, and what it does and you have a good idea of what the <em>monk</em> command does.  It lists, manages and instantiates new skeletons for your project. The Monk binary can instatiate any skeleton you want, which means it is a great way to start projects in any&nbsp;language.</p>
<h4>Monk&nbsp;Skeletons</h4>
<p>A Monk skeleton is a set of files defining the structure of a new project.  There are almost no rules here, the new project can be Sinatra, Django, an ircbot setup, or anything else you want, heck, it could even be&nbsp;Rails. </p>
<h4>Monk Default&nbsp;Skeleton</h4>
<p>The default Monk skeleton is where lots of work has gone in, and where you&#8217;ll find the meat of Monk.  It&#8217;s a set of amazing tools forming a full-stack Sinatra based web development&nbsp;platform.</p>
<ul>
<li>Sinatra - super lightweight web <span class="caps">DSL</span>. You know what this is (and if you don&#8217;t, go read the rest of this blog, and check it&nbsp;out)</li>
<li>Ohm - data access layer using Redis, a stupid fast key-value database.  Super simple models for your&nbsp;app</li>
<li>Monk Glue - a Reloader, Logger, and Settings handler for your new application. Don&#8217;t worry about it, Sinatra Logging finally made easy&#8230;  Monk Glue is destined to keep growing too, including a handful of mix <span class="amp">&amp;</span> match helpers for common&nbsp;tasks.</li>
<li>Rack-Test, Contest, Stories, Webrat, Faker, Spawn - An amazing unit and integration test stack, allowing both low level unit tests of your code, and high level integration tests, similar in style to Cucumber, but without that nasty repeating-yourself part.  You owe it to yourself to try the stories <span class="amp">&amp;</span> webrat approach to testing your Sinatra&nbsp;application.</li>
<li>Dependencies - trivial management of all the gems you rely on. Just define a dependencies file, and the dependencies gem will handle vendoring and unpacking your&nbsp;requirements.</li>
</ul>
<h4>Monk&nbsp;Glue</h4>
<p><strong>Logging</strong> - a perennial problem and hassle in setting up new projects is now simple with Monk, and Monk&nbsp;Glue. </p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  logger.<span style="color:#9900CC;">info</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Entered homepage route&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#996600;">&quot;homepage text&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Reloader</strong> - an alternative to the classic Sinatra reloading (with weird require related issues), and Shotgun, which causes a fork() each request, which is fairly heavyweight.  Glue&#8217;s Reloader is the happy midpoint, between the other two solutions. It reloads everything, but in the same Ruby process, making it much&nbsp;faster.</p>
<p><strong>Settings</strong> - a minimalist implementation of the settings.yml file, with environment support. Easily switch up your database settings, your email address, url and more.  Bonus Feature: the default skeleton creates an automatic settings.yml file when you first run&nbsp;monk:start. </p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#0066ff; font-weight:bold;">@foobar</span> = settings<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:foobar</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#996600;">&quot;the value of the foobar setting is:&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#0066ff; font-weight:bold;">@foobar</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p> </p>
<h4>Ohm Persistence&nbsp;Layer</h4>
<p>Ohm is a lightweight data management layer that uses Redis as it&#8217;s backend. Redis is a fast key-value database, and Ohm makes mappings that are simple to define, and automates the nasty parts of key-value databases like reverse lookups (indexes).  Ohm isn&#8217;t technically an <span class="caps">ORM</span>, since there&#8217;s no relational database backing it, but it fills the same niche as ActiveRecord or Datamapper, storing your data for future&nbsp;use.</p>
<h3>Awesome Reddit Clone&nbsp;Example</h3>
<p>Check out <a href="http://news.monkrb.com/">http://news.monkrb.com/</a>, the code is located at&nbsp;<a href="http://github.com/monkrb/reddit-clone/tree/master">http://github.com/monkrb/reddit-clone</a></p>
<p>Pay attention for a future blog post digging further into this example code,&nbsp;and dissecting it.</p>
<h3>Get Monk <span class="amp">&amp;</span> Find out&nbsp;More</h3>
<h4>Install&nbsp;Monk</h4>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">gem install monk</pre></div></div>

<h4>Links</h4>
<ul>
<li><a href="http://monkrb.com">Official Monk Website -&nbsp;http://monkrb.com</a></li>
<li>Monk Github:&nbsp;<a href="http://www.github.com/monkrb/monk">http://www.github.com/monkrb/monk</a></li>
<li>Monk Default Skeleton Github:  <a href="http://www.github.com/monkrb/skeleton">http://www.github.com/monkrb/skeleton</a></li>
<li>Monk Glue Github:&nbsp;<a href="http://www.github.com/monkrb/glue">http://www.github.com/monkrb/glue</a></li>
<li>Ohm Documentation:&nbsp;<a href="http://ohm.keyvalue.org/">http://ohm.keyvalue.org/</a></li>
<li>Ohm Github:&nbsp;<a href="http://github.com/soveran/ohm">http://github.com/soveran/ohm</a></li>
<li>Monk Mailing List Link:&nbsp;<a href="http://groups.google.com/group/monkrb">http://groups.google.com/group/monkrb</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/monk-quickstart-sinatra-projects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wrapping get, post, put, delete &#8211; Add Magic JSON Power</title>
		<link>http://www.gittr.com/index.php/archive/wrapping-get-post-put-delete-add-magic-json-power/</link>
		<comments>http://www.gittr.com/index.php/archive/wrapping-get-post-put-delete-add-magic-json-power/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 03:55:14 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=89</guid>
		<description><![CDATA[Several times recently, there have been questions in the #sinatra channel, and on the mailing list about how to automatically render JSON, or any other kind of format as the response from&#160;Sinatra.
My favorite way of accomplishing this is to wrap the normal get and post methods with additional JSON&#160;abilities.

require 'rubygems'
require 'sinatra'
require 'json'
&#160;
def json_get&#40;route, options=&#123;&#125;, &#38;#038;block)
 [...]]]></description>
			<content:encoded><![CDATA[<p>Several times recently, there have been questions in the #sinatra channel, and on the mailing list about how to automatically render <span class="caps">JSON</span>, or any other kind of format as the response from&nbsp;Sinatra.</p>
<p>My favorite way of accomplishing this is to wrap the normal get and post methods with additional <span class="caps">JSON</span>&nbsp;abilities.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> json_get<span style="color:#006600; font-weight:bold;">&#40;</span>route, 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;">&amp;</span><span style="color:#008000; font-style:italic;">#038;block)</span>
  get<span style="color:#006600; font-weight:bold;">&#40;</span>route, options<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> 
    block.<span style="color:#9900CC;">call</span>.<span style="color:#9900CC;">to_json</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
json_get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;bar&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;baz&quot;</span>, <span style="color:#996600;">&quot;foo&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;bar&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And of course, this can be expanded to other cases where you&#8217;d want to pre-process or post-process certain routes. You could easily define an <strong>admin_get</strong> that checks that the user is logged in as an admin. Or an <strong>xml_get</strong>, or a <strong>timed_get</strong>&nbsp;method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/wrapping-get-post-put-delete-add-magic-json-power/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rendering different layouts with Sinatra</title>
		<link>http://www.gittr.com/index.php/archive/rendering-different-layouts-with-sinatra/</link>
		<comments>http://www.gittr.com/index.php/archive/rendering-different-layouts-with-sinatra/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 15:38:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=86</guid>
		<description><![CDATA[I had a project recently that had a requirement of a frontend, and an admin backend. Pretty normal for an application, but of course the admin had a different layout, set of tabs, etc.  I didn&#8217;t want to say :layout => &#8216;admin&#8217; everywhere, so I came up with this (very small) code snippet to [...]]]></description>
			<content:encoded><![CDATA[<p>I had a project recently that had a requirement of a frontend, and an admin backend. Pretty normal for an application, but of course the admin had a different layout, set of tabs, etc.  I didn&#8217;t want to say :layout => &#8216;admin&#8217; everywhere, so I came up with this (very small) code snippet to make rendering a different layout&nbsp;easy.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> admin_haml<span style="color:#006600; font-weight:bold;">&#40;</span>template, 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> 
  haml<span style="color:#006600; font-weight:bold;">&#40;</span>template, options.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> :<span style="color:#996600;">'admin/layout'</span><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;">end</span></pre></div></div>

<p>Which I then used in my code&nbsp;like:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">get <span style="color:#996600;">'/admin/users'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#0066ff; font-weight:bold;">@users</span> = User.<span style="color:#9900CC;">all</span>
  admin_haml :<span style="color:#996600;">'admin/user/index'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This also shows how to have nested directories in the views folder if you were curious. This will look for the view  views/admin/users/index.haml, and render it with the layout&nbsp;views/admin/layout.haml.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/rendering-different-layouts-with-sinatra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Sinatra 0.10.1</title>
		<link>http://www.gittr.com/index.php/archive/installing-sinatra-0-10-1/</link>
		<comments>http://www.gittr.com/index.php/archive/installing-sinatra-0-10-1/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 15:07:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=81</guid>
		<description><![CDATA[The current version of Sinatra (as of the time I write this) is version 0.10.1.  The gem on rubyforge is outdated (0.9.2).  To install the current gem, use the github built&#160;version:

sudo gem install sinatra-sinatra --source=http://gems.github.com

]]></description>
			<content:encoded><![CDATA[<p>The current version of Sinatra (as of the time I write this) is version 0.10.1.  The gem on rubyforge is outdated (0.9.2).  To install the current gem, use the github built&nbsp;version:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">sudo gem install sinatra-sinatra --source=http://gems.github.com</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/installing-sinatra-0-10-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActiveRecord timezones without Rails</title>
		<link>http://www.gittr.com/index.php/archive/activerecord-timezones-without-rails/</link>
		<comments>http://www.gittr.com/index.php/archive/activerecord-timezones-without-rails/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 14:23:00 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=77</guid>
		<description><![CDATA[I was using Active Record in a batch application to manipulate some data, and I needed the timezone handling built into the newer versions.  But I had a hell of a time trying to figure out how to make it all&#160;work. 
In plain Rails, it&#8217;s&#160;simple:

Rails::Initializer.run do &#124;config&#124;
  config.time_zone = 'Pacific Time (US &#38; [...]]]></description>
			<content:encoded><![CDATA[<p>I was using Active Record in a batch application to manipulate some data, and I needed the timezone handling built into the newer versions.  But I had a hell of a time trying to figure out how to make it all&nbsp;work. </p>
<p>In plain Rails, it&#8217;s&nbsp;simple:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Rails::Initializer</span>.<span style="color:#9900CC;">run</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span>
  config.<span style="color:#9900CC;">time_zone</span> = <span style="color:#996600;">'Pacific Time (<span class="caps">US</span> <span class="amp">&amp;</span> Canada)'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>But I wasn&#8217;t running Rails proper, and didn&#8217;t want to pull in the whole Rails boot sequence.  So the Rails::Initializer call didn&#8217;t work.  To do it manually, time zone config turns out it&#8217;s a 3 lines of setup&nbsp;calls:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'activerecord'</span>
<span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">zone</span> = <span style="color:#996600;">&quot;Pacific Time (<span class="caps">US</span> <span class="amp">&amp;</span> Canada)&quot;</span>
<span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">time_zone_aware_attributes</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
<span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">default_timezone</span> = <span style="color:#996600;">&quot;Pacific Time (<span class="caps">US</span> <span class="amp">&amp;</span> Canada)&quot;</span></pre></div></div>

<p>When you do that, time zone attributes work both going into the database, and coming back out. If you miss the last line, they&#8217;ll just not work coming out, which is a damn confusing thing to deal&nbsp;with.</p>
<p>Ohh, and one other thing I ran into when getting this setup is that <span class="caps">AR</span> pulls in Active Support, which in turn pulls in Builder (to hack xml support or something). Just watch out for that, you&#8217;ll get weird crashes if you don&#8217;t have builder installed.  Honestly, I just went and commented out the areas of Active Support that did it, I didn&#8217;t want builder&nbsp;anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/activerecord-timezones-without-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fix for: &#8220;no such file to load &#8212; blankslate&#8221;</title>
		<link>http://www.gittr.com/index.php/archive/fix-for-no-such-file-to-load-blankslate/</link>
		<comments>http://www.gittr.com/index.php/archive/fix-for-no-such-file-to-load-blankslate/#comments</comments>
		<pubDate>Tue, 12 May 2009 17:43:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=75</guid>
		<description><![CDATA[I was getting this error, and it turns out it&#8217;s just that builder isn&#8217;t installed.  sudo gem install builder, and you&#8217;re&#160;fixed.

/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- blankslate (MissingSourceFile)
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/basic_object.rb:21
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/duration.rb:1
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/time/calculations.rb:1
	 ... 18 levels...
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'

]]></description>
			<content:encoded><![CDATA[<p>I was getting this error, and it turns out it&#8217;s just that builder isn&#8217;t installed.  sudo gem install builder, and you&#8217;re&nbsp;fixed.</p>
<pre>
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- blankslate (MissingSourceFile)
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/basic_object.rb:21
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/duration.rb:1
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/time/calculations.rb:1
	 ... 18 levels...
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/fix-for-no-such-file-to-load-blankslate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tokyo Cabinet and Tyrant for Ruby</title>
		<link>http://www.gittr.com/index.php/archive/tokyo-cabinet-and-tyrant-for-ruby/</link>
		<comments>http://www.gittr.com/index.php/archive/tokyo-cabinet-and-tyrant-for-ruby/#comments</comments>
		<pubDate>Sat, 09 May 2009 00:18:57 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=71</guid>
		<description><![CDATA[I&#8217;m writing this post as a brain dump and for future reference.  I was doing research on Tokyo Cabinet and Tyrant today for&#160;an upcoming project.
Tokyo Cabinet - A Key Value database that&#8217;s stupidly fast 
Tokyo Tyrant - A network layer on top of Tokyo Cabinet
Tokyo Dystopia - A full text search (inverted index) on top of Tokyo&#160;Cabinet 
 
Official&#160;Docs:
These include mostly [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post as a brain dump and for future reference.  I was doing research on Tokyo Cabinet and Tyrant <abbr class="datetime" title="2009-05-08">today</abbr> for&nbsp;an upcoming project.</p>
<p><strong>Tokyo Cabinet -</strong> A Key Value database that&#8217;s stupidly fast<strong> <br />
<span style="font-weight: normal;"><strong>Tokyo Tyrant - </strong>A network layer on top of Tokyo Cabinet<br />
<strong>Tokyo Dystopia - </strong>A full text search (inverted index) on top of Tokyo&nbsp;Cabinet </span></strong></p>
<p> </p>
<p><strong>Official&nbsp;Docs:</strong></p>
<p>These include mostly the official C <span class="caps">API</span> docs.  They are useful if you skim through them, not for the C definitions, but to get an idea of what is possible.  You will get lots of sparse explanations, but it&#8217;s a&nbsp;start.</p>
<ul>
<li><strong>Tokyo Cabinet: <span style="font-weight: normal;"><a href="http://tokyocabinet.sourceforge.net/">http://tokyocabinet.sourceforge.net/</a></span></strong></li>
<li><strong>Tokyo Tyrant: <span style="font-weight: normal;"><a href="http://tokyocabinet.sourceforge.net/tyrantdoc/">http://tokyocabinet.sourceforge.net/tyrantdoc/</a></span></strong></li>
<li><strong>Tokyo Dystopia: </strong><a href="http://tokyocabinet.sourceforge.net/dystopiadoc/">http://tokyocabinet.sourceforge.net/dystopiadoc/</a></li>
</ul>
<p><strong>Ruby&nbsp;Libraries:</strong></p>
<ul>
<li><strong>Official Ruby Lib (forked to github <span class="amp">&amp;</span> gemified) </strong><a href="http://github.com/careo/tokyocabinet-ruby">http://github.com/careo/tokyocabinet-ruby</a></li>
<li><strong>Official Ruby Lib (forked to github <span class="amp">&amp;</span> gemified) </strong><a href="http://github.com/careo/tokyotyrant-ruby">http://github.com/careo/tokyotyrant-ruby</a></li>
<li><strong>Rufus Library (<span class="caps">FFI</span> Based) <span style="font-weight: normal;"><a href="http://github.com/jmettraux/rufus-tokyo/tree/master">http://github.com/jmettraux/rufus-tokyo/tree/master</a></span></strong></li>
<li><strong>Datamapper Adapter</strong>  <a href="http://github.com/makoto/dm-tokyo-cabinet-adapter">http://github.com/makoto/dm-tokyo-cabinet-adapter</a></li>
<li><strong>Speed Comparison (At the bottom): <span style="font-weight: normal;"><a href="http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/">http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/</a></span></strong></li>
</ul>
<p><strong>More About Rufus&nbsp;Library:</strong></p>
<ul>
<li><strong>Rufus 0.1.5 Release Notes - </strong><a href="http://jmettraux.wordpress.com/2009/02/13/rufus-tokyo-015-hail-to-the-tyrant/">http://jmettraux.wordpress.com/2009/02/13/rufus-tokyo-015-hail-to-the-tyrant/</a></li>
<li><strong>Rufus 0.1.9 Release Notes - </strong><a href="http://jmettraux.wordpress.com/2009/02/27/rufus-tokyo-018-rufusedo/">http://jmettraux.wordpress.com/2009/02/27/rufus-tokyo-018-rufusedo/</a></li>
</ul>
<p><strong><span class="caps">OSX</span>&nbsp;Installation:</strong></p>
<p>Macports version of Tokyo Cabinet and Tokyo Tyrant are broken.  The current state is that there are incompatible versions of cabinet <span class="amp">&amp;</span> tyrant, and that there are Portfile problems as well, where the checksum doesn&#8217;t match the downloaded file.  I eventually gave up, and just used the instructions at <a href="http://openwferu.rubyforge.org/tokyo.html">http://openwferu.rubyforge.org/tokyo.html</a> to install it manually (the version numbers in that post are old, but otherwise accurate).  Those instructions install it to /usr/local/bin, so you may need to add it to your&nbsp;path.</p>
<p><strong>Key Value Store&nbsp;Theory:</strong></p>
<ul>
<li>This post talks about Redis, but is a good introduction to the thinking needed for Key Value storage, as opposed to a relational approach.&nbsp;<a href="http://code.google.com/p/redis/wiki/TwitterAlikeExample">http://code.google.com/p/redis/wiki/TwitterAlikeExample</a></li>
<li><a href="http://antirez.com/post/Sorting-in-key-value-data-model.html">http://antirez.com/post/Sorting-in-key-value-data-model.html</a></li>
</ul>
<p><strong>More Cabinet&nbsp;Docs:</strong></p>
<ul>
<li>A quick intro into the storage and theory of Cabinet.  Not much actionable content here, but useful background.&nbsp;<a href="http://www.scribd.com/doc/12016121/Tokyo-Cabinet-and-Tokyo-Tyrant-Presentation">http://www.scribd.com/doc/12016121/Tokyo-Cabinet-and-Tokyo-Tyrant-Presentation</a></li>
</ul>
<p><strong>Cabinet Storage&nbsp;Engines:</strong></p>
<p>I&#8217;m still vague on the real differences in this section. I&#8217;ll expand out as I learn and understand more. What I do know is that B-Tree and Table have additional methods on them, and that Tyrant doesn&#8217;t support at least the B-Tree ones (at a C level, it&#8217;s not a problem with the Ruby&nbsp;bindings).</p>
<ul>
<li><strong>Hash</strong> - Standard hash structure for storing a&nbsp;key. </li>
<li><strong>B-Tree</strong> - Tree structure to store keys. Allows for ordering, and multiple&nbsp;values.</li>
<li><strong>Table</strong> - ?? Allows storing of arbitrary keys, and indexes (like&nbsp;CouchDB?).</li>
<li><strong>??</strong> - I think array is another one, for fixed length values, but I haven&#8217;t gone into that one&nbsp;yet</li>
</ul>
<p><strong>Other&nbsp;Items:</strong></p>
<p>Lightcloud is some sort of distributed layer on top of tyrant, which gives some horizontal scaling ability. I haven&#8217;t looked much further than&nbsp;that.</p>
<ul>
<li><strong>Lightcloud</strong> - <a href="http://opensource.plurk.com/LightCloud/">http://opensource.plurk.com/LightCloud/</a></li>
<li><strong>Lightcloud Ruby</strong> - <a href="http://github.com/mitchellh/lightcloud">http://github.com/mitchellh/lightcloud</a></li>
<li><strong>Django Tokyo Sessions</strong> - <a href="http://pypi.python.org/pypi/django-tokyo-sessions/0.1.0">http://pypi.python.org/pypi/django-tokyo-sessions/0.1.0</a></li>
</ul>
<p> </p>
<p>That&#8217;s enough for now&#8230;. I&#8217;ll try to keep this updated as I&nbsp;learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/tokyo-cabinet-and-tyrant-for-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capistrano On OSX Error: could not find any SCM named `git&#8217;</title>
		<link>http://www.gittr.com/index.php/archive/capistrano-on-osx-error-could-not-find-any-scm-named-git/</link>
		<comments>http://www.gittr.com/index.php/archive/capistrano-on-osx-error-could-not-find-any-scm-named-git/#comments</comments>
		<pubDate>Thu, 07 May 2009 04:56:53 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=68</guid>
		<description><![CDATA[I am working on getting my development environment setup on my new mac, and ran into an under-documented error: &#8220;could not find any SCM named `git&#8217;&#8221;.&#160; 
It turns out that Leopard installs capistrano 2.0 automatically, and in a battle between /usr/bin/ and /opt/local/bin, the first one on the path of course wins. The trick is to [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on getting my development environment setup on my new mac, and ran into an under-documented error: &#8220;<strong>could not find any <span class="caps">SCM</span> named `git&#8217;</strong>&#8221;.&nbsp; </p>
<p>It turns out that Leopard installs capistrano 2.0 automatically, and in a battle between /usr/bin/ and /opt/local/bin, the first one on the path of course wins. The trick is to run <strong>sudo /usr/bin/gem uninstall capistrano</strong> which will get rid of both the gem, and more importantly the cap and capify commands that came with it.  Now just install capistrano in your macports install of gems <strong>sudo </strong><strong>/opt/local/bin/gem install capistrano</strong> and run cap: <strong>/opt/local/bin/cap&nbsp;deploy</strong></p>
<p>This <a href="http://neverlet.be/2009/1/12/capistrano-on-osx">blog post</a> was very helpful while I was hunting down this&nbsp;info.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/capistrano-on-osx-error-could-not-find-any-scm-named-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
