<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><description>Sliced Software strives to produce high quality, easy to use software.
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-74018-5");
pageTracker._trackPageview();
} catch(err) {}</description><title>Sliced Software</title><generator>Tumblr (3.0; @slicedsoftware)</generator><link>http://blog.slicedsoftware.com/</link><item><title>A better Array#rand</title><description>I &lt;a href="http://github.com/tsmango/rand/tree/master"&gt;released a new plugin today&lt;/a&gt;, called rand. This plugin expands on the &lt;code&gt;#rand&lt;/code&gt; method ActiveSupport adds to Array.

As background, the &lt;code&gt;rand&lt;/code&gt; method that Rails gives you, returns a single random value back from the array it’s called on.

&lt;code&gt;&lt;pre&gt;
&gt;&gt; [0, 1, 2, 3, 4].rand
=&gt; 2
&lt;/pre&gt;&lt;/code&gt;

This rand plugin overrides the &lt;code&gt;rand&lt;/code&gt; method so that you can pass in an integer value that corresponds to how many random values from the array you actually want back.

&lt;code&gt;&lt;pre&gt;
&gt;&gt; [0, 1, 2, 3, 4].rand(2)
=&gt; [4, 0]

&gt;&gt; [0, 1, 2, 3, 4].rand(4)
=&gt; [3, 0, 2, 1]
&lt;/pre&gt;&lt;/code&gt;

Additionally, the existing functionality is still in place so that if you don’t pass in a parameter, it still gives you back a single random value.</description><link>http://blog.slicedsoftware.com/post/134370830</link><guid>http://blog.slicedsoftware.com/post/134370830</guid><pubDate>Thu, 02 Jul 2009 17:28:22 -0400</pubDate></item><item><title>A better Rails.cache.increment</title><description>&lt;p&gt;I started working with &lt;code&gt;Rails.cache.increment&lt;/code&gt; and &lt;code&gt;Rails.cache.decrement&lt;/code&gt; today but quickly found that it didn’t work as I planned. For example, it seemed that when calling these methods they would return the previous value rather than the newly incremented value. Additionally, if you decided to read directly using &lt;code&gt;Rails.cache.read&lt;/code&gt; and the same key, it would always return nil despite being able to call &lt;code&gt;Rails.cache.increment&lt;/code&gt; again. Another annoying thing is that if you tried to increment a value that wasn’t in memcached, instead of defaulting to 1, it returned nil. Just all sorts of wacky stuff going on. I decided to just write my own.&lt;/p&gt;
&lt;p&gt;Update: &lt;a href="http://blog.slicedsoftware.com/post/130075743/a-better-rails-cache-increment"&gt;click through for the source&lt;/a&gt;.&lt;/p&gt; 
&lt;div id="gist-135972" class="gist"&gt;
	&lt;div class="gist-file"&gt;
		&lt;div class="gist-data gist-syntax"&gt;
			&lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;div class="line" id="LC1"&gt;&lt;span class="c1"&gt;# app/models/util/cache.rb&lt;/span&gt;&lt;/div&gt;&lt;div class="line" id="LC2"&gt; &lt;/div&gt;&lt;div class="line" id="LC3"&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Util&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Cache&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC4"&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC5"&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC6"&gt;      &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC7"&gt;    &lt;span class="k"&gt;else&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC8"&gt;      &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC9"&gt;    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC10"&gt;    &lt;/div&gt;&lt;div class="line" id="LC11"&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC12"&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC13"&gt;  &lt;/div&gt;&lt;div class="line" id="LC14"&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nc"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC15"&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC16"&gt;      &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC17"&gt;    &lt;span class="k"&gt;else&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC18"&gt;      &lt;span class="no"&gt;Rails&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC19"&gt;    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC20"&gt;    &lt;/div&gt;&lt;div class="line" id="LC21"&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC22"&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/div&gt;&lt;div class="line" id="LC23"&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;
		&lt;/div&gt;
    &lt;div class="gist-meta"&gt;
      &lt;a href="http://gist.github.com/raw/135972/65f127304b1032cd3e564aaf9c124318168768a3/gistfile1.rb" style="float: right;"&gt;view raw&lt;/a&gt;
      &lt;a href="http://gist.github.com/135972"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</description><link>http://blog.slicedsoftware.com/post/130075743</link><guid>http://blog.slicedsoftware.com/post/130075743</guid><pubDate>Thu, 25 Jun 2009 12:56:00 -0400</pubDate></item><item><title>An update about the LIRR app</title><description>&lt;p&gt;My custom, iPhone optimized webapp for interfacing with the LIRR scheduling system has been offline for a few weeks following a complete overhaul of the MTA’s LIRR scheduling software.&lt;/p&gt;

&lt;p&gt;Although their new scheduling system looks similar to the old site, it seems to be a complete rewrite. Unfortunately, this totally broke my app. I worked hard rewriting my parsing system to interface with the new site and I actually finished about half of it before I ran into a show stopping problem. I’d rather not say what the exact problem I ran into is, but I will say that I am still attempting to work around the issue.&lt;/p&gt;

&lt;p&gt;For now (long overdue, I know), I replaced my app with a message concerning the breaking of the app as well as a link out to the official MTA site.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/122729291</link><guid>http://blog.slicedsoftware.com/post/122729291</guid><pubDate>Sat, 13 Jun 2009 00:54:11 -0400</pubDate></item><item><title>My LIRR mobile app is busted because the mta.info site changed. I’ll try and fix it soon.</title><description>My LIRR mobile app is busted because the mta.info site changed. I’ll try and fix it soon.</description><link>http://blog.slicedsoftware.com/post/105475893</link><guid>http://blog.slicedsoftware.com/post/105475893</guid><pubDate>Sat, 09 May 2009 11:58:41 -0400</pubDate></item><item><title>Generating RSS Feeds in Rails</title><description>&lt;p&gt;It’s very easy to generate RSS feeds in Rails. In fact, if there is any possible benefit to having RSS feeds in your rails application, there is absolutely no reason you shouldn’t take a few minutes and set them up.&lt;/p&gt;

&lt;p&gt;These days, you just have to create a file like &lt;code&gt;:action.rss.builder&lt;/code&gt; to go along with your &lt;code&gt;:action.html.erb&lt;/code&gt; file. You don’t even need a &lt;code&gt;respond_to&lt;/code&gt; block in your action. As long as you have a route setup that knows how to handle additional formats, rails will automatically render your &lt;code&gt;.rss.builder&lt;/code&gt; file rather than your &lt;code&gt;.html.erb&lt;/code&gt; file if an &lt;code&gt;.rss&lt;/code&gt; extension is at the end of the url.&lt;/p&gt;

&lt;p&gt;For the basics of generating RSS feeds in rails, check out this &lt;a href="http://railscasts.com/episodes/87-generating-rss-feeds" target="railscasts"&gt;screencast&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you’d like to include media in your RSS feeds you should use the Yahoo media namespace xml definitions. To include this namespace in your feed you can use:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;
xml.rss(:version =&gt; "2.0", 
        "xmlns:media" =&gt; 'http://search.yahoo.com/mrss/')
&lt;/pre&gt;



&lt;p&gt;You can then generate a namespaced XML element like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;
xml.media(:content, :url =&gt; "some-image-url", 
            :type =&gt; "image/jpeg")
&lt;/pre&gt;</description><link>http://blog.slicedsoftware.com/post/91983824</link><guid>http://blog.slicedsoftware.com/post/91983824</guid><pubDate>Wed, 01 Apr 2009 15:11:05 -0400</pubDate></item><item><title>I Searched and Searched for searchd</title><description>&lt;p&gt;For a while now I’ve been working on a really long and detailed post comparing the different search systems available for rails projects. I just deleted the draft.&lt;/p&gt;

&lt;p&gt;I deleted it because I realized there really isn’t anything to compare. If you don’t &lt;strong&gt;need&lt;/strong&gt; live updated search results and you can live with an index that’s updated every 15 minutes or more, just use Sphinx. Sphinx with &lt;a href="http://ts.freelancing-gods.com/"&gt;Thinking Sphinx&lt;/a&gt; by &lt;a href="http://twitter.com/pat"&gt;Pat Allan&lt;/a&gt; is simply the most elegant, full featured and most importantly, &lt;strong&gt;stable&lt;/strong&gt; search system available for rails today. We’ve been using it over at &lt;a href="http://gawkk.com"&gt;gawkk&lt;/a&gt; for months now and haven’t had a single unhappy moment since we switched from Solr.&lt;/p&gt;

&lt;p&gt;SQL searches are slow. Ferret is crap in production. Solr is almost as unstable as Ferret in production and will bring down your database with unnecessary connections every time a damn object is instantiated. Sphinx is rock solid and fast as hell.&lt;/p&gt;

&lt;p&gt;I will only offer two lines of proof:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;
total 1133325 docs, 266596694 bytes
total 117.702 sec, 2265011.00 bytes/sec, 9628.75 docs/sec
&lt;/pre&gt;



&lt;p&gt;Over a million documents in 117 seconds. Try and do that with anything other than Sphinx. I dare you.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/86949087</link><guid>http://blog.slicedsoftware.com/post/86949087</guid><pubDate>Mon, 16 Mar 2009 10:51:57 -0400</pubDate></item><item><title>Back in Business</title><description>I was finally able to get my expired SSL certificate situation resolved. The &lt;a href="http://secure.slicedsoftware.com" target="store"&gt;store&lt;/a&gt; is back online. Sorry for any inconvenience!</description><link>http://blog.slicedsoftware.com/post/82876101</link><guid>http://blog.slicedsoftware.com/post/82876101</guid><pubDate>Mon, 02 Mar 2009 13:37:10 -0500</pubDate></item><item><title>A Simple .union Extension For ActiveRecord</title><description>&lt;p&gt;I just wrote and &lt;a href="http://github.com/tsmango/union/tree/master"&gt;released my first rails plugin&lt;/a&gt;, called union. It’s absurdly simple and fairly naive. I wrote this plugin so that I didn’t have to look at an ugly UNION I was running in a find_by_sql.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ActiveRecord::Base.union(parts, options = {})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The first parameter, parts, is an array of hashes. Each hash is what you would normally send into a single find and represents each SELECT. All parts will be unioned together.&lt;/p&gt;

&lt;p&gt;The second paramter, options, is a hash of remaining options to be applied to the UNION of the parts (ie: order, limit, offset).&lt;/p&gt;

&lt;p&gt;A simple (and useless) example would be:&lt;br/&gt;&lt;code&gt;User.union([{:conditions =&gt; ['name = ?', 'tom']}, {:conditions =&gt; ['name = ?', 'gary']}], {:order =&gt; 'created_at'})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This example produces the following SQL:&lt;br/&gt;&lt;code&gt;(SELECT * FROM `users` WHERE (name = 'tom')) UNION (SELECT * FROM `users` WHERE (name = 'gary')) ORDER BY created_at;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Essentially you can do any union, but it’s up to you to make sure you don’t pass the wrong stuff in because it’s a pretty dumb implementation.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/82183997</link><guid>http://blog.slicedsoftware.com/post/82183997</guid><pubDate>Fri, 27 Feb 2009 23:09:57 -0500</pubDate></item><item><title>Rake That Data into A Pile of YAML</title><description>&lt;p&gt;My friend, &lt;a href="http://twitter.com/milaniliev"&gt;@milaniliev&lt;/a&gt;, pointed me to his very useful &lt;code&gt;db:fixtures:dump&lt;/code&gt; &lt;a href="http://github.com/milaniliev/db_fixtures_dump_enhanced/tree/master"&gt;rake task&lt;/a&gt; that allows for selectively dumping data from your database directly into YAML fixtures.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; It looks like this was also &lt;a href="http://github.com/topfunky/ar_fixtures/tree/master"&gt;tackled in a different way&lt;/a&gt; by &lt;a href="http://github.com/topfunky"&gt;topfunky&lt;/a&gt;. He seems to have added a &lt;code&gt;.to_fixture&lt;/code&gt; method to &lt;code&gt;ActiveRecord::Base&lt;/code&gt;. I don’t think it accepts a &lt;code&gt;WHERE&lt;/code&gt; clause, but that is probably easily patched.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/82019971</link><guid>http://blog.slicedsoftware.com/post/82019971</guid><pubDate>Fri, 27 Feb 2009 10:35:00 -0500</pubDate></item><item><title>Nested Object Forms in Rails 2.3</title><description>I’ve just found &lt;a target="_blank" href="http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes"&gt;this great overview&lt;/a&gt; of the Nested Object Forms feature that’s new in Rails 2.3. When I first read about nested forms, I didn’t really see the huge benefit, but while working on a new side project, I realized how useful they are. If you don’t already know how this feature works, take a few minutes and read through the blog post above to get an idea.</description><link>http://blog.slicedsoftware.com/post/81926361</link><guid>http://blog.slicedsoftware.com/post/81926361</guid><pubDate>Fri, 27 Feb 2009 01:31:03 -0500</pubDate></item><item><title>Safari and Gmail Just Won't Play Nice</title><description>&lt;p style="text-align:center;"&gt;&lt;a href="http://farm4.static.flickr.com/3621/3312371282_23191c5283_o.png" target="_blank"&gt;&lt;img src="http://farm4.static.flickr.com/3447/3311541261_7175961c1a_o.png" width="420" height="325"/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’ve been having an issue lately with Safari and Gmail not playing nice. I leave Gmail open the whole day and every few hours it stops working. If you try and refresh the site, you’re given a Bad Request 400 error. The only option I had found to fix the problem is to reset Safari, clearing out all cookies and cache. It’s extremely annoying that the only way to get Gmail working again is to log yourself out of every site you’re logged into and close the browser with all of your open windows.&lt;/p&gt;
&lt;p&gt;While trying to find some answers for this problem that’s been happening for the past month or so on Safari 3 and now persists to the Safari 4 beta, I came across a &lt;a href="http://groups.google.com/group/Gmail-Help-Discussion/search?group=Gmail-Help-Discussion&amp;q=safari+bad+request&amp;qt_g=Search+this+group" target="_blank"&gt;Google Groups post&lt;/a&gt; that mentioned a huge number of GMAIL_STAT_* cookies being created near the time Gmail stops working. Sure enough, removing just these cookies and reloading Gmail works fine. But let’s be honest, this is a band-aid and extremely annoying to have to stop what you’re doing to fix it. Especially when you don’t realize Gmail stops working until you click send on a long email you just wrote. Now you have to remove those cookies before sending your email.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/81780185</link><guid>http://blog.slicedsoftware.com/post/81780185</guid><pubDate>Thu, 26 Feb 2009 14:53:00 -0500</pubDate></item><item><title>Expired SSL Certificate</title><description>The SSL certificate expired for secure.slicedsoftware.com. I’m trying to get a new one but for some reason, they need verification of where my company resides and they are saying the document I provided is too old. Will hopefully be back in working order by the end of the week. Sorry for any inconvenience.</description><link>http://blog.slicedsoftware.com/post/81131704</link><guid>http://blog.slicedsoftware.com/post/81131704</guid><pubDate>Tue, 24 Feb 2009 12:51:53 -0500</pubDate></item><item><title>My Problem With before_filters</title><description>&lt;p&gt;Although I think using before_filters is sometimes appropriate, I often find that it reduces the readability of the code. I don’t mean that before_filters clutter up the code, because it obviously doesn’t. Using a before_filter keeps your action code nice and tidy. The problem I have with it is that if someone else looks at your code, or if you look at some of your old code, you may not realize that something is happening before the action you’re looking at.&lt;/p&gt;
&lt;p&gt;For example, if you were to use a before filter and only make some of your actions in a controller require a logged in user, when scanning through your code you won’t know right away which actions require login and which don’t. However, if you were to do something like:&lt;/p&gt;

&lt;pre&gt;def some_action
 return no_access unless user_logged_in?
 # your action's code
end&lt;/pre&gt;
&lt;p&gt;Now, when you read this action, you know right away that a user must be logged in to use it.&lt;/p&gt;
&lt;p&gt;Also note, no_access can be a method in your application controller that simply routes the user back to where they came from with a note that they must be logged in to do that. And, user_logged_in? would be another method that simply checks if the user is logged in or not.&lt;/p&gt;
&lt;p&gt;You can take this a step further if you have certain actions that don’t need a logged in user, others that need a logged in user and still others that need a logged in user who is also an administrator.&lt;/p&gt;

&lt;pre&gt;def some_action
 return no_access unless user_can_administer?
 # your action's code
end&lt;/pre&gt;
&lt;p&gt;I realize a lot of people simply group all of their administrative actions together so that they can lock down entire controllers, but I don’t always find that the best way of doing things.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/78022992</link><guid>http://blog.slicedsoftware.com/post/78022992</guid><pubDate>Fri, 13 Feb 2009 09:37:00 -0500</pubDate></item><item><title>MySQL Isn't Very Sensitive</title><description>&lt;p&gt;When writing SQL conditions in MySQL, using an equal sign is case insensitive. For example:&lt;/p&gt;

&lt;pre&gt;SELECT * FROM comments WHERE thread_id = '2A';&lt;/pre&gt;
&lt;p&gt;Will return results where thread_id actually equals 2a and 2A. To make this case sensitive, you can use LIKE BINARY:&lt;/p&gt;

&lt;pre&gt;SELECT * FROM comments WHERE thread_id LIKE BINARY '2A';&lt;/pre&gt;
&lt;p&gt;But what happens when you want to use IN? For example:&lt;/p&gt;

&lt;pre&gt;SELECT * FROM comments &lt;br/&gt;WHERE thread_id IN ('2A', '2B', '2C');&lt;/pre&gt;
&lt;p&gt;This would return where thread_id actually equals 2a, 2A, 2b, 2B, 2c and 2C. This is no good because I need it to be case sensitive. You could do something like:&lt;/p&gt;

&lt;pre&gt;SELECT * FROM comments &lt;br/&gt;WHERE thread_id LIKE BINARY '2A' &lt;br/&gt;OR thread_id LIKE BINARY '2B' &lt;br/&gt;OR thread_id LIKE BINARY '2C';&lt;/pre&gt;
&lt;p&gt;But this is a problem when you want dynamically built this query using an ActiveRecord find method like:&lt;/p&gt;

&lt;pre&gt;ids = ['2A', '2B', '2C']
Comment.find(:all, :conditions =&gt; ['thread_id IN (?)', ids])&lt;/pre&gt;
&lt;p&gt;I haven’t found a solution yet, but I hope to soon.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/77554324</link><guid>http://blog.slicedsoftware.com/post/77554324</guid><pubDate>Wed, 11 Feb 2009 16:14:50 -0500</pubDate></item><item><title>A Fresh Start</title><description>&lt;p&gt;I picked up a 320GB 7200RPM hard drive for my MacBook Pro and rather than cloning my current drive, I figured I’d take the opportunity to start fresh.&lt;/p&gt;
&lt;p&gt;Starting fresh is kind of scary when you’re a software engineer because you have to get your environment setup just the way you like it before you can really get started on work again. While I’m waiting for the last of my files to back up, I thought it’d be nice to detail how I prepare for a fresh operating system install.&lt;/p&gt;
&lt;p&gt;I have a Western Digital 1.5TB USB hard drive connected to my machine at all times running Time Machine backups. While I feel this keeps me safe for day to day operations, when I do a fresh install I always do a manual backup of the things I need. You can never have too many backups.&lt;/p&gt;
&lt;p&gt;First I copy over my main directories in my home directory. OS X makes this easy. I backup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;~/Desktop&lt;/li&gt;
&lt;li&gt;~/Documents&lt;/li&gt;
&lt;li&gt;~/Downloads&lt;/li&gt;
&lt;li&gt;~/Library&lt;/li&gt;
&lt;li&gt;~/Movies&lt;/li&gt;
&lt;li&gt;~/Music&lt;/li&gt;
&lt;li&gt;~/Pictures&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I then export important data from applications to make it easy to import in my fresh install. I export from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Address Book&lt;/li&gt;
&lt;li&gt;Camino (Bookmarks)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next, I take various lists of things I have installed and screenshots of my current setup.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I run &lt;code&gt;ls -la&lt;/code&gt; in my /Applications directory and copy the output to a text file&lt;/li&gt;
&lt;li&gt;I run &lt;code&gt;gem list&lt;/code&gt; and copy that to a text file&lt;/li&gt;
&lt;li&gt;I run &lt;code&gt;which&lt;/code&gt; on various binaries like gem, ruby, rails to ensure my paths are setup properly when I reinstall&lt;/li&gt;
&lt;li&gt;I take a screenshot of my Dock&lt;/li&gt;
&lt;li&gt;I take a screenshot of my Menubar&lt;/li&gt;
&lt;li&gt;I take a screenshot of System Preferences&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Stragglers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I copy my ~/.ssh directory so that I have my ssh keys&lt;/li&gt;
&lt;li&gt;I copy various config files such as ~/.gitconfig&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I then copy my ~/Development directory which contains things like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;~/Development/assets&lt;/li&gt;
&lt;li&gt;~/Development/cocoa&lt;/li&gt;
&lt;li&gt;~/Development/iphone&lt;/li&gt;
&lt;li&gt;~/Development/java&lt;/li&gt;
&lt;li&gt;~/Development/rails&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of my ~/Development/ directories has directories like ./documentation/ and ./projects/.&lt;/p&gt;
&lt;p&gt;Lastly, I make backups of all of my development PostgreSQL and MySQL databases using pgAdmin and MySQL Administrator, respectively.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/70586377</link><guid>http://blog.slicedsoftware.com/post/70586377</guid><pubDate>Wed, 14 Jan 2009 22:59:00 -0500</pubDate></item><item><title>High Capacity Color Barcodes</title><description>&lt;p&gt;I just read an &lt;a href="http://www.techcrunch.com/2009/01/08/microsoft-releases-tag-its-second-iphone-application/"&gt;article&lt;/a&gt; about Microsoft’s new iPhone application, Microsoft Tag, that utilizes something they developed called &lt;a href="http://en.wikipedia.org/wiki/High_Capacity_Color_Barcode"&gt;High Capacity Color Barcodes&lt;/a&gt;. Although it’s a great idea to use color to increase the amount of data that can be stored in the barcode while decreasing the size of the barcode itself, it must shorten the life of the barcode.&lt;/p&gt;
&lt;p&gt;Before going to work fulltime on &lt;a href="http://www.gawkk.com"&gt;Gawkk&lt;/a&gt;, I worked at a company on Long Island. I was a software engineer there, but the company itself did a lot of work for the military. We made things like swivel stands for missiles and a mechanism that deflated the tires slightly of large aircraft before they landed. In the last year I worked there, we started affixing 2D barcodes to our parts so that if something failed in the field we would have all of the relevant data including when it was originally built.&lt;/p&gt;
&lt;p&gt;Now, these barcodes were printed on a special material and had to stay attached to the part under extreme conditions (hundreds of degrees, if I remember correctly), so it’s slightly different, but what about one of these High Capacity Color Barcodes stuck to the back of some electronic device? Eventually, the colors will start to fade and these barcodes will fail. It’s a lot easier to distinguish faded black with white than it is faded colors with other faded colors.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/69166786</link><guid>http://blog.slicedsoftware.com/post/69166786</guid><pubDate>Thu, 08 Jan 2009 10:24:00 -0500</pubDate></item><item><title>Go to File...</title><description>&lt;p&gt;I’m still using &lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt; these days despite being frustrated with a lot of things including the complete lack of forward progress and no information about TextMate 2. I’ve thought about switching to &lt;code&gt;vim&lt;/code&gt;, especially after reading a &lt;a href="http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim"&gt;great article&lt;/a&gt; by Jamis Buck. I’ve always loved using &lt;code&gt;vi&lt;/code&gt; and I get by, but to be honest I just don’t think I’m good enough yet to use it as my every day editor for work I actually have to get done. Especially considering I would be using &lt;code&gt;vim&lt;/code&gt; to work with a project and not just &lt;code&gt;vi&lt;/code&gt; editing a single file.&lt;/p&gt;
&lt;p&gt;Regardless, one of TextMate’s biggest strengths is its &lt;code&gt;Go to File&lt;/code&gt; window. Fuzzy search across all your file names. It’s dead simple and extremely fast. The only problem is that a lot of my views have the same name; &lt;code&gt;index.rhtml&lt;/code&gt;, for example. I’d love to see the &lt;code&gt;Go to File&lt;/code&gt; window support an escape key that toggles the matching to the containing directory they show in gray after the filename. For example, you type index and then you hit &lt;code&gt;CMD-OPTION&lt;/code&gt; and you start typing the directory name to filter on the matches already showing.&lt;/p&gt;
&lt;p&gt;I wonder if this is possible with a plugin without rewriting the entire window.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/66581812</link><guid>http://blog.slicedsoftware.com/post/66581812</guid><pubDate>Wed, 24 Dec 2008 08:28:33 -0500</pubDate></item><item><title>Working From Home</title><description>&lt;p&gt;It’s incredible how much you can get done when working from home. Before I went full time at Gawkk over a year ago, I had a software engineering job at a regular company. I was in an office. People would call all day. People would stop by. I had to physically go to meetings. It really affected productivity.&lt;/p&gt;
&lt;p&gt;When I started working from home, I thought that it would be tough.&lt;/p&gt;
&lt;blockquote&gt;“I’ll really need to try and concentrate. There will just be so many distractions.”&lt;/blockquote&gt;
&lt;p&gt;I mean, it’s what everyone was telling me.&lt;/p&gt;
&lt;blockquote&gt;“You’re going to work from home? Wow, I could never do that. I’d never get anything done!”&lt;/blockquote&gt;
&lt;p&gt;But really, what distractions are there? You don’t have to stop what you’re working on to make it to a meeting. You don’t have to answer the phone calls from people who don’t want to wait for a response from an email. You also don’t have people dropping by to just shoot the breeze.&lt;/p&gt;
&lt;p&gt;Once you realize that 9 to 5 isn’t when you have to be productive. Everything else falls into place. Sure, I like to generally be at my desk before 9 and I try and remember to pull myself away after 5 (although I can get sucked into my code), but if I was up late the night before and feel better starting at 10, it’s not that big of a deal. The key is working when you are productive. There is no sense at sitting at your desk doing nothing from 9 to 10 if on that particular morning you feel like crap. Work when you are productive and the distraction-less environment will help facilitate that.&lt;/p&gt;
&lt;p&gt;It probably also helps if you actually enjoy doing what you do.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/64486283</link><guid>http://blog.slicedsoftware.com/post/64486283</guid><pubDate>Fri, 12 Dec 2008 09:50:31 -0500</pubDate></item><item><title>Customer Support</title><description>&lt;p&gt;A few days ago, I ordered a pair of snowboard pants from &lt;a href="http://www.the-house.com"&gt;The House&lt;/a&gt;. When they showed up last night they were the wrong size. Further investigation revealed that the drop down containing sizes on their website listed them wrong. The size I selected was not the size they thought I ordered.&lt;/p&gt;
&lt;p&gt;Luckily, The House has great customer support. I called the toll free number and a woman answered immediately. No automated menus. She answered, I said I was sent the wrong size, she transferred me to the right person.&lt;/p&gt;
&lt;p&gt;The person who I was transferred to helped me find a different pair of pants. Discounted them. Ensured they would ship the same day and gave me free shipping on them. In the box will be the return shipping labels for the pants that were the wrong size so that I won’t have to pay shipping to send those back.&lt;/p&gt;
&lt;p&gt;There was only one painful part of the experience. The on hold music was just a single song on loop. &lt;a href="http://www.gawkk.com/james-brown-i-feel-good-http-leplubo-nn-cx-video-izle-indir-download/discuss"&gt;James Brown’s “I Feel Good”&lt;/a&gt;.&lt;/p&gt;</description><link>http://blog.slicedsoftware.com/post/64111939</link><guid>http://blog.slicedsoftware.com/post/64111939</guid><pubDate>Wed, 10 Dec 2008 10:54:00 -0500</pubDate></item><item><title>The man who would be Sergey</title><description>&lt;a href="http://news.cnet.com/The-man-who-would-be-Sergey/2010-1032_3-6082323.html"&gt;The man who would be Sergey&lt;/a&gt;: Just stumbled across this article about Gary (&lt;a href="http://www.gawkk.com"&gt;Gawkk&lt;/a&gt;’s fearless leader). In all of the times we spoke about Direct Hit, I never knew that the ranking algorithm worked that way. It’s brilliant.</description><link>http://blog.slicedsoftware.com/post/64003325</link><guid>http://blog.slicedsoftware.com/post/64003325</guid><pubDate>Tue, 09 Dec 2008 20:47:19 -0500</pubDate></item></channel></rss>
