<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Schadenfreude</title>
	
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Sun, 08 Nov 2009 03:41:57 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<geo:lat>39.254356</geo:lat><geo:long>-76.800602</geo:long><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RubyStoleMyBike" type="application/rss+xml" /><feedburner:emailServiceId>RubyStoleMyBike</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FRubyStoleMyBike" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FRubyStoleMyBike" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FRubyStoleMyBike" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:browserFriendly>Thanks for coming! I hope my posts interest you enough to sign up.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>SMPlayer, Lirc, and IRExec on Ubuntu Karmic</title>
		<link>http://www.ralree.com/2009/11/07/smplayer-lirc-and-irexec-on-ubuntu-karmic/</link>
		<comments>http://www.ralree.com/2009/11/07/smplayer-lirc-and-irexec-on-ubuntu-karmic/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 03:41:35 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lirc]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[smplayer]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22715</guid>
		<description><![CDATA[I used to use lirc with mplayer to allow my Packard Bell crappy remote to work awesomely, but I have since lost that configuration and switched to smplayer, since it&#8217;s awesome.  Today, I figured out how to control smplayer using similar means.


sudo apt-get install lirc
Make your /etc/lirc/lircrc look like this:


##### GLOBAL #####
begin
  flags = [...]]]></description>
			<content:encoded><![CDATA[<p>I used to use lirc with mplayer to allow my Packard Bell crappy remote to work awesomely, but I have since lost that configuration and switched to smplayer, since it&#8217;s awesome.  Today, I figured out how to control smplayer using similar means.</p>
<p><span id="more-22715"></span></p>
<ul>
<li>sudo apt-get install lirc</li>
<li>Make your <strong>/etc/lirc/lircrc</strong> look like this:</li>
</ul>
<pre><code>
##### GLOBAL #####
begin
  flags = startup_mode
  mode = smplayer
end

begin
  remote = PackBell
  button = Aux1
  mode = smplayer
end

begin
  button = Mute
  prog   = irexec
  repeat = 0
  config = amixer sset 'Master' toggle
end
begin
  button = VolUp
  prog   = irexec
  repeat = 2
  delay = 1
  config = amixer sset 'Master' 1+
end
begin
  button = VolDown
  prog   = irexec
  repeat = 2
  delay = 1
  config = amixer sset 'Master' 1-
end

##### MPLAYER #####
begin smplayer
  begin
      remote = PackBell
      prog = irexec
      button = Down
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action rewind2); fi
      repeat = 3
      delay = 1
  end

  begin
      remote = PackBell
      prog = irexec
      button = Up
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action forward2); fi
      repeat = 3
      delay = 1
  end

  begin
      remote = PackBell
      prog = irexec
      button = Right
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action forward1); fi
      repeat = 3
      delay = 1
  end

  begin
      remote = PackBell
      prog = irexec
      button = Left
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action rewind1); fi
      repeat = 3
      delay = 1
  end

  begin
      remote = PackBell
      prog = irexec
      button = Display
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action fullscreen); fi
      repeat = 0
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = CHUp
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action next_subtitle); fi
      repeat = 3
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = CHDown
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action next_audio); fi
      repeat = 3
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = LMB
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action pl_prev); fi
      repeat = 3
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = RMB
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action pl_next); fi
      repeat = 3
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = Zero
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action next_aspect); fi
      repeat = 3
      delay = 0
  end

  begin
      remote = PackBell
      prog = irexec
      button = One
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action rewind3); fi
      repeat = 3
      delay = 0
  end
  begin
      remote = PackBell
      prog = irexec
      button = Two
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action play_or_pause); fi
      repeat = 3
      delay = 0
  end
  begin
      remote = PackBell
      prog = irexec
      button = Three
      config = if [ $(ps -eo cmd | grep -c ^smplayer) -eq 1 ]; then (smplayer -send-action forward3); fi
      repeat = 3
      delay = 0
  end
end smplayer
</code></pre>
<ul>
<li>sudo /etc/init.d/lirc restart</li>
<li>You should see the irexec daemon start</li>
<li>Start smplayer and make it play something</li>
<li>Push the AUX1 button on your Packard Bell remote</li>
<li>Now push other buttons.  It should all work.</li>
</ul>
<p>Thanks to all the blog posts and forum conversations that helped me figure all that out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/11/07/smplayer-lirc-and-irexec-on-ubuntu-karmic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Poor Franz</title>
		<link>http://www.ralree.com/2009/10/03/poor-franz/</link>
		<comments>http://www.ralree.com/2009/10/03/poor-franz/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 02:11:45 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[terrible]]></category>
		<category><![CDATA[wow]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22708</guid>
		<description><![CDATA[It&#8217;s a sad day when a random one-hit wonder band who stole your name gets a higher page rank in Google than you do.

Poor Franz Ferdinand.  I&#8217;ll bet he&#8217;s rolling in his grave.  He should Black (back)Hand that band.
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a sad day when a random one-hit wonder band who stole your name gets a higher page rank in Google than you do.</p>
<p><a href="http://www.ralree.com/newblog/wp-content/uploads/2009/10/franz.jpg"><img class="aligncenter size-full wp-image-22709" title="franz" src="http://www.ralree.com/newblog/wp-content/uploads/2009/10/franz.jpg" alt="franz" width="702" height="286" /></a></p>
<p>Poor Franz Ferdinand.  I&#8217;ll bet he&#8217;s rolling in his grave.  He should Black (back)Hand that band.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/10/03/poor-franz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Importing MySQL 1.4 Amarok data into Amarok 2.2 Nightly</title>
		<link>http://www.ralree.com/2009/09/28/importing-mysql-1-4-amarok-data-into-amarok-2-2-nightly/</link>
		<comments>http://www.ralree.com/2009/09/28/importing-mysql-1-4-amarok-data-into-amarok-2-2-nightly/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 20:15:49 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[amarok]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22704</guid>
		<description><![CDATA[I was having a bunch of trouble today importing my old MySQL amarok database into the new nightly version of amarok I installed.  The Amarok Wiki had a great section on how to convert a MySQL Amarok collection into an SQLlite one.  This was the key to importing my old 1.4 collection into the new [...]]]></description>
			<content:encoded><![CDATA[<p>I was having a bunch of trouble today importing my old MySQL amarok database into the new nightly version of amarok I installed.  <span style="background-color: #ffffff; "><a href="http://amarok.kde.org/wiki/MySQL_HowTo#Amarok_1.4.8_and_MySQL_5.0.45">The Amarok Wiki</a> had a great section on how to convert a MySQL Amarok collection into an SQLlite one.  This was the key to importing my old 1.4 collection into the new 2.2 nightly version of Amarok.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/09/28/importing-mysql-1-4-amarok-data-into-amarok-2-2-nightly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make Chrome bearable in Ubuntu Jaunty 9.04</title>
		<link>http://www.ralree.com/2009/09/25/how-to-make-chrome-bearable-in-ubuntu-jaunty-9-04/</link>
		<comments>http://www.ralree.com/2009/09/25/how-to-make-chrome-bearable-in-ubuntu-jaunty-9-04/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:56:30 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[addons]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22690</guid>
		<description><![CDATA[So, there I was, watching Firefox 3 thrash my CPU and IO, when I decided that I needed a replacement.  Something elegant, fast, preferably threaded&#8230; oh!  Google Chrome!  So, I finally found a link to download the unstable version of the browser based on the latest revisions, of which I got version 4.0.213.1-r27053.
Now, I&#8217;ve used [...]]]></description>
			<content:encoded><![CDATA[<p>So, there I was, watching Firefox 3 thrash my CPU and IO, when I decided that I needed a replacement.  Something elegant, fast, preferably threaded&#8230; <em>oh</em>!  <strong>Google Chrome</strong>!  So, I finally found a <a href="http://dev.chromium.org/getting-involved/dev-channel">link to download</a> the unstable version of the browser based on the latest revisions, of which I got version 4.0.213.1-r27053.</p>
<p><span style="background-color: #ffffff;">Now, I&#8217;ve used Chrome in Linux before, and a few things about Firefox kept me hooked.  Today, though, I was on a mission to change all that.  I wanted basically all the functionality I got from Firefox in my Chrome experience as well.  This article should help others do the same.</span></p>
<p><span style="background-color: #ffffff;"><span id="more-22690"></span></span></p>
<p><span style="background-color: #ffffff;"><strong>Tip</strong>: Flash is enabled in newer versions by default, but in old Chrome for Linux versions, you had to start it with &#8211;enable-plugins.  I&#8217;m using native x86_64 flash for Ubuntu 9.04, and it works brilliantly.  Get it <a href="http://labs.adobe.com/downloads/flashplayer10.html">here</a>.</span></p>
<h2><span style="background-color: #ffffff;">Result</span></h2>
<p><span style="background-color: #ffffff;">The first thing I did was import all my Firefox settings, which Chrome asks when it starts the first time.  This worked extremely well, even pulling over my bookmarks toolbar.  This is the result of my work:</span></p>
<p><span style="background-color: #ffffff;"><a href="http://www.ralree.com/newblog/wp-content/uploads/2009/09/main_chrome.jpg"><img class="aligncenter size-full wp-image-22692" title="main_chrome" src="http://www.ralree.com/newblog/wp-content/uploads/2009/09/main_chrome.jpg" alt="main_chrome" width="784" height="628" /></a></span></p>
<p><span style="background-color: #ffffff;"><strong>Tip</strong>: To get the bookmark toolbar to show, hit Ctrl-b.</span></p>
<p><span style="background-color: #ffffff;"><strong>Another Tip</strong>: You can remove all the title text from bookmarks to get the bare icons I did above.  It&#8217;s actually pretty clean when you have favicons to depend on.</span></p>
<h2>Goal 1: Stumbleupon</h2>
<p><span style="background-color: #ffffff;">Yes, I waste tons of time stumbling.  According to my stats, I&#8217;ve given 4,854 pages a Thumbs Up, 447 pages a Thumbs Down, and I&#8217;ve hit the Stumble!  button 18,610 times.  This behavior may be unhealthy, but I&#8217;m addicted.  The solution to this is the cool toolbar they have.  You can see an example <a href="http://www.stumbleupon.com/s/">here</a>.  This replaces the Firefox addon toolbar for everything by the initiation of Stumbling, which I made a little bookmark for in my toolbar.</span></p>
<p><a href="http://www.stumbleupon.com/s/">Stumble!</a></p>
<h2>Goal 2:  Instapaper</h2>
<p>Instapaper is great for putting those articles in a reading queue that you just don&#8217;t feel like reading, and getting them on some mobile device when you&#8217;re bored, like on a flight.  It&#8217;s easily solved in Chrome with a bookmarklet.  See your account details in Instapaper, since it&#8217;s personalized.</p>
<h2>Goal 3: Delicious</h2>
<p>I love delicious.  It&#8217;s seriously helpful, and the delicious addon for Firefox has been on of my reasons for sticking with it for so long.  Yet, I recently found out that a bookmarklet can do all of the functions I use the addon for.  Here it is:</p>
<p><a href="javascript:(function(){f='http://delicious.com/save?url='+encodeURIComponent(window.location.href)+'&amp;title='+encodeURIComponent(document.title)+'&amp;v=5&amp;';a=function(){if(!window.open(f+'noui=1&amp;jump=doclose','deliciousuiv5','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()">Delicious</a></p>
<p>Just drag that to your toolbar.</p>
<h2>Goal 4: Get rid of that stupid blue theme</h2>
<p>Ugh.  That light blue crap reminds me of Windows XP.  Get it away!  Thankfully, Chrome now has <a href="https://tools.google.com/chrome/intl/en/themes/index.html">themes</a>.  I changed it to the Brushed look, and I like it a lot.</p>
<h2>Goal 5: Amazon Universal Wishlist</h2>
<p>The Universal Wishlist bookmarklet still works like it did in Firefox.  Awesome.  <a href="http://www.amazon.com/wishlist/get-button">Get one.</a></p>
<p>I hope this helps all of you out there with Firefox blues.  Google really has come through on this one.</p>
<h2>Goal 6: URL Shortening</h2>
<p>I always liked being able to click a button and shorten a URL.  I can get this functionality using PunyURL (the sapo.pt one) using this bookmarklet: <a href="javascript:(function(){f='http://puny.sapo.pt/punify?url='+encodeURIComponent(window.location.href);a=function(){if(!window.open(f,'punyurl','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'));};a();})()">Puny</a></p>
<p><a href="http://www.stumbleupon.com/demo/"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/09/25/how-to-make-chrome-bearable-in-ubuntu-jaunty-9-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1,000,000th Fibonacci Number One-Liner in C</title>
		<link>http://www.ralree.com/2009/09/09/1000000th-fibonacci-number-one-liner-in-c/</link>
		<comments>http://www.ralree.com/2009/09/09/1000000th-fibonacci-number-one-liner-in-c/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 05:04:40 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[one-liner]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22673</guid>
		<description><![CDATA[This is possibly the best one-liner I&#8217;ve ever written:


gcc -x c -o /tmp/out - -lgmp ]]></description>
			<content:encoded><![CDATA[<p>This is possibly the best one-liner I&#8217;ve ever written:</p>
<p><code>
<pre>
gcc -x c -o /tmp/out - -lgmp <<< '#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdint.h&gt;
#include &lt;gmp.h&gt;
void omg_i_love_leonardo_of_pisa(uint32_t num, mpz_t * result) { mpz_t retval, last, tmp; mpz_init(retval);
 mpz_init(last); mpz_init(tmp); uint32_t i = 1; if(num == 0) return; mpz_set_ui(retval, 1U);
mpz_set_ui(last, 0U); for(; i < num; i++) { mpz_set(tmp, retval); mpz_add(retval, retval, last);
mpz_set(last, tmp); } mpz_set(*result, retval); } int main() { uint32_t num; mpz_t fibo; mpz_init(fibo);
omg_i_love_leonardo_of_pisa(1000001, &#038;fibo); mpz_out_str(stdout, 10, fibo); printf("\n"); return 1; }
' &#038;&#038; time /tmp/out
</pre>
<p></code></p>
<p>It compiles a C program given from <code>STDIN</code>, puts it in <code>/tmp/out</code>, and runs it with time to find the time it takes to run.  It generates the 1,000,000th Fibonacci number.  <strong>Try it!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/09/09/1000000th-fibonacci-number-one-liner-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading compressed files with postgres using named pipes</title>
		<link>http://www.ralree.com/2009/09/04/reading-compressed-files-with-postgres-using-named-pipes/</link>
		<comments>http://www.ralree.com/2009/09/04/reading-compressed-files-with-postgres-using-named-pipes/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 06:38:55 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[dba]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22661</guid>
		<description><![CDATA[Postgres has the same type of ability MySQL has to read in files, yet much nicer syntax.  LOAD DATA INFILE from MySQL is just COPY in postgres.  I decided to try having it read from a named pipe today, and it worked out nicely.

I started out making a test db and making a [...]]]></description>
			<content:encoded><![CDATA[<p>Postgres has the same type of ability MySQL has to read in files, yet much nicer syntax.  <code>LOAD DATA INFILE</code> from MySQL is just <code>COPY</code> in postgres.  I decided to try having it read from a named pipe today, and it worked out nicely.<br />
<span id="more-22661"></span><br />
I started out making a test db and making a nice little schema:</p>
<pre><code>
postgres@tardis:~$ createdb test
postgres@tardis:~$ psql test
psql (8.4.0)
Type "help" for help.

test=# CREATE TYPE rank AS ENUM ('general', 'sergeant', 'private');
CREATE TYPE
test=# CREATE TABLE military (id SERIAL PRIMARY KEY,
test(#   name VARCHAR(128),
test(#   rank rank);
NOTICE:  CREATE TABLE will create implicit sequence "military_id_seq" for serial column "military.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "military_pkey" for table "military"
CREATE TABLE
</code></pre>
<p>Notice the use of <code>SERIAL</code>?  That&#8217;s postgres&#8217; <code>AUTO_INCREMENT</code>, basically.  I like it better.  Next, it&#8217;s time to make a text file with some data and compress it.  Here&#8217;s what I put in the file (note that the spaces between the words are <code>TAB</code> characters):</p>
<pre><code>
general Lee
sergeant  Hartman
private Pyle
</code></pre>
<p>And compress it with <code>gzip</code>, making a nice little file:</p>
<pre><code>
hank@tardis:/tmp$ gzip file
hank@tardis:/tmp$ zcat file.gz
general	Lee
sergeant	Hartman
private	Pyle
</code></pre>
<p>Now let&#8217;s actually make a named pipe for postgres to read from:</p>
<pre><code>
hank@tardis:/tmp$ mkfifo namedpipe
</code></pre>
<p>Now that we have our named pipe, let&#8217;s start reading from it:</p>
<pre><code>
test=# COPY military (rank, name) FROM '/tmp/namedpipe' WITH DELIMITER E'\t';
</code></pre>
<p>The <code>E'\t'</code> part means to escape characters inside the single-quoted string, turning this into an actual tab character.  All that we have to do now is use zcat:</p>
<pre><code>
hank@tardis:/tmp$ zcat file.gz > namedpipe
</code></pre>
<p>Immediately, there&#8217;s some output in the psql session:</p>
<pre><code>
COPY 3
</code></pre>
<p>So, postgres says it got 3 records successfully.  Yay!  Now, let&#8217;s display them:</p>
<pre><code>
test=# select * from military;
 id |  name   |   rank
----+---------+----------
  1 | Lee     | general
  2 | Hartman | sergeant
  3 | Pyle    | private
(3 rows)
</code></pre>
<p>So, this is a pretty good method to read in compressed files with postgres.  I&#8217;ve seen many articles that use similar methods with postgres dump files, but it&#8217;s useful for bulk delimited data loading as well, as many times it&#8217;s prudent to compress bulk data files and not extract them before loading them.  See the postgres <a href="http://www.postgresql.org/docs/8.4/interactive/sql-copy.html">COPY</a> page for more information about this awesome function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/09/04/reading-compressed-files-with-postgres-using-named-pipes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby to generate RSS feeds for sites that don’t offer them</title>
		<link>http://www.ralree.com/2009/08/23/ruby-to-generate-rss-feeds-for-sites-that-dont-offer-them/</link>
		<comments>http://www.ralree.com/2009/08/23/ruby-to-generate-rss-feeds-for-sites-that-dont-offer-them/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 14:53:41 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[generation]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyrss]]></category>
		<category><![CDATA[scraping]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22648</guid>
		<description><![CDATA[There&#8217;s this site that has an equipment exchange I wanted to keep track of.  Yet, it&#8217;s done with what seems to be a custom php file rather than vbulletin, so none of the usual RSS feeds from the site apply to it.  So, I decided to make a scraper/feed-generator to get me the [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s this site that has an equipment exchange I wanted to keep track of.  Yet, it&#8217;s done with what seems to be a custom php file rather than vbulletin, so none of the usual RSS feeds from the site apply to it.  So, I decided to make a scraper/feed-generator to get me the latest version every 5 minutes and generate a nice RSS feed, so I can view it in Google Reader.  The volume of posting is low enough that this won&#8217;t be annoying to see in my daily feeds.</p>
<p>I usually use Ruby for this because it offers Hpricot, a very nice and fast scraper and XPath interface. This time, I resolved to find something that does RSS generation better, and I stumbled upon <a href="http://rubyrss.com/">RubyRSS</a>, which <strong>happens to be in the core ruby distribution</strong>!<br />
<span id="more-22648"></span><br />
Here&#8217;s what I ended up with after about an hour:</p>
<script src="http://gist.github.com/173318.js"></script>
<p>Now this is impressive if you look at the fail of html <code>id</code> and <code>class</code> attributes coming out of the original page.  I had to base everything off of the links to the items that were not images, and then the structure <em>up the tree</em> from there (see the liberal use of <code>.parent</code>).  I&#8217;ve rediscovered that Hpricot is awesome (_why, come back to us!), and that it truly only takes 30 lines of code to generate a nice RSS feed in ruby.  The resultant RSS feed for MDShooters Classifieds site is <a href="http://www.ralree.com/mdshooters_classifieds.xml">here</a>.</p>
<p>And now, yet another RSS feed generator: <a href="http://ralree.com/md_super_ads.xml">MD Super Ads</a></p>
<p>Here&#8217;s the code:</p>
<script src="http://gist.github.com/173623.js"></script>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/08/23/ruby-to-generate-rss-feeds-for-sites-that-dont-offer-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good Passwords with GnuPG</title>
		<link>http://www.ralree.com/2009/08/22/good-passwords-with-gnupg/</link>
		<comments>http://www.ralree.com/2009/08/22/good-passwords-with-gnupg/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 03:15:45 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[passwords]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/10/13/good-passwords-with-gnupg</guid>
		<description><![CDATA[I found out from this site that GPG can be used to generate random text for passwords.  Here’s the command:

 gpg --gen-random 1 20 &#124; gpg --enarmor &#124; sed -n 5p

Very simple.  I may have to use this in the future.
WARNING
This limits you to the Base64 character set, greatly limiting the search space [...]]]></description>
			<content:encoded><![CDATA[<p>I found out from <a href="http://www.linuxjournal.com/article/8732">this site</a> that GPG can be used to generate random text for passwords.  Here’s the command:</p>
<pre><code>
 gpg --gen-random 1 20 | gpg --enarmor | sed -n 5p
</code></pre>
<p>Very simple.  I may have to use this in the future.</p>
<h1>WARNING</h1>
<p>This limits you to the Base64 character set, greatly limiting the search space for password cracking.  One should really use something other than enarmor to spit out a random printable ASCII string&#8230;</p>
<h1>Update</h1>
<p>OK, I did it.  It took some time, but it works nicely now, and generates MUCH better passwords:</p>
<pre style="overflow:auto;"><code>
hank@tardis:/nexus/tardis/hank$ for i in 1 2 3 4; \
  do gpg --gen-random 1 20 | \
  perl -ne's/[\x00-\x20]/chr(ord($^N)+50)/ge;s/([\x7E-\xDB])/chr(ord($^N)-93)/ge;s/([\xDC-\xFF])/chr(ord($^N)-129)/ge;print $_, "\n"';
done
p8$K`frjdkp;i-c2]2a2
glj#""I/eY\aYe3p}2y@
U2cXL&amp;2^2/@7P2d#;?E=
kG)|N?[ZP2t2'bH22e;$
</code></pre>
<p>I know that probably looks like gobbledy-gook, but the main part of it is this:</p>
<pre style="overflow:auto;"><code>gpg --gen-random 1 20 | perl -ne'print "Your password: ";s/[\x00-\x20]/chr(ord($^N)+50)/ge;s/([\x7E-\xDB])/chr(ord($^N)-93)/ge;s/([\xDC-\xFF])/chr(ord($^N)-129)/ge;print $_, "\n"'</code></pre>
<p>Run that in a terminal, and <strong>profit</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/08/22/good-passwords-with-gnupg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Citibank says checks are cleared as soon as you see them online…</title>
		<link>http://www.ralree.com/2009/08/10/22628/</link>
		<comments>http://www.ralree.com/2009/08/10/22628/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 05:56:33 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[banking]]></category>
		<category><![CDATA[checks]]></category>
		<category><![CDATA[finance]]></category>
		<category><![CDATA[money]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22628</guid>
		<description><![CDATA[I called Citibank tonight to confirm that one of my checks I deposited was finally collected.  This is a good thing to ask your bank if you are concerned that a check might bounce.  They indicated, as is said in the following audio recording, that if a check shows up in your transaction log online, [...]]]></description>
			<content:encoded><![CDATA[<p>I called Citibank tonight to confirm that one of my checks I deposited was finally collected.  This is a good thing to ask your bank if you are concerned that a check might bounce.  They indicated, as is said in the following audio recording, <strong>that if a check shows up in your transaction log online, it&#8217;s cleared.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/08/10/22628/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.ralree.com/newblog/wp-content/uploads/2009/08/stuff.mp3" length="4349039" type="audio/mpeg" />
		</item>
		<item>
		<title>How to set the RTC max_user_freq in newer kernels</title>
		<link>http://www.ralree.com/2009/07/19/how-to-set-the-rtc-max_user_freq-in-newer-kernels/</link>
		<comments>http://www.ralree.com/2009/07/19/how-to-set-the-rtc-max_user_freq-in-newer-kernels/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 01:03:07 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rtc]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.ralree.com/?p=22623</guid>
		<description><![CDATA[I found out today how to set the real time clock max frequencies in Ubuntu since they removed the possibility to do it from sysutil.conf from newer kernels.  Add the following to your /etc/rc.local or another startup script:
echo 2048 >/sys/class/rtc/rtc0/max_user_freq
echo 2048 >/proc/sys/dev/hpet/max-user-freq
Reboot, and you should get better performance from things like mplayer.
]]></description>
			<content:encoded><![CDATA[<p>I found out today how to set the real time clock max frequencies in Ubuntu since they removed the possibility to do it from <code>sysutil.conf</code> from newer kernels.  Add the following to your <code>/etc/rc.local</code> or another startup script:</p>
<pre><code>echo 2048 >/sys/class/rtc/rtc0/max_user_freq
echo 2048 >/proc/sys/dev/hpet/max-user-freq</code></pre>
<p>Reboot, and you should get better performance from things like mplayer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2009/07/19/how-to-set-the-rtc-max_user_freq-in-newer-kernels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.452 seconds -->
