<?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>blog.layer2.org</title>
	<atom:link href="http://blog.layer2.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.layer2.org</link>
	<description>A technical blog</description>
	<lastBuildDate>Thu, 31 Dec 2009 00:27:49 +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>How to replace your iPod Touch 2nd gen digitizer / outer glass and bezel frame</title>
		<link>http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/</link>
		<comments>http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/#comments</comments>
		<pubDate>Sun, 31 May 2009 04:21:57 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[ipod touch]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/?p=71</guid>
		<description><![CDATA[If you&#8217;re like me, you recently had a small accident with your iPod touch&#8230; you broke the screen! In our case, the iPod had slipped from a pants pocket into the recliner. It got caught between a few internal recliner arms and pinched to the point where the upper portion of the glass was broken.
In [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me, you recently had a small accident with your iPod touch&#8230; you broke the screen! In our case, the iPod had slipped from a pants pocket into the recliner. It got caught between a few internal recliner arms and pinched to the point where the upper portion of the glass was broken.</p>

<a href='http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/p5300289-modified-in-gimp-image-editor/' title='broken ipod touch'><img width="150" height="150" src="http://blog.layer2.org/wp-content/uploads/2009/05/p5300289-modified-in-gimp-image-editor-150x150.jpg" class="attachment-thumbnail" alt="" title="broken ipod touch" /></a>
<a href='http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/p5300295-modified-in-gimp-image-editor/' title='digitizer and bezel together'><img width="150" height="150" src="http://blog.layer2.org/wp-content/uploads/2009/05/p5300295-modified-in-gimp-image-editor-150x150.jpg" class="attachment-thumbnail" alt="" title="digitizer and bezel together" /></a>
<a href='http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/p5300293-modified-in-gimp-image-editor/' title='button seat'><img width="150" height="150" src="http://blog.layer2.org/wp-content/uploads/2009/05/p5300293-modified-in-gimp-image-editor-150x150.jpg" class="attachment-thumbnail" alt="" title="button seat" /></a>
<a href='http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/p5300297-modified-in-gimp-image-editor/' title='bare 2nd gen ipod touch'><img width="150" height="150" src="http://blog.layer2.org/wp-content/uploads/2009/05/p5300297-modified-in-gimp-image-editor-150x150.jpg" class="attachment-thumbnail" alt="" title="bare 2nd gen ipod touch" /></a>
<a href='http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/p5300298-modified-in-gimp-image-editor/' title='bezel frame without digitizer'><img width="150" height="150" src="http://blog.layer2.org/wp-content/uploads/2009/05/p5300298-modified-in-gimp-image-editor-150x150.jpg" class="attachment-thumbnail" alt="" title="bezel frame without digitizer" /></a>

<p>In the case where your outer glass (called the digitizer) is broken but the LCD underneath is still perfect, you can replace the glass for $50-$75 in parts and tools. If you just want someone to fix it for you, it&#8217;ll run $100+ for a 2nd gen from a <a href="http://www.ipodjuice.com/apple-ipod-touch-repair.htm">parts</a> <a href="http://www.rapidrepair.com/shop/screen-ipod-repair.html">store</a>. Much better than the $200+ I&#8217;ve heard about from the Apple store.</p>
<p>I found a few video tutorials and other articles about replacing parts on the iPod Touch 2nd gen, but nobody described a few issues that I ran into. First, a few good resources:</p>
<ul>
<li>Video that shows how to take apart the touch &#8211; <a href="http://www.youtube.com/watch?v=iPyN9yLEH9o">http://www.youtube.com/watch?v=iPyN9yLEH9o</a></li>
<li>Article with pictures that shows the entire iPod Touch breakdown &#8211; <a href="http://www.rapidrepair.com/guides/ipodtouch2g/ipodtouch2grepairguide.html">http://www.rapidrepair.com/guides/ipodtouch2g/ipodtouch2grepairguide.html</a></li>
</ul>
<h1>Things you&#8217;ll need</h1>
<ol>
<li>Plastic opening tools (these often accompany digitizer replacements on ebay)</li>
<li>A new digitizer. Available from eBay or a parts shop like http://www.pdaparts.com</li>
<li>Most likely you&#8217;ll also need a new front bezel or frame. For best results, get one with rubber gasket around the edge and double-sided tape on the inside</li>
<li>A thin knife with a strong blade (mostly optional)</li>
<li>A small pair of wire cutters (optional)</li>
<li>Intermediate skill if you buy a new front bezel / frame, and advanced skill if you salvage the old one . I took the easier route and bought a new front bezel. Either way, you still need the button seat from the old bezel.</li>
</ol>
<p><strong>Unfortunately most of the part stores and eBay sellers that advertise replacement digitizers for 2nd generation iPod touches don&#8217;t mention that the front bezel is extremely difficult to remove without damage.</strong> The front bezel and digitizer are attached through buttons around the digitizer edges. My broken digitizer was also glued down to the front bezel. Additionally, there is a thin rubber gasket that runs around the length of the digitizer. Even with careful prying with my fingers and plastic tools I tore the gasket in several places.</p>
<h1>Take it apart</h1>
<p>The youtube video linked above gives very good information about the location of the clips and how to pull the digitizer off without damaging it. Be careful that you press the plastic tool on the outside of the rubber gasket (closest to the metal backing) rather than the inside of the rubber gasket (closest to the actual glass). This is especially important if you don&#8217;t want to damage the bezel. I found that I accidentally separated the bezel from the digitizer because I didn&#8217;t realize the distinction.</p>
<p>Once you have the digitizer off, you can put the rest of the iPod aside and focus on separating the glass from the bezel. It is a pain, and assuming your digitizer is cracked, is likely to drop pieces of glass. You only need to separate the glass from the lower portion of the bezel (near the home button).</p>
<p>The goal is the grab the home button and its seat. I haven&#8217;t seen any parts stores that sell the seat, so don&#8217;t mess it up! The button just fails out.</p>
<p>The edges around the button seat are raised. After bending the plastic various ways, I found the easiest way to retrieve it is to use a small wire cutter and snip off the edges to the right and left, removing the raised edges. This will allow you to take a small, thin knife and slide it under the tiny plastic buttons that hold it on. Keep the knife away from the center of the button seat because that might sever the electrical connection.</p>
<h1>Attach the new digitizer and bezel</h1>
<p>Since I didn&#8217;t know that I needed a bezel to do the replacement, I just ordered it tonight. I will post more information and pictures when the part arrives.</p>
<h1>Slide in the new assembly</h1>
<p>After you have the new digitizer and bezel together, complete with home button, you can put it back together! Don&#8217;t forget to attach the digitizer ribbon to the rest of the iPod.</p>
<p>Thats it! Post a comment about how your replacement goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2009/05/31/how-to-replace-your-ipod-touch-2nd-gen-digitizer-outer-glass-and-frame/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Remember Basic Authentication passwords in Firefox without Roboform</title>
		<link>http://blog.layer2.org/2008/02/09/remember-basic-authentication-passwords-in-firefox-without-roboform/</link>
		<comments>http://blog.layer2.org/2008/02/09/remember-basic-authentication-passwords-in-firefox-without-roboform/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 21:26:53 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2008/02/09/remember-basic-authentication-passwords-in-firefox-without-roboform/</guid>
		<description><![CDATA[If you like to save your passwords, you probably know that its a pain to save Basic Authentication passwords in Firefox. Basic Authentication comes up in a new window saying &#8220;Enter username and password for &#8230;&#8221; and looks like this:

There is no &#8217;save this password&#8217; button. If you access this site every day, and close [...]]]></description>
			<content:encoded><![CDATA[<p>If you like to save your passwords, you probably know that its a pain to save Basic Authentication passwords in Firefox. Basic Authentication comes up in a new window saying &#8220;Enter username and password for &#8230;&#8221; and looks like this:</p>
<p><a href="http://blog.layer2.org/wp-content/uploads/2008/02/prompt.png" title="Prompt"><img src="http://blog.layer2.org/wp-content/uploads/2008/02/prompt.png" alt="Prompt" /></a></p>
<p>There is no &#8217;save this password&#8217; button. If you access this site every day, and close Firefox between sessions, you&#8217;d have to type your username/password every time. No longer!</p>
<p>It is possible, though seemingly undocumented, to save the username/password inside the HTTP URL (this long has been done with FTP). For example:</p>
<p>http://user:password@layer2.org</p>
<p><a href="http://blog.layer2.org/wp-content/uploads/2008/02/bookmark.png" title="bookmark"><img src="http://blog.layer2.org/wp-content/uploads/2008/02/bookmark.png" alt="bookmark" /></a></p>
<p>Just put this into a bookmark, and you have an easy way to access your password-protected site. Of course, if the password is actually sensitive, you might think twice about saving it in plain text as a bookmark!</p>
<p>The only annoying thing that happens using this method is that you&#8217;ll see this prompt the <em>first</em> time you try to log in (for any given Firefox session):</p>
<p><a href="http://blog.layer2.org/wp-content/uploads/2008/02/log_in.png" title="Log in"><img src="http://blog.layer2.org/wp-content/uploads/2008/02/log_in.png" alt="Log in" /></a></p>
<p>Just press OK. While not perfect, this is a heck of a lot easier to deal with than entering the password each and every time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2008/02/09/remember-basic-authentication-passwords-in-firefox-without-roboform/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails migration with a list of all United States</title>
		<link>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/</link>
		<comments>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 01:58:09 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/</guid>
		<description><![CDATA[How many times have you created web applications that use addresses? Since I felt like I wasted the entire 10 minutes it took me to type out this state list, I figured I&#8217;d share it with everyone so that their time wasn&#8217;t equally wasted. Enjoy.
Run this command:
ruby script/generate model State
And put this in db/migrate/XXX_create_states.rb:

class CreateStates [...]]]></description>
			<content:encoded><![CDATA[<p>How many times have you created web applications that use addresses? Since I felt like I wasted the entire 10 minutes it took me to type out this state list, I figured I&#8217;d share it with everyone so that their time wasn&#8217;t equally wasted. Enjoy.</p>
<p>Run this command:</p>
<pre>ruby script/generate model State</pre>
<p>And put this in db/migrate/XXX_create_states.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateStates &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:states</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:abbreviation</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Alabama'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Alaska'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AK'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Arizona'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AZ'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Arkansas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AR'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'California'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Colorado'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CO'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Connecticut'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Delaware'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'DE'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'District of Columbia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'DC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Florida'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'FL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Georgia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'GA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Hawaii'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'HI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Idaho'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ID'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Illinois'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Indiana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Iowa'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Kansas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'KS'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Kentucky'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'KY'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Louisiana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'LA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Maine'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ME'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Maryland'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MD'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Massachutsetts'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Michigan'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Minnesota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Mississippi'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MS'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Missouri'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MO'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Montana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Nebraska'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NE'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Nevada'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NV'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Hampshire'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NH'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Jersey'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NJ'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Mexico'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NM'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New York'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NY'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'North Carolina'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'North Dakota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ND'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Ohio'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OH'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Oklahoma'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OK'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Oregon'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OR'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Pennsylvania'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'PA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Rhode Island'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'RI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'South Carolina'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'SC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'South Dakota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'SD'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Tennessee'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'TN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Texas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'TX'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Utah'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'UT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Vermont'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'VT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Virginia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'VA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Washington'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'West Virginia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WV'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Wisconsin'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Wyoming'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WY'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:states</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Use ffmpeg to extract first image out of FLV</title>
		<link>http://blog.layer2.org/2007/12/03/use-ffmpeg-to-extract-first-image-out-of-flv/</link>
		<comments>http://blog.layer2.org/2007/12/03/use-ffmpeg-to-extract-first-image-out-of-flv/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 05:10:48 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/12/03/use-ffmpeg-to-extract-first-image-out-of-flv/</guid>
		<description><![CDATA[I found at least one other person trying to find a way to extract a JPG snapshot out of a flash video using ffmpeg.
The above article suggests using ffmpeg to extract a PNG, and then convert that to a JPG (since the JPG will be much smaller). Instead, just use the correct arguments to ffmpeg:

ffmpeg [...]]]></description>
			<content:encoded><![CDATA[<p>I found at least <a href="http://www.db75.com/blog/archives/000176.html">one other person</a> trying to find a way to <a href="http://www.5etdemi.com/blog/archives/2005/12/extracting-a-jpeg-snapshot-from-an-flv-file/">extract a JPG snapshot out of a flash video using ffmpeg</a>.</p>
<p>The above article suggests using ffmpeg to extract a PNG, and then convert that to a JPG (since the JPG will be much smaller). Instead, just use the correct arguments to ffmpeg:</p>
<pre>
ffmpeg -i movie.flv-vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 movie.jpg
</pre>
<p>With <strong>-vcodec mjpeg</strong> the important argument.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/12/03/use-ffmpeg-to-extract-first-image-out-of-flv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails&#8217; attachment_fu, :thumbnail_class and you</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/</link>
		<comments>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 01:56:23 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/</guid>
		<description><![CDATA[I was having a bit of trouble with attachment_fu that took a while to figure out, so I thought I&#8217;d post my solution for the next person.
I have a Photo model that I&#8217;m using to store pictures. Since attachment_fu will automatically resize, create thumbnails, and store pictures on the file system, it was an easy [...]]]></description>
			<content:encoded><![CDATA[<p>I was having a bit of trouble with attachment_fu that took a while to figure out, so I thought I&#8217;d post my solution for the next person.</p>
<p>I have a Photo model that I&#8217;m using to store pictures. Since attachment_fu will automatically resize, create thumbnails, and store pictures on the file system, it was an easy choice to use it. The things I found I didn&#8217;t like about it:</p>
<ol>
<li>It stores thumbnails as separate records inside the photos table. This means you have to check if thumbnail.nil? each time you display the pictures, and you&#8217;ll have to check parent_id.nil? to count your photos.</li>
<li>You can&#8217;t use your own model validations. For example, I wanted to use</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="ruby">validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span>
validates_presence_of <span style="color:#ff3333; font-weight:bold;">:description</span></pre></div></div>

<p>But I&#8217;d always get validation errors because attachment_fu tries to save the thumbnail attributes when it creates or resizes a thumbnail. As you can imagine, this is a major problem.</p>
<h2>:thumbnail_class to the rescue</h2>
<p>Mike Clark&#8217;s <a href="http://clarkware.com/cgi/blosxom/2007/02/24">attachment_fu blog post</a> mentions that you can use the :thumbnail_class argument to separate your model validations and attachment_fu&#8217;s validations. Here&#8217;s how to do it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Photo &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:thumbnails</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> =&gt; <span style="color:#996600;">'parent_id'</span>
&nbsp;
  has_attachment  <span style="color:#ff3333; font-weight:bold;">:storage</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:file_system</span>,
                          <span style="color:#ff3333; font-weight:bold;">:content_type</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:image</span>,
                          <span style="color:#ff3333; font-weight:bold;">:max_size</span> =&gt; <span style="color:#006666;">10</span>.<span style="color:#9900CC;">megabytes</span>,
                          <span style="color:#ff3333; font-weight:bold;">:resize_to</span> =&gt; <span style="color:#996600;">'640x480'</span>,
                          <span style="color:#ff3333; font-weight:bold;">:thumbnails</span> =&gt; <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:thumb</span> =&gt; <span style="color:#996600;">'100x100'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
                          <span style="color:#ff3333; font-weight:bold;">:thumbnail_class</span> =&gt; Thumbnail
&nbsp;
  <span style="color:#008000; font-style:italic;"># Validations</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:description</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Thumbnail &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:photo</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> =&gt; <span style="color:#996600;">'parent_id'</span>
&nbsp;
  has_attachment  <span style="color:#ff3333; font-weight:bold;">:storage</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:file_system</span>,
                  <span style="color:#ff3333; font-weight:bold;">:content_type</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:image</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The killer for me initially was that I wasn&#8217;t specifying has_attachment in the Thumbnail model. I always got this error:</p>
<pre>
undefined method `temp_path=' for #thumbnail:0xb69a9514</pre>
<p>So save yourself by putting has_attachment in both models. Make sure to define any attachment_fu arguments in your Photo model, and leave the Thumbnail model bare. You&#8217;ll also want to make sure you have the normal attachment_fu schema in <strong>both</strong> models:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:parent_id</span>,  <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:content_type</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:filename</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:thumbnail</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:size</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:width</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:height</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span></pre></div></div>

<p>I&#8217;ve found that everything seems to be working as normal going this route. My model validations work and the thumbnails are not polluting the photos table. If you want to find the Photo for a particular Thumbnail, keep in mind that parent_id now refers to the id in the Photo model:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">t = Thumbnail.<span style="color:#9900CC;">find</span> ....  <span style="color:#008000; font-style:italic;"># find your thumbnail</span>
<span style="color:#CC0066; font-weight:bold;">p</span> = Photo.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>t.<span style="color:#9900CC;">parent_id</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>And for the ultimate ease-of-use relationship, just use:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">t = Thumbnail.<span style="color:#9900CC;">find</span> ....  <span style="color:#008000; font-style:italic;"># find your thumbnail</span>
<span style="color:#CC0066; font-weight:bold;">p</span> = t.<span style="color:#9900CC;">photo</span>               <span style="color:#008000; font-style:italic;"># get a photo</span>
<span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">thumbnails</span>              <span style="color:#008000; font-style:italic;"># get all thumbnails</span></pre></div></div>

<p>This works since we defined the has_many relationship in the model.</p>
<p>Let me know if you have any problems with this method or if it helped you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Serve home directories to internal IPs only with lighttpd</title>
		<link>http://blog.layer2.org/2007/11/04/serve-home-directories-to-internal-ips-only-with-lighttpd/</link>
		<comments>http://blog.layer2.org/2007/11/04/serve-home-directories-to-internal-ips-only-with-lighttpd/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 01:47:39 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[network]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/11/04/serve-home-directories-to-internal-ips-only-with-lighttpd/</guid>
		<description><![CDATA[Recently, I decided I wanted to share home directories via HTTP to everyone on my home network. This is an easy way to share files with Windows machines where you don&#8217;t have any type of sshfs-like support. The problem was that this file/web server also faces the Internet. Obviously I don&#8217;t want to share our [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I decided I wanted to share home directories via HTTP to everyone on my home network. This is an easy way to share files with Windows machines where you don&#8217;t have any type of sshfs-like support. The problem was that this file/web server also faces the Internet. Obviously I don&#8217;t want to share our personal files to anybody who cares to look. After a bit of playing, I came up with this configuration:</p>
<pre>
$HTTP["remoteip"] != "192.168.1.0/24" {
  $HTTP["url"] =~ "^/~" {
    url.access-deny = ( "" )
    dir-listing.activate = "disable"
  }
}</pre>
<p>This allows any host with an IP in the 192.168.1.1-254 range view any URL that begins with /~username. It denies everyone else with a <em>403 &#8211; Forbidden</em> message. Note that for some reason, listing the conditions in the opposite order (url first, remoteip second) did not produce the correct results.</p>
<p>Finally, make sure that you have both the appropriate modules enabled:</p>
<pre>
server.modules += ( "mod_access", "mod_userdir" )</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/11/04/serve-home-directories-to-internal-ips-only-with-lighttpd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google IMAP will be a Yahoo mail killer!</title>
		<link>http://blog.layer2.org/2007/10/24/google-imap-will-be-a-yahoo-mail-killer/</link>
		<comments>http://blog.layer2.org/2007/10/24/google-imap-will-be-a-yahoo-mail-killer/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 02:45:51 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/24/google-imap-will-be-a-yahoo-mail-killer/</guid>
		<description><![CDATA[If you haven&#8217;t heard already, Google with be and is offering IMAP for their Gmail service! You might not have it available on your account immediately, but it should be within a few days or a week.
I&#8217;m one of the lucky ones that already has IMAP set up. I tried it out in Thunderbird and [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t heard already, Google with be and is <a href="http://blog.wired.com/monkeybites/2007/10/google-adds-ima.html">offering IMAP</a> for their Gmail service! You might not have it available on your account immediately, but it should be within a few days or a week.</p>
<p>I&#8217;m one of the lucky ones that already has IMAP set up. I tried it out in Thunderbird and the setup was quite smooth. The only problem I ran into is that some of my old chats came up with a timestamp of 2:33am this morning. So, they were out of order and weird, but it wasn&#8217;t that big of an issue.</p>
<p>The real point I wanted to make in this post is that this will be a killer (imo) for Yahoo mail. Back in the day when I signed up for Yahoo mail, they were on the leading edge for features and interface. I remember when they moved to the interface they have which they now call their &#8216;classic&#8217; interface, and I have saved HTML pages that show what their REAL classic interface looks like.</p>
<p>But until now I have not had a reason to move to Gmail. While I do have a Gmail account, I don&#8217;t use it as my primary account because there was no real advantage to switch to it. Some of the features might be nicer and sexier, but webmail is still webmail. Now that Gmail offers IMAP along with a host of other features that set it apart from other webmail clients, there is a huge reason to move to Gmail. For this reason, Yahoo will lose many &#8216;techie&#8217; customers it hasn&#8217;t already lost unless it offers the same feature.</p>
<p>In case you&#8217;re curious, here are the settings:</p>
<p><strong>Incoming</strong>: imap.gmail.com<br />
<strong> Outgoing</strong>: smtp.gmail.com<br />
<strong> Username</strong>: username@gmail.com<br />
<strong> SSL</strong>: yes</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/24/google-imap-will-be-a-yahoo-mail-killer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LDS General Conference Podcast RSS feed</title>
		<link>http://blog.layer2.org/2007/10/20/lds-general-conference-podcast-rss-feed/</link>
		<comments>http://blog.layer2.org/2007/10/20/lds-general-conference-podcast-rss-feed/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 03:30:38 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/20/lds-general-conference-podcast-rss-feed/</guid>
		<description><![CDATA[LDS General Conference audio and video is available via podcast!
After watching conference the LDS General Conference at the beginning of October, I really wanted to download all the talks via an RSS feed. I didn&#8217;t see one available right away, so I considered making my own. Fortunately, I found that an official podcast does exist. [...]]]></description>
			<content:encoded><![CDATA[<p>LDS General Conference audio and video is available via podcast!</p>
<p>After watching conference the LDS General Conference at the beginning of October, I really wanted to download all the talks via an RSS feed. I didn&#8217;t see one available right away, so I considered making my own. Fortunately, I found that an official podcast does exist. Its just not publicized well by the Church.</p>
<p>MP3 audio: <a href="http://feeds.lds.org/ldsgccomplete_eng">http://feeds.lds.org/ldsgccomplete_eng</a></p>
<p>Video: <a href="http://feeds.lds.org/ldsgccomplete_eng_mp4">http://feeds.lds.org/ldsgccomplete_eng_mp4</a></p>
<p>This should get you the most recent General Conference. If you haven&#8217;t used RSS before, you just need to give either (or both) of the above feed URLs to a podcast downloader (such as <a href="http://www.apple.com/itunes/store/podcasts.html">iTunes</a>). The downloader will download all the current talks, and theoretically, will download the new talks next conference.</p>
<p>As an unrelated side note, feeds.lds.org is actually hosted by <a href="http://feedburner.com">feedburner</a>. Thanks to <a href="http://www.ldswebguy.com/2007/10/17/podcasts-and-rss-feeds-of-general-conference/">ldswebguy</a> for originally posting these podcast feeds.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/20/lds-general-conference-podcast-rss-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verizon FIOS and running a Linux operating system</title>
		<link>http://blog.layer2.org/2007/10/19/verizon-fios-and-running-a-linux-operating-system/</link>
		<comments>http://blog.layer2.org/2007/10/19/verizon-fios-and-running-a-linux-operating-system/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 12:34:11 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[fios]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/19/verizon-fios-and-running-a-linux-operating-system/</guid>
		<description><![CDATA[Despite the well known fact that Verizon Can&#8217;t Do Math, I have to say that I am surprised to find that their FIOS service is pretty good. I&#8217;ve had it for over a month, and haven&#8217;t noticed it go down or have any speed problems.
More interestingly, I&#8217;ve actually found that they are pretty Linux-friendly. Actually, [...]]]></description>
			<content:encoded><![CDATA[<p>Despite the well known fact that <a href="http://science.slashdot.org/article.pl?sid=06/12/09/0625245&amp;from=rss">Verizon Can&#8217;t Do Math</a>, I have to say that I am surprised to find that their FIOS service is pretty good. I&#8217;ve had it for over a month, and haven&#8217;t noticed it go down or have any speed problems.</p>
<p>More interestingly, I&#8217;ve actually found that they are pretty Linux-friendly. Actually, Linux-friendly might be too strong &#8211; lets just say that they have not locked me into using Windows for their service. I did have to use activatemyfios.verizon.net, which has a Windows/OS X only Firefox extension. But other than that, I haven&#8217;t felt the vendor lock-in blues.<br />
Here are some good points:</p>
<ul>
<li>As far as I can tell, Verizon only blocks port 80. I run both SSH and HTTPS from my home box.</li>
<li>Once I spoofed the <a href="http://blog.layer2.org/2007/10/01/silly-verizon-and-their-creepy-new-router/">correct MAC address</a>, I was able to use my own non-Verizon router</li>
<li>There is no PPPoE authentication or the like</li>
<li>My IP address has not changed since I started the service</li>
<li>Latency is very low (about 12ms to Google)</li>
<li>Service has not gone down</li>
</ul>
<p>I don&#8217;t use their phone or TV services, so I can&#8217;t comment on those. My guess would be that services like Vonage or Skype would work pretty well on my FIOS connection.</p>
<p>Bad points:</p>
<ul>
<li>The backup battery is supposedly pretty weak. It only provides voice service during a power outage, not Internet. For that, you&#8217;d have to use a UPS. Fortunately, I haven&#8217;t had the power go out.</li>
<li>It took forever to get the service installed. Even though the previous house owner already had FIOS installed, they couldn&#8217;t come out for 2.5 weeks.</li>
</ul>
<p>Verizon does pretty well here. So if you&#8217;re thinking about switching &#8211; I would recommend it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/19/verizon-fios-and-running-a-linux-operating-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a lookup table in Ruby on Rails</title>
		<link>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/</link>
		<comments>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 01:02:53 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/</guid>
		<description><![CDATA[I&#8217;m a big fan of the Rails way, but sometimes the simple things get you. I like to set up &#8220;lookup tables&#8221; in Rails, ie. tables in the database that hold commonly used, (often) fixed values. For example, if I have a Car model, I might want to define a Car type model. This would [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of <em>the Rails way</em>, but sometimes the simple things get you. I like to set up &#8220;lookup tables&#8221; in Rails, ie. tables in the database that hold commonly used, (often) fixed values. For example, if I have a Car model, I might want to define a Car type model. This would have two purposes:</p>
<ol>
<li>Give me the ability to associate a type with the Car model (ie. Car.type => &#8217;sport&#8217;)</li>
<li>Pre-load common values into the database (ie. sport, coupe, sedan, etc)</li>
</ol>
<p><span id="more-55"></span></p>
<p>I can accomplish this through a few steps. First, lets generate the lookup table model:</p>
<pre>
$ ruby script/generate model CarType</pre>
<p>We&#8217;ll need to edit the migration under db/migrate/XXX_create_car_types.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateCarTypes &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:car_types</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'sedan'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'sport'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'coupe'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'truck'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'van'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:car_types</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>You&#8217;ll note that I created the <em>name</em> field, and then I just used the create method to produce sample values in the database. This can be an immensely useful technique, especially when deploying a production website &#8211; just run your migrations and those lookup tables are already populated.</p>
<p><strong>Note: </strong>The other technique for populating the database automatically is fixtures. While I think they are great for creating test development data, fixtures fall behind in a production environment. Typically, fixtures will define data like &#8220;Test car 1&#8243; and &#8220;Test car 2&#8243;. This is very useful to during development, but if you have a lot of test data you can crowd your production database pretty quickly. Since there is no mechanism to conditionally load fixture data based on the environment, fixtures lose their appeal. If you must load fixture data into your production database, you may use</p>
<pre>
$ rake RAILS_ENV=production db:fixtures:load</pre>
<p>Second, create the Car model and associate it with a CarType:</p>
<pre>
$ ruby script/generate model Car</pre>

<div class="wp_syntax"><div class="code"><pre class="ruby">Car &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:car_type</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Your Car migration must hold the appropriate car_type_id:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateCars &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:cars</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:car_type_id</span>, <span style="color:#ff3333; font-weight:bold;">:int</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:cars</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Then, you can write code like this:</p>
<pre>
c = Car.find(1)
c.car_type
=> #<CarType:0xb70f05c0 @attributes={"name"=>"sedan", "id"=>"1"}>
</pre>
<p>I like to simply even more, so I generally add a method like this to the Car model:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> type
  car_type.<span style="color:#9900CC;">name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Resulting in the following:</p>
<pre>
c.type
=> "sedan"</pre>
<p>And thats it!</p>
<p>You might be interested to know that you <em>can</em> add a corresponding has_many to the CarType model to easily find all Cars of a particular type:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">CarType &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:cars</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then call something like:</p>
<pre>
CarType.find(1).cars
=> [#<Car:0xb70f4c88 @attributes={"name"=>"Test car 1", "id"=>"1", "car_type_id"=>"1"}>]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 4.015 seconds -->
<!-- Cached page served by WP-Cache -->
