<?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"
	>

<channel>
	<title>Code Like Zell</title>
	<atom:link href="http://www.codelikezell.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codelikezell.com</link>
	<description></description>
	<pubDate>Sat, 22 Nov 2008 19:38:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Edit through FTP with TextMate and Cyberduck</title>
		<link>http://www.codelikezell.com/edit-through-ftp-with-textmate-and-cyberduck</link>
		<comments>http://www.codelikezell.com/edit-through-ftp-with-textmate-and-cyberduck#comments</comments>
		<pubDate>Mon, 30 Jun 2008 02:25:11 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[cyberduck]]></category>

		<category><![CDATA[ftp]]></category>

		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/edit-through-ftp-with-textmate-and-cyberduck</guid>
		<description><![CDATA[I do a bit of freelance php work where I need to edit files through FTP.  Textmate does not support this very well out of the box, and at first it seemed like I would have to open and edit each file in its own window.  But by combining this tip by subtlegradient [...]]]></description>
			<content:encoded><![CDATA[<p>I do a bit of freelance php work where I need to edit files through FTP.  Textmate does not support this very well out of the box, and at first it seemed like I would have to open and edit each file in its own window.  But by combining <a href="http://lists.macromates.com/textmate/2006-February/008636.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/lists.macromates.com');">this tip</a> by <a href="http://subtlegradient.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/subtlegradient.com');">subtlegradient</a> with <a href="http://ciaranwal.sh/2007/11/27/textmate-tip-where-am-i" onclick="javascript:pageTracker._trackPageview('/outbound/article/ciaranwal.sh');">this tip</a> by <a href="http://ciaranwal.sh/" onclick="javascript:pageTracker._trackPageview('/outbound/article/ciaranwal.sh');">ciaranwal.sh</a> we can use tabbed editing, project drawer, and cmd+t to switch files.  The steps:</p>
<p>1. In Cyberduck&#8217;s preferences make sure external editor is set to TextMate.  Also, it helps if &#8220;Double click opens file in external editor&#8221; is set to true.</p>
<p>2. Open up a file from your FTP project that is close to the top level directory of your project, you&#8217;ll see why in a minute.</p>
<p>3.  In the TextMate window that popped up, hit ctrl+shift+o (Bundles &gt; Shell Script &gt; Open Terminal).  The terminal will open at the temporary location where the file you are editing is.</p>
<p>4.  cd .. back to the top level directory of your project and enter: <code>mate .</code></p>
<p>Now any subsequent files you open using Cyberduck will be added as tabs in the current TextMate project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/edit-through-ftp-with-textmate-and-cyberduck/feed</wfw:commentRss>
		</item>
		<item>
		<title>GoLark Mobile</title>
		<link>http://www.codelikezell.com/golark-mobile</link>
		<comments>http://www.codelikezell.com/golark-mobile#comments</comments>
		<pubDate>Wed, 13 Feb 2008 01:04:23 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[golark]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/golark-mobile</guid>
		<description><![CDATA[The GoLark iPhone Application was released this week, making GoLark one step closer to providing us with local events, anywhere, at any time.
Currently, two of GoLark&#8217;s lists are supported on the iPhone: Top Larks and Top Recurring Larks. Date and time filtering&#8211;although slightly stripped down&#8211;is also provided. The app is purposely minimal in design, providing [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.apple.com/webapps/entertainment/golarkmobile.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.apple.com');">GoLark iPhone Application</a> was released this week, making GoLark one step closer to providing us with local events, anywhere, at any time.</p>
<p>Currently, two of GoLark&#8217;s lists are supported on the iPhone: Top Larks and Top Recurring Larks. Date and time filtering&#8211;although slightly stripped down&#8211;is also provided. The app is purposely minimal in design, providing a clear and simple interface to the best local events.</p>
<p>Check it out at <a href="http://iphone.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/iphone.golark.com');">iphone.golark.com</a></p>
<p><a href="http://iphone.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/iphone.golark.com');"><img class="alignnone size-medium wp-image-17" title="iPhone, meet GoLark." src="http://www.golark.com/blog/wp-content/uploads/2008/03/iphone_app1.png" alt="" width="311" height="567" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/golark-mobile/feed</wfw:commentRss>
		</item>
		<item>
		<title>Intermix arrays (using Ruby)</title>
		<link>http://www.codelikezell.com/intermix-arrays-using-ruby</link>
		<comments>http://www.codelikezell.com/intermix-arrays-using-ruby#comments</comments>
		<pubDate>Sat, 17 Nov 2007 00:00:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[array transpose]]></category>

		<category><![CDATA[intermix arrays]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/intermix-arrays-using-ruby</guid>
		<description><![CDATA[I haven&#8217;t posted in a while because GoLark is consuming all of my time, but tonight I felt compelled because of how cool this is. I needed to intermix two arrays, here is how I did it:
a1 = [1,2,3]
a2 = ["a","b","c"]
intermixed_array = [a1,a2].transpose.flatten
Yeah, no doubt. Is that obvious?
]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t posted in a while because <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark</a> is consuming all of my time, but tonight I felt compelled because of how cool this is. I needed to intermix two arrays, here is how I did it:</p>
<pre class="all:nocontrols:nogutter">a1 = [1,2,3]
a2 = ["a","b","c"]
intermixed_array = [a1,a2].transpose.flatten</pre>
<p>Yeah, no doubt. Is that obvious?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/intermix-arrays-using-ruby/feed</wfw:commentRss>
		</item>
		<item>
		<title>Create a sick game with Processing</title>
		<link>http://www.codelikezell.com/create-a-sick-game-with-processing</link>
		<comments>http://www.codelikezell.com/create-a-sick-game-with-processing#comments</comments>
		<pubDate>Sun, 04 Nov 2007 10:41:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[Processing]]></category>

		<category><![CDATA[Processing API]]></category>

		<category><![CDATA[sick game]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/create-a-sick-game-with-processing</guid>
		<description><![CDATA[I did a little experimenting with Processing, a language written for artists, graphics designers, and anyone interested in learning something new. I was very impressed with how easy it was to get started. The download comes with tons of simple example projects, and the API reference is easy to understand. I had hopes of Processing [...]]]></description>
			<content:encoded><![CDATA[<p>I did a little experimenting with <a href="http://www.processing.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.processing.org');">Processing</a>, a language written for artists, graphics designers, and anyone interested in learning something new. I was very impressed with how easy it was to get started. The download comes with tons of simple example projects, and the <a href="http://www.processing.org/reference/index.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.processing.org');">API reference</a> is easy to understand. I had hopes of Processing opening a whole, previously undiscovered, artistic side of my brain &#8212; it didn&#8217;t. But I did make a killer &#8220;blow up the falling spheres with my triangle&#8217;s laser&#8221; game. Check it out:</p>
<p><a title="Killer game made with Processing" href="http://www.louiszell.com/wp-content/uploads/2007/12/game_smaller1.png" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.louiszell.com');"></a></p>
<p><a title="Killer game made with Processing" href="http://www.louiszell.com/wp-content/uploads/2007/12/game_smaller1.png" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.louiszell.com');"><img src="http://www.codelikezell.com/wp-content/uploads/2007/12/game_smaller1.png" alt="Killer game made with Processing" /></a></p>
<p>Wow, that screen shot makes it look even more lame than it really is (hard to do). Well, if you aren&#8217;t impressed with that, check out what <a href="http://www.vimeo.com/286434" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.vimeo.com');">someone with artistic talent</a> can do with Processing.</p>
<p>I know, I know, you want the code so you can try this game out for yourself. <a title="Source for sphere game" href="http://www.codelikezell.com/blog/wp-content/uploads/2007/12/processing_sphere_game.pde" >Here it is</a>, open with Processing and hit play.</p>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/create-a-sick-game-with-processing/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to modify the GNU linker&#8217;s default search path</title>
		<link>http://www.codelikezell.com/how-to-modify-the-gnu-linkers-default-search-path</link>
		<comments>http://www.codelikezell.com/how-to-modify-the-gnu-linkers-default-search-path#comments</comments>
		<pubDate>Tue, 30 Oct 2007 22:10:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[centos]]></category>

		<category><![CDATA[GNU linker]]></category>

		<category><![CDATA[ld search path]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/how-to-modify-the-gnu-linkers-default-search-path</guid>
		<description><![CDATA[A couple of weeks ago I hit multiple snags on my first attempt at installing memcached from source code on CentOS, hence the tutorial, &#8220;How to install memcached.&#8221; The fact that users found the tutorial by searching Google for the exact error messages in my post reassured me that I wasn&#8217;t just being an idiot. [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I hit multiple snags on my first attempt at installing memcached from source code on CentOS, hence the tutorial, <a href="http://www.codelikezell.com/how-to-install-memcached" >&#8220;How to install memcached.&#8221;</a> The fact that users found the tutorial by searching Google for the exact error messages in my post reassured me that I wasn&#8217;t just being an idiot. Here I will address a very similar problem and provide a once and for all solution.</p>
<p>I installed <a href="http://www.gnu.org/software/gsl/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gnu.org');">GNU&#8217;s Scientific Library</a> and <a href="http://rb-gsl.rubyforge.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/rb-gsl.rubyforge.org');">Ruby&#8217;s wrapper for GSL</a> on Ubuntu and OS X without any problems. Next up: CentOS. The install appeared to complete successfully, but a require &#8216;gsl&#8217; from irb showed otherwise:</p>
<pre class="all:nocontrols:nogutter">LoadError: libgsl.so.0: cannot open shared object file: No such file or directory</pre>
<p>I located libgsl.so.0 in /usr/local/lib; so once again I have a problem with the linker finding a shared library. The way I fixed this during the memcached install was to add the <code>--rpath</code> linker flag during the build. But I don&#8217;t wan&#8217;t to keep running into this in the future, so I decided to add /usr/local/lib to ld&#8217;s default search path, here&#8217;s how:</p>
<p>Open /etc/ld.so.conf and make sure there is a single line that reads:</p>
<pre class="all:nogutter:nocontrols">include ld.so.conf.d/*.conf</pre>
<p>Then, from bash prompt:</p>
<pre class="all:nogutter:nocontrols">echo "/usr/local/lib" &gt;&gt; /etc/ld.so.conf.d/loc_lib.conf
/sbin/ldconfig</pre>
<p>That should do it.</p>
<p>If you would like to learn more on the subject, this is the only good documentation I have found on <a href="http://www.eyrie.org/~eagle/notes/rpath.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.eyrie.org');">Shared Library Search Paths</a>.</p>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/how-to-modify-the-gnu-linkers-default-search-path/feed</wfw:commentRss>
		</item>
		<item>
		<title>Broaden your vocabulary with Genius, Ruby, and Dictionary.com</title>
		<link>http://www.codelikezell.com/broaden-your-vocabulary-with-genius-ruby-and-dictionarycom</link>
		<comments>http://www.codelikezell.com/broaden-your-vocabulary-with-genius-ruby-and-dictionarycom#comments</comments>
		<pubDate>Mon, 29 Oct 2007 19:20:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[applescript]]></category>

		<category><![CDATA[crontab]]></category>

		<category><![CDATA[dictionary.com]]></category>

		<category><![CDATA[genius]]></category>

		<category><![CDATA[mac os x]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[vi]]></category>

		<category><![CDATA[vocabulary]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/broaden-your-vocabulary-with-genius-ruby-and-dictionarycom</guid>
		<description><![CDATA[Genius is a flash card program for Mac OS X that I came across on Lifehacker a few days ago. Using it is simple: you create a flash card set, Genius determines how often to display each card based on how well you have answered it in the past. The thing is, I don&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>Genius is a flash card program for Mac OS X that I came across on <a href="http://lifehacker.com/software/featured-mac-download/memorize-anything-with-genius-315064.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/lifehacker.com');">Lifehacker</a> a few days ago. Using it is simple: you create a flash card set, Genius determines how often to display each card based on how well you have answered it in the past. The thing is, I don&#8217;t want to create the flashcard set, and you probably don&#8217;t either; that is the reason we never used flashcards in the first place. But I do want to expand my vocabulary, and Genius is certainly a tool that can help with that. So if you are also interested in a shiny new vocabulary, here&#8217;s what we can do: automate the flash card creation process.</p>
<p>The way we will do this is by creating a Ruby script that will parse Dictionary.com&#8217;s &#8220;Word of the Day&#8221; rss feed, then use AppleScript to add the word/definition pair to Genius. Finally, we will use crontab to automate the entire process. If all this sounds complicated, don&#8217;t worry, it is 90% copy-pasting.</p>
<p><strong>Step 1: Create necessary directories</strong><br />
I am placing the Ruby and AppleScript files in ~/scripts, and the Genius flash card file in ~/flashcards, but feel free to use directories of your choice. From terminal:</p>
<pre class="all:nocontrols:nogutter">mkdir ~/scripts
mkdir ~/flashcards</pre>
<p><strong>Step 2: Create empty .genius file</strong><br />
Open Genius and save a new (empty) file as &#8216;dictionary_wotd&#8217; in the ~/flashcards directory. Close Genius.</p>
<p><strong>Step3: Create a Ruby file to parse Dictionary.com&#8217;s word of the day rss feed</strong><br />
From terminal, create the file with:</p>
<pre class="all:nocontrols:nogutter">touch ~/scripts/parse_wotd.rb; chmod 664 ~/scripts/parse_wotd.rb</pre>
<p>Next, open ~/scripts/parse_wotd.rb in an editor and paste in this chunk of code:</p>
<pre class="all:nocontrols">require 'rubygems'
require 'hpricot'
require 'open-uri'

xml = Hpricot(open("http://dictionary.reference.com/wordoftheday/wotd.rss"))
desc = (xml/"item"/"description").inner_html

desc =~ /^([-\w]+):\s+(.+)/
word = $1
definition = $2.gsub(/^(\w)/) {|x| x.upcase}

system "osascript /Users/HOMEDIR/scripts/create_fcard.scpt " + word + " '" + definition + "'"</pre>
<p>Be sure to replace HOMEDIR (line 12) with your own directory name (e.g. your username).<br />
Save and quit. Also, make sure you have the <a href="http://code.whytheluckystiff.net/hpricot/wiki/InstallingHpricot" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.whytheluckystiff.net');">Hpricot</a> gem installed.</p>
<p><strong>Step4: Create AppleScript file to add the word/definition pair to Genius</strong></p>
<p>open Applications &gt; AppleScript &gt; Script Editor<br />
then File &gt; New</p>
<p>Paste in this chunk of code:</p>
<pre class="all:nocontrols">on run argv
tell application "Finder"
activate
open document file "dictionary_wotd.genius" of folder "flashcards" of folder "HOMEDIR" of folder "Users" of startup disk
end tell

tell application "Genius"
activate
end tell

tell application "System Events"
keystroke "N" using command down
keystroke item 1 of argv
keystroke "\t"
keystroke item 2 of argv
keystroke "s" using command down
delay .2
keystroke "w" using command down
end tell
end run</pre>
<p>Again, be sure to replace HOMEDIR (line 4) with your own directory name. Save this file as &#8216;create_fcard&#8217; in the ~/scripts directory. Close Script Editor.</p>
<p>We should test what we have so far, open terminal and:</p>
<pre class="all:nocontrols:nogutter">cd ~/scripts
ruby parse_wotd.rb</pre>
<p>Now open ~/flashcards/dictionary_wotd.genius and make sure the new card exists, if it does not, double check your paths in the .rb and .scpt files.</p>
<p>Finally, automate with crontab<br />
From terminal:</p>
<pre class="all:nogutter:nocontrols">crontab -e</pre>
<p>This will open vi, add the following line to run the Ruby script every morning at 2:30 am:</p>
<pre class="all:nogutter:nocontrols">30 2 * * * /PATH/TO/RUBY /Users/HOMEDIR/scripts/parse_wotd.rb</pre>
<p>You can find your path to ruby by <code>$which ruby</code>. Also, I put a 30 second tutorial on vi at the end of this post for those that don&#8217;t know how to add the above line.</p>
<p>And that&#8217;s it! Every morning a new word will be added to your Dictionary.com flash card set &#8212; now it&#8217;s just a matter of actually studying them.</p>
<p>vi in 30 seconds:<br />
to launch:<br />
$vi FILENAME<br />
x to delete<br />
i to insert<br />
esc to return to normal mode<br />
:q! quits discarding changes<br />
:wq quits saving changes</p>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/broaden-your-vocabulary-with-genius-ruby-and-dictionarycom/feed</wfw:commentRss>
		</item>
		<item>
		<title>Optimizing Ruby Time Creation with Time.local</title>
		<link>http://www.codelikezell.com/optimizing-ruby-time-creation-with-timelocal</link>
		<comments>http://www.codelikezell.com/optimizing-ruby-time-creation-with-timelocal#comments</comments>
		<pubDate>Fri, 19 Oct 2007 12:56:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[benchmarking]]></category>

		<category><![CDATA[DateTime]]></category>

		<category><![CDATA[optimization]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[Time.local]]></category>

		<category><![CDATA[Time.parse]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/optimizing-ruby-time-creation-with-timelocal</guid>
		<description><![CDATA[I have never been one to remember the number of days in a given month, and for a particular project I am working on I needed just that. I did a quick Google search to see if someone has already written a snippet of ruby code that will take care of this for me, and [...]]]></description>
			<content:encoded><![CDATA[<p>I have never been one to remember the number of days in a given month, and for a particular project I am working on I needed just that. I did a quick Google search to see if someone has already written a snippet of ruby code that will take care of this for me, and I found one here and here. The solution is as follows:</p>
<pre class="all:nocontrols">def DaysIn(MonthNum)
  (Date.new(Time.now.year,12,31).to_date&lt;&lt;(12-MonthNum)).day
end</pre>
<p>At first glance it seems like a fine solution — I’m getting 30s and 31s in all of the appropriate places — but then I do something that precludes this from being a reasonable solution: I benchmark it. Oh what a slippery slope it was, but I’ll get into that later. For those just looking for a ruby snippet for days in a month, I wrote an alternative solution that completes in about 2% of the time it takes the solution above:</p>
<pre class="all:nocontrols">def days_in_month(month, year)
  feb = lambda do
    if year % 400 == 0 || year % 4 == 0 &amp;&amp; year % 100 != 0 then 29 else 28 end
  end
  day_array = [31, feb.call, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  day_array[month-1]
end</pre>
<p>So what exactly caused the first solution to take so long? A quick benchmark exposes the culprit as Date.new. I have been doing a lot of date and time manipulations lately (<a href="http://www.naturalinputs.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.naturalinputs.com');">naturalinputs.com</a> is a natural language date and time parser<a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');"></a>), so I begin to worry. I decided to expand my investigation to Ruby’s Time Class, which I prefer to use over Date whenever possible; by passing appropriate strftime parameters I can accomplish most, if not all, of my needs with this class alone. In the past whenever I needed a particular date I would use Time.parse(”yyyymmdd”), which I always thought was working like a champ. Turns out it was working a lot less champ-like than I would have preferred. Two other flavors of Date creation that some of you may be using are Date.parse and Date.strptime. Then there is the DateTime class, with creation methods DateTime.civil, DateTime.parse, and DateTime.strptime. Every one of these methods is slow, horribly slow. But there is a better way, enter Time.local. Here is the benchmark (I created October 10, 2007 ten-thousand times in each case):</p>
<pre class="all:nocontrols">Date.strptime:      5.110000   0.370000   5.480000 (  5.487217)
Date.parse:   	    5.920000   0.420000   6.340000 (  6.329733)
Date.new:           1.010000   0.060000   1.070000 (  1.068610)
DateTime.civil:     2.740000   0.240000   2.980000 (  2.990096)
DateTime.parse:     8.310000   0.610000   8.920000 (  8.916347)
DateTime.strptime:  7.350000   0.700000   8.050000 (  8.046435)
Time.parse:   	    2.570000   0.110000   2.680000 (  2.677252)
Time.local:   	    0.110000   0.010000   0.120000 (  0.118345)</pre>
<p>Yeah, crazy right? Yes, the parameter format of Time.local is annoying, but even using a wrapper to Time.local that takes the same parameters as Time.parse, such as:</p>
<pre class="all:nocontrols">class Time
  class << self
    # Instantiate a Time object with Time.quick_parse("YYYYMMDD")
    def quick_parse(date_str)
      local(date_str[0..3], RFC2822_MONTH_NAME[date_str[4..5].to_i - 1], date_str[6..7])
    end
  end
end
</pre>
<p>The benchmark comes out as:</p>
<pre class="all:nocontrols">Time.parse:   	    2.570000   0.110000   2.680000 (  2.677252)
Time.local:   	    0.110000   0.010000   0.120000 (  0.118345)
Time.quick_parse:   0.160000   0.010000   0.170000 (  0.159252)</pre>
<p>And now I can still use the “yyyymmdd” format that I have sprinkled throughout my app! Congratulations Time.local, you saved the day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/optimizing-ruby-time-creation-with-timelocal/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to install memcached</title>
		<link>http://www.codelikezell.com/how-to-install-memcached</link>
		<comments>http://www.codelikezell.com/how-to-install-memcached#comments</comments>
		<pubDate>Thu, 11 Oct 2007 12:34:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[centos]]></category>

		<category><![CDATA[install memcached]]></category>

		<category><![CDATA[libevent]]></category>

		<category><![CDATA[stop memcached]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/how-to-install-memcached</guid>
		<description><![CDATA[I am using CentOS release 5; to find what version you are using, enter cat /etc/redhat-release
at a bash prompt. That is not to say that these steps won’t work for other linux distros, I just haven’t tried them. Anyway, when I first tried to install memcached I could not create the Makefile due to a [...]]]></description>
			<content:encoded><![CDATA[<p>I am using CentOS release 5; to find what version you are using, enter <code>cat /etc/redhat-release</code><br />
at a bash prompt. That is not to say that these steps won’t work for other linux distros, I just haven’t tried them. Anyway, when I first tried to install memcached I could not create the Makefile due to a dependence on libevent. So first, from /usr/local/src:</p>
<pre class="all:nocontrols">curl -O http://monkey.org/~provos/libevent-1.3e.tar.gz
tar xzvf libevent-1.3e.tar.gz
cd libevent-1.3e
./configure --prefix=/usr/local
make
make install</pre>
<p>Hopefully everything went smoothly for you there. Now on to getting memcached, again from /usr/local/src:</p>
<pre class="all:nocontrols">curl -O http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
tar xzvf memcached-1.2.2.tar.gz
cd memcached-1.2.2
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make
make install</pre>
<p>Now:</p>
<pre class="all:nocontrols:nogutter">memcached -d -u root</pre>
<p>No errors, let’s make sure it’s running:</p>
<pre class="all:nocontrols:nogutter">ps aux | grep memcached</pre>
<p>Awesome! Hey, that’s the name of the blog, how unoriginal.</p>
<p>Now to stop it:</p>
<pre class="all:nocontrols:nogutter">pkill memcached</pre>
<p>I hope that saved you some time.</p>
<p>For those curious as to what that <code>LDFLAGS='-Wl,--rpath /usr/local/lib'</code> is all about, enter at a bash prompt <code>man ld</code></p>
<p>This post prevents the following errors:<br />
configure: error: libevent is required<br />
If It’s already installed, specify its path using –with-libevent=/dir/<br />
memcached: error while loading shared libraries: libevent-1.3e.so.1: cannot open shared object file: No such file or directory</p>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/how-to-install-memcached/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to use javascript to hijack the enter key</title>
		<link>http://www.codelikezell.com/how-to-use-javascript-to-hijack-the-enter-key</link>
		<comments>http://www.codelikezell.com/how-to-use-javascript-to-hijack-the-enter-key#comments</comments>
		<pubDate>Fri, 05 Oct 2007 04:07:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[enter]]></category>

		<category><![CDATA[form]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[javascript key]]></category>

		<category><![CDATA[second submit]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/how-to-use-javascript-to-hijack-the-enter-key</guid>
		<description><![CDATA[Within a form, an auxiliary submit button associated with a single text field is often useful. Here’s how to make the ‘enter’ key submit the auxiliary button, as opposed to the entire form.
&#60;form method="post" onsubmit="alert('submitting form')"&#62;
  &#60;input type="text" onkeypress="return js_on_enter(event, function(){document.getElementById('aux').click()})"&#62;
  &#60;input id="aux" type="button" value="aux submit" onclick="alert('aux');"&#62;&#60;br&#62;
  &#60;input type="text"&#62;&#60;br&#62;
  &#60;input type="submit" [...]]]></description>
			<content:encoded><![CDATA[<p>Within a form, an auxiliary submit button associated with a single text field is often useful. Here’s how to make the ‘enter’ key submit the auxiliary button, as opposed to the entire form.</p>
<pre class="all:nocontrols">&lt;form method="post" onsubmit="alert('submitting form')"&gt;
  &lt;input type="text" onkeypress="return js_on_enter(event, function(){document.getElementById('aux').click()})"&gt;
  &lt;input id="aux" type="button" value="aux submit" onclick="alert('aux');"&gt;&lt;br&gt;
  &lt;input type="text"&gt;&lt;br&gt;
  &lt;input type="submit" value="form submit"&gt;
&lt;/form&gt;</pre>
<p>Now for the javascript:</p>
<pre class="all:nocontrols">&lt;script type="text/javascript"&gt;
	function js_on_enter(e, func)  // Takes event instance and js function as params
	{
		if (!e) e = window.event;  // IE appends event instance to window object
		if (e.keyCode == '13')
		{
			func();
			return false;
		}
		return true;
	}
&lt;/script&gt;</pre>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/how-to-use-javascript-to-hijack-the-enter-key/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to use ruby variables inside regular expressions</title>
		<link>http://www.codelikezell.com/how-to-use-ruby-variables-inside-regular-expressions</link>
		<comments>http://www.codelikezell.com/how-to-use-ruby-variables-inside-regular-expressions#comments</comments>
		<pubDate>Thu, 27 Sep 2007 01:22:00 +0000</pubDate>
		<dc:creator>Lou</dc:creator>
		
		<category><![CDATA[codelikezell]]></category>

		<category><![CDATA[regex]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[string]]></category>

		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://www.codelikezell.com/how-to-use-ruby-variables-inside-regular-expressions</guid>
		<description><![CDATA[In this case it is best to learn by example, fire up irb and enter:
str = "this string has ruby in it"
re = 'ruby'
str =~ /#{re}/
The 16 that gets returned is the location of the first matching character, ‘r’. You can also use this with gsub, for instance:
str = "uhhhh, I don't have a good [...]]]></description>
			<content:encoded><![CDATA[<p>In this case it is best to learn by example, fire up irb and enter:</p>
<pre class="all:nocontrols">str = "this string has ruby in it"
re = 'ruby'
str =~ /#{re}/</pre>
<p>The 16 that gets returned is the location of the first matching character, ‘r’. You can also use this with gsub, for instance:</p>
<pre class="all:nocontrols">str = "uhhhh, I don't have a good example"
speech_correcting_reg_ex = 'uh+,?\s?'
str.gsub!(/#{speech_correcting_reg_ex}/,'')</pre>
<p>And just like that, we have proper English. Should there be a comma there?</p>
<p>Thanks for reading, now find something to do at  <a href="http://www.golark.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.golark.com');">GoLark.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codelikezell.com/how-to-use-ruby-variables-inside-regular-expressions/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
