<?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>occasionally useful &#187; ruby</title>
	<atom:link href="http://blog.maxaller.name/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.maxaller.name</link>
	<description>ruby, ubuntu, etc</description>
	<lastBuildDate>Sun, 11 Jul 2010 07:01:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A brief introduction to Ruby, Sinatra, and Haml</title>
		<link>http://blog.maxaller.name/2010/01/a-brief-introduction-to-ruby-sinatra-and-haml/</link>
		<comments>http://blog.maxaller.name/2010/01/a-brief-introduction-to-ruby-sinatra-and-haml/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 20:01:05 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=251</guid>
		<description><![CDATA[Ruby and Sinatra make it ludicrously easy to make a webapp, but getting started, as with any new language or framework, can be daunting.  By the end of this part, you'll have a simple template that talks back to you!

I'm not going to go over how to install Ruby here (it's probably been done [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby and Sinatra make it ludicrously easy to make a webapp, but getting started, as with any new language or framework, can be daunting.  By the end of this part, you'll have a simple template that talks back to you!<br />
<span id="more-251"></span><br />
I'm not going to go over how to install Ruby here (it's probably been done numerous times around the web), but here's a quick checklist:<br />
1) Install Ruby (http://www.ruby-lang.org/en/downloads/)<br />
2) If running Ruby 1.8.6 or 1.8.7 (check with ruby -v), install Rubygems.  For more info on Rubygems, check out http://docs.rubygems.org/read/book/1 .  Ruby 1.9 and above come with Rubygems built in.<br />
3) Install the Sinatra and Haml rubygems (see http://docs.rubygems.org/read/chapter/2#page5, but the command on Linux is sudo gem install sinatra haml to install both at the same time)</p>
<p>As a sanity check when you're done, run "irb" (interactive Ruby), and type each of the following commands (in order).  None of them should return errors.</p>
<ol>
<li>require 'rubygems'</li>
<li>require 'sinatra'</li>
<li>require 'haml'</li>
</ol>
<p>Okay, now on with the good stuff.</p>
<h2>First Steps</h2>
<p>Create a project directory, like first_app or something.  Create a file with the .rb extension, like hello.rb.  Open it up in your favorite (simple?) text editor (notepad++, gedit, TextMate).</p>
<p>Write the following:<br />
<script src="http://gist.github.com/284715.js?file=learning_ruby1.rb"></script></p>
<p>Let's take a step by step to figure out exactly what's going on in this file.  (list numbers correspond to line numbers)</p>
<ol>
<li>"require" simply loads up a library.  If it's already been loaded once, "require" will check to make sure it already loaded it and then do nothing.  "require"ing rubygems loads up that library into memory so we can load other gems, like...sinatra.  (Like Perl, Ruby has a number of "magic globals".  The load path, where require looks, is an array in $:).  Also, notice single-line comments are denoted by #.  Ruby doesn't really have multiline comments amazingly, but there is a hacky substitute...</li>
<li>Now that we have rubygems loaded, we can load sinatra!  Rubygems works by modifying that $: variable I mentioned above.  By loading the sinatra gem, the libraries full capabilities are now ready -- and most importantly, new methods are available in the main scope.</li>
<li></li>
<li>Ah, 'get' is our first method call, which we get after loading sinatra.  We're passing in one argument to it, "/hello", as well as a block.  Blocks have some tricky aspects to them, but think of them as simply a way of passing a chunk of code around (see <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29">closure</a> and <a href="http://ruby-doc.org/docs/ProgrammingRuby/html/tut_containers.html">Pragmatic Programmers</a> for more info).  Note that calling methods without the (optional) parentheses is generally considered against best practice, except in very simple cases, like this one.</li>
<li>As you may have guessed, this is a string.  But what is it doing?  The last line of any block or method is implicitly the return value.  When sinatra asks this block "what's your value", the block will hand up whatever's on the last line.  Of course, you can (and sometimes have to) be more explicit by prefixing your return value with the <strong>return</strong> keyword, like Java.</li>
</ol>
<p>If you're confused about what method calls generally look like, here's a little <a href="http://gist.github.com/284715#file_method_call_examples.rb">snippet</a> I prepared.</p>
<p>Okay, let's run this thing.  In your terminal, run `ruby hello.rb`.  The terminal will tell you where to point your browser: http://localhost:4567/.  Go there -- you should see "Hello, world!"</p>
<p>Okay, the basics are out of the way.  Let's get to the cookbook-style programs.  (be sure to note the filename, in the corner of the gist)</p>
<h2>Render a haml template and pass data to it</h2>
<p><script src="http://gist.github.com/284756.js"></script></p>
<h2>Render a layout</h2>
<p>Layouts minimize redundant code across multiple views.<br />
<script src="http://gist.github.com/284757.js"></script></p>
<h2>Adding javascript, css, images</h2>
<p>Plop those files into a /public subdirectory and you should be able to reference them like /my_css.css in your views.  See here: <a href="http://www.sinatrarb.com/intro.html">Sinatra Intro</a>.</p>
<h2>Posting a form and using that data</h2>
<p><script src="http://gist.github.com/284762.js"></script></p>
<h2>Preserving session information, like logins</h2>
<p>The Sinatra FAQ is pretty good about this one: <a href="http://www.sinatrarb.com/faq.html#sessions">http://www.sinatrarb.com/faq.html#sessions</a></p>
<p>I'm cutting this off a bit short, but hopefully this is enough to get you started.</p>
<p>EDIT: cont'd.</p>
<h2>Basic HTML/HAML stuff</h2>
<p><script src="http://gist.github.com/284781.js"></script></p>
<h2>A basic "sign in" application with link bar</h2>
<p>See this little app I made at <a href="http://github.com/nanodeath/SinatraHamlSignin">github</a>.  Click the Download Source button on that page, and/or browse around online.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2010/01/a-brief-introduction-to-ruby-sinatra-and-haml/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Destructors in Ruby?  Not quite&#8230;</title>
		<link>http://blog.maxaller.name/2009/12/destructors-in-ruby-not-quite/</link>
		<comments>http://blog.maxaller.name/2009/12/destructors-in-ruby-not-quite/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 00:54:35 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[destructor]]></category>
		<category><![CDATA[jruby]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=247</guid>
		<description><![CDATA[So I was curious to see how destructors work in Ruby, and...they don't.  Or rather, the method we do have, ObjectSpace.define_finalizer, is rather restrictive.  But it does leave a loophole -- the callback method receives an object_id.

If you're thinking this is a bad idea, you might be right -- this is just a [...]]]></description>
			<content:encoded><![CDATA[<p>So I was curious to see how destructors work in Ruby, and...they don't.  Or rather, the method we do have, ObjectSpace.define_finalizer, is rather restrictive.  But it does leave a loophole -- the callback method receives an object_id.<br />
<span id="more-247"></span><br />
If you're thinking this is a bad idea, you might be right -- this is just a proof of concept showing that it's possible.  Anyway, so the main restriction on define_finalizer callback is it can't refer to the object being freed.  If you try, the callback fails silently (except on JRuby 1.4.0! the exception propagates there).  This is because the callback executes <em>after</em> the object has been freed, so there is no "self".  Here's the proof of concept of one possible solution: maintain a map of object ids to resources: <a href="http://gist.github.com/255174" target="_blank">gist</a>.  The module, sample app, and output from Ruby 1.8(.7), 1.9, and JRuby 1.4.0 are also included.</p>
<p>Edit: apparently you can embed Gists.  Sweet.  Gist is below.</p>
<p><script src="http://gist.github.com/255174.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/12/destructors-in-ruby-not-quite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool free hosted tools for your Ruby webapp</title>
		<link>http://blog.maxaller.name/2009/11/cool-free-hosted-tools-for-your-ruby-webapp/</link>
		<comments>http://blog.maxaller.name/2009/11/cool-free-hosted-tools-for-your-ruby-webapp/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 02:15:51 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=211</guid>
		<description><![CDATA[Some of these are obvious (i.e. get exceptional, hoptoad), many of these aren't Ruby-specific, but I thought it might be nice to put all these in one place, at least for my sake.
Exception tracking
Get Exceptional limit: 1 app
Hoptoad limit: 1 project, 2 users
Bug tracking:
there's github, of course, if you're already using that...
16bugs limit: 1 project
I'm [...]]]></description>
			<content:encoded><![CDATA[<p>Some of these are obvious (i.e. get exceptional, hoptoad), many of these aren't Ruby-specific, but I thought it might be nice to put all these in one place, at least for my sake.</p>
<h2>Exception tracking</h2>
<p><a href="http://getexceptional.com/" target="_blank">Get Exceptional</a> limit: 1 app<br />
<a href="https://hoptoadapp.com/account/new" target="_blank">Hoptoad</a> limit: 1 project, 2 users</p>
<h2>Bug tracking:</h2>
<p>there's github, of course, if you're already using that...<br />
<a href="http://16bugs.com/pricing" target="_blank">16bugs</a> limit: 1 project<br />
I'm not including full hosting platforms, like Google Code here, but you could use those, too</p>
<h2>Email</h2>
<h3>One-off emails (i.e. signup)</h3>
<p><a href="http://sendgrid.com/pricing.html" target="_blank">Sendgrid</a> limit: 200 emails/day<br />
GMail allows 500 emails/day, but doesn't offer all the doodads that Sendgrid does</p>
<h3>Mailing list (i.e. newsletter)</h3>
<p><a href="http://www.mailchimp.com/pricing/" target="_blank">Mailchimp</a> limit: 500 subscribers, 3000 emails total a month</p>
<h2>Customer Support</h2>
<p><a href="http://www.snapabug.com/plans.jsp" target="_blank">SnapABug</a> limit: 10 reports/day<br />
<a href="https://uservoice.com/signup" target="_blank">uservoice</a> limit: 100 unique users/month<br />
<a href="http://getsatisfaction.com/features" target="_blank">GetSatisfaction</a> limit: 0 official reps, not hosted on your url</p>
<h2>Analytics</h2>
<p>There's a ton of options in this space, but I use:<br />
<a href="http://www.google.com/analytics/" target="_blank">Google Analytics</a> limit: no limits, because it's The Goog<br />
<a href="http://getclicky.com/" target="_blank">Clicky</a> limit: 1 website, 3000 hits/day</p>
<h2>Metrics, Monitoring</h2>
<p><a href="http://www.newrelic.com/get-RPM.html" target="_blank">New Relic</a> limit: no troubleshooting, optimization, etc</p>
<h2>User Avatar Hosting</h2>
<p><a href="http://www.gravatar.com/" target="_blank">Gravatar</a> limit: none</p>
<h2>Authentication</h2>
<h3>OpenID</h3>
<p><a href="https://rpxnow.com/get" target="_blank">RPX</a> limit: up to 6 providers, instead of 12</p>
<h2>Time tracking/invoicing</h2>
<p><a href="http://www.getharvest.com/pricing" target="_blank">Harvest</a> limit: 2 projects, 4 clients, 1 user</p>
<h2>Help desk thing</h2>
<p>Just kidding, couldn't find any free hosted help desk apps</p>
<p>Anything else I'm missing that every webapp needs?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/11/cool-free-hosted-tools-for-your-ruby-webapp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design pattern/flow for building a website</title>
		<link>http://blog.maxaller.name/2009/07/design-patternflow-for-building-a-website/</link>
		<comments>http://blog.maxaller.name/2009/07/design-patternflow-for-building-a-website/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 02:55:55 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[musing]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=155</guid>
		<description><![CDATA[So here's how I normally do things:

Do as much of the models as possible in this first pass, skipping validation but including schema stuff
Stick a couple things into the controllers that I think I'll need
Build out some of the views, giving them some basic styles
Revisit the models to add validation, helper methods
Build out the rest [...]]]></description>
			<content:encoded><![CDATA[<p>So here's how I normally do things:</p>
<ol>
<li>Do as much of the models as possible in this first pass, skipping validation but including schema stuff</li>
<li>Stick a couple things into the controllers that I think I'll need</li>
<li>Build out some of the views, giving them some basic styles</li>
<li>Revisit the models to add validation, helper methods</li>
<li>Build out the rest of the views, give them real styles</li>
<li>Muse about specs, then give up before starting</li>
<li>Put more stuff into the controllers</li>
<li>Iterate on random components until you're done</li>
</ol>
<p>Needless to say, I'm getting to the point where my lack of organization kills my mini-projects before I hit step 4, sometimes even sooner than that.  So I'm going to try a slightly more...conventional (or widely suggested, at least) approach:</p>
<ol>
<li>Create controllers with just enough information so that your pages will display.  No setting variables yet or other logic!</li>
<li>Fill out the views with as much HTML and fake data as you need.  Site have a sign-in page?  Leave a link to "force sign-in" the user that simply sets them to an authenticated state.  All it should do is set a session variable</li>
<li>Spec out the models.  Don't check for validation yet, just check for core functionality, i.e. there is a User table, the first user has a name of Foo and email of bar@baz.com, etc.</li>
<li>Fill out your model code so that the specs pass -- this includes migrations with sample data (these can be removed in a later migration).</li>
<li>Spec out your controllers/views.</li>
<li>Fill out your controllers/views so they pass specs.</li>
<li>Do the rest of the little things that need doing, like validation, error messaging, authentication, styling, etc.</li>
<li>Revel in having finished a project.</li>
</ol>
<p>Hopefully I'll get further than step 3 this way! I'm going to try to focus more on content/frontend instead of getting bogged down in the backend, and I want to actually write specs.</p>
<p>Any comments/suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/07/design-patternflow-for-building-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing: Ramastic, a skeleton for Ramaze</title>
		<link>http://blog.maxaller.name/2009/04/announcing-ramastic-a-skeleton-for-ramaze/</link>
		<comments>http://blog.maxaller.name/2009/04/announcing-ramastic-a-skeleton-for-ramaze/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 08:01:09 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ramaze]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=130</guid>
		<description><![CDATA[This is something I've been working on since slightly before my original call for suggestions a while back.  It's not done yet (I'd say it's somewhere around 75% done) but I want to get it out there before I totally lose steam on it.  There are a few inline styles I was planning on removing, [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I've been working on since slightly before my original call for suggestions a while back.  It's not done yet (I'd say it's somewhere around 75% done) but I want to get it out there before I totally lose steam on it.  There are a few inline styles I was planning on removing, but haven't gotten around to, so...apologies.  If you find it of use, please leave a comment.</p>
<p>And yes, it doesn't <em>look</em> that great.  But I'm expecting you to restyle everything anyway and possibly blow away the templates entirely in your instantiation of the skeleton.</p>
<p>Now, without further ado, here are features and screenshots:</p>
<h2>Features/requirements</h2>
<ul>
<li>Built on <a href="http://github.com/TwP/bones/tree/master" target="_blank">Bones</a></li>
<li>Edge Rack/Innate/Ramaze</li>
<li>Haml/Sass</li>
<li>Sequel + sqlite3</li>
<li>Blueprint CSS</li>
<li>jQuery, jQuery UI</li>
<li>OpenID (via <a href="http://www.rpxnow.com/" target="_blank">RPX</a>)</li>
<li><a href="http://github.com/adamwiggins/rest-client/tree/master" target="_blank">RestClient</a></li>
<li><a href="http://github.com/jnunemaker/crack/tree/master" target="_blank">Crack</a></li>
<li><a href="http://github.com/assaf/uuid/tree/master" target="_blank">UUID</a></li>
<li><a href="http://github.com/nakajima/rack-flash/tree/master" target="_blank">Rack-flash</a></li>
</ul>
<h2>Screenshots</h2>
<ul>
<li><a href="http://www.flickr.com/photos/7766113@N02/sets/72157616875804949/detail/" target="_blank">Individual pages</a></li>
<li><a href="http://www.flickr.com/photos/7766113@N02/sets/72157616875804949/show/" target="_blank">Slideshow</a></li>
</ul>
<h2>Repository</h2>
<p><a href="http://github.com/nanodeath/ramastic/tree/master" target="_blank">Github</a>.</p>
<p>Thanks for looking!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/04/announcing-ramastic-a-skeleton-for-ramaze/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ideas Needed for Mr. Bones skeleton built on Ramaze</title>
		<link>http://blog.maxaller.name/2009/04/ideas-needed-for-mr-bones-skeleton-built-on-ramaze/</link>
		<comments>http://blog.maxaller.name/2009/04/ideas-needed-for-mr-bones-skeleton-built-on-ramaze/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 08:00:50 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[idea]]></category>
		<category><![CDATA[ramaze]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=124</guid>
		<description><![CDATA[If I were to make a skeleton using Mr. Bones that was built on Ramaze, what would people like to see in it?  It's for my use first, but the community's use a close second if I can generalize it enough.  I was thinking along the lines of openid support, having a decent home page [...]]]></description>
			<content:encoded><![CDATA[<p>If I were to make a skeleton using <a href="http://codeforpeople.rubyforge.org/bones/" target="_blank">Mr. Bones</a> that was built on <a href="http://ramaze.net/" target="_blank">Ramaze</a>, what would people like to see in it?  It's for my use first, but the community's use a close second if I can generalize it enough.  I was thinking along the lines of openid support, having a decent home page and logged-in-user gateway, appropriate nav-bars, haml+sass, jquery+ui, etc....thoughts?  What do you find yourself doing at the beginning of every website project that you'd like to not have to repeat every time you start a project?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/04/ideas-needed-for-mr-bones-skeleton-built-on-ramaze/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>re-&quot;require&quot;-ing: how&#039;s the speed?</title>
		<link>http://blog.maxaller.name/2009/04/re-require-ing-hows-the-speed/</link>
		<comments>http://blog.maxaller.name/2009/04/re-require-ing-hows-the-speed/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:07:46 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=107</guid>
		<description><![CDATA[What this is about
So I like the design that, when you need a particular library in your code, you require it in right there in the method/class (JIT library-loading, so to speak), even if it means the require directive will get executed more than once.  Running through irb you can tell that calling require [...]]]></description>
			<content:encoded><![CDATA[<h1>What this is about</h1>
<p>So I like the design that, when you need a particular library in your code, you <em>require </em>it in right there in the method/class (JIT library-loading, so to speak), even if it means the <em>require </em>directive will get executed more than once.  Running through irb you can tell that calling require twice on the same library is usually much faster the second time, but how much faster?<br />
Read on for benchmarks!<br />
<span id="more-107"></span></p>
<h1>Benchmarks</h1>
<p>I came up with some simple benchmarks for a few gems below:</p>
<table>
<tr>
<th>Library</th>
<th>Initial load (seconds)</th>
<th>Subsequent loads (as multiplier of initial load)</th>
</tr>
<tr>
<td>open-uri</td>
<td>0.02</td>
<td>250-325</td>
</tr>
<tr>
<td>rack</td>
<td>0.08</td>
<td>2500-2900</td>
</tr>
<tr>
<td>rest_client</td>
<td>0.1</td>
<td>3000-4100</td>
</tr>
<tr>
<td>activerecord</td>
<td>0.9</td>
<td>270-300</td>
</tr>
<tr>
<td>activesupport</td>
<td>0.7</td>
<td>190-200</td>
</tr>
<tr>
<td>heroku</td>
<td>0.3</td>
<td>800-900</td>
</tr>
<tr>
<td>net/http</td>
<td>0.03</td>
<td>300-450</td>
</tr>
</table>
<p><strong>Example</strong>: heroku took 0.3 seconds to load the first time and subsequent attempts to load it were 800-900 times faster.<br />
<strong>Note</strong>: these are very ballpark figures.  I ran most of them 3-5 times and eyeballed the representative range.</p>
<h1>Commentary</h1>
<p>So what's the takeaway message?  One is unless you're concerned about performance, re-requiring isn't going to be what's putting a damper on the speed in your program.  On the other hand, you're probably well off not requiring activerecord or activesupport more than once, whereas requiring rest_client you can probably do as often as you want.</p>
<h1>Where's the code?</h1>
<p>Ah, right, the code.  Here's a <a href="http://www.pastie.org/435630">pastie</a> link for ya.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/04/re-require-ing-hows-the-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gotcha with Sequel and Association Caching</title>
		<link>http://blog.maxaller.name/2009/03/gotcha-with-sequel-and-association-caching/</link>
		<comments>http://blog.maxaller.name/2009/03/gotcha-with-sequel-and-association-caching/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 19:30:06 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ramaze]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sequel]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=73</guid>
		<description><![CDATA[One thing to remember with Sequel is that it caches associations -- for an hour, by default.  Normally this is good -- if I say my_model.my_associated_models twice in one request, I'd like that to be cached.  But at least with Ramaze, where you can access a variable that persists between requests (via session, [...]]]></description>
			<content:encoded><![CDATA[<p>One thing to remember with <a href="http://sequel.rubyforge.org/">Sequel</a> is that it caches associations -- for an hour, by default.  Normally this is good -- if I say my_model.my_associated_models twice in one request, I'd like that to be cached.  But at least with <a href="http://ramaze.net/">Ramaze</a>, where you can access a variable that persists between requests (via session, like session[:user]), you have to remember that associations on that session object get cached, too.  So what does that mean?  That means if you have a user view their posts (with session[:user].posts), and then they go make a post, and then they come back to view their posts again...the new post won't be in the list of posts!  So you have two basic options here, that I know of -- either a) manually kill the cache by putting session[:user].refresh on the action that alters the associations of session[:user], or b) put session[:user].refresh in a place that gets executed at the beginning of every request.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/03/gotcha-with-sequel-and-association-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby 1.9 and OpenSSL on Ubuntu</title>
		<link>http://blog.maxaller.name/2009/02/ruby-19-and-openssl-on-ubuntu/</link>
		<comments>http://blog.maxaller.name/2009/02/ruby-19-and-openssl-on-ubuntu/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 02:45:12 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[ruby 1.9.1]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.maxaller.name/?p=70</guid>
		<description><![CDATA[Having trouble getting openssl working on your Linux box and Ruby 1.9 (or 1.9.1, specifically)?  Here's something to give a try...

If you got your Ruby from a package manager, you have to get an extra package before reinstalling Ruby.  If you built from source (as is currently the only way to get Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble getting openssl working on your Linux box and Ruby 1.9 (or 1.9.1, specifically)?  Here's something to give a try...<br />
<span id="more-70"></span><br />
If you got your Ruby from a package manager, you have to get an extra package before reinstalling Ruby.  If you built from source (as is currently the only way to get Ruby 1.9.1 on Ubuntu) then you still have to get the extra package, but you don't have to reinstall Ruby.</p>
<h1>From the repository</h1>
<ol>
<li>sudo aptitude install libopenssl-ruby1.9</li>
<li>sudo aptitude install ruby1.9</li>
</ol>
<h1>From source</h1>
<ol>
<li>sudo aptitude install libopenssl-ruby1.9</li>
<li>cd ~/Downloads/ruby-1.9.1-p0/ext/openssl</li>
<li>ruby extconf.rb &#038;& make &#038;& sudo make install</li>
</ol>
<p>Note that if you haven't installed Ruby yet, you don't need to build the openssl gem manually -- I believe it will automatically get picked up during the regular Ruby 1.9.1 build process if all the dependencies are already there.</p>
<h1>Disclaimer...</h1>
<p>I'm not 100% sure these steps are accurate, so if they're not, please leave angry messages and I'll try to fix the directions.  Otherwise, hope they help!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2009/02/ruby-19-and-openssl-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Partial success!</title>
		<link>http://blog.maxaller.name/2008/06/partial-success/</link>
		<comments>http://blog.maxaller.name/2008/06/partial-success/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 16:58:03 +0000</pubDate>
		<dc:creator>Max</dc:creator>
				<category><![CDATA[games]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[distribution]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[rmagick]]></category>

		<guid isPermaLink="false">http://giftswappo.com/wordpress/?p=27</guid>
		<description><![CDATA[For a good chunk of yesterday, I was trying to ""port"" my exceedlingly simple Ruby application to Windows.  The hitch?  It uses Gosu (game engine), Chipmunk (physics engine), ImageMagick (popular graphics tool), and RMagick (wrapper for ImageMagick in Ruby).  With the help of RubyScript2Exe it almost, almost worked.  Gosu and Chipmunk [...]]]></description>
			<content:encoded><![CDATA[<p>For a good chunk of yesterday, I was trying to ""port"" my exceedlingly simple Ruby application to Windows.  The hitch?  It uses <a href="http://code.google.com/p/gosu/" target="_blank">Gosu</a> (game engine), <a href="http://wiki.slembcke.net/main/published/Chipmunk">Chipmunk</a> (physics engine), <a href="http://www.imagemagick.org/script/index.php" target="_blank">ImageMagick</a> (popular graphics tool), and <a href="http://rmagick.rubyforge.org/" target="_blank">RMagick</a> (wrapper for ImageMagick in Ruby).  With the help of RubyScript2Exe it almost, <em>almost</em> worked.  Gosu and Chipmunk had no problem, as they had no-strings-attached .so files and apparently were programmed well.  ImageMagick, despite trying to be a pain in the ass by making me include an extra dozen DLLs in my project folder, actually did end up working.  But RMagick...when moving the generated app to a new computer that didn't have ImageMagick installed freaked out with a weird "address not accessible" error or something.  After some fiddling I gave it up as a lost cause and dropped support for ImageMagick+RMagick.  The only reason they were there in the first place is because I wanted to load SVG files whenever possible, and possibly have some dynamic graphic generation, but...the former isn't that great anyway, and the latter will have to be done other ways, if at all.</p>
<p>So, yes, Ruby+Gosu+Chipmunk play just fine with RubyScript2Exe on both Windows and Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maxaller.name/2008/06/partial-success/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
