<?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>Libby Hemphill &#187; Code</title>
	<atom:link href="http://www.libbyh.com/category/technology/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.libbyh.com</link>
	<description>research and posts on social media, collaboration, and related technologies</description>
	<lastBuildDate>Wed, 23 Jun 2010 16:38:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Ruby on Rails on Snow Leopard</title>
		<link>http://www.libbyh.com/2009/10/18/ruby-on-rails-on-snow-leopard/</link>
		<comments>http://www.libbyh.com/2009/10/18/ruby-on-rails-on-snow-leopard/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 17:12:58 +0000</pubDate>
		<dc:creator>libbyh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://www.libbyh.com/?p=494</guid>
		<description><![CDATA[I finally tackled the (hopefully) last bit of my Snow Leopard upgrade today: getting Ruby (and Rails) ready to go. I'm working on an information visualization project and am using Ruby to write the app. Mike Gunderloy at A Fresh Cup has a great step by step guide (I started at step 19 since I [...]]]></description>
			<content:encoded><![CDATA[<p>I finally tackled the (hopefully) last bit of my Snow Leopard upgrade today: getting Ruby (and Rails) ready to go. I'm working on an information visualization project and am using Ruby to write the app. Mike Gunderloy at A Fresh Cup has a great step by step guide (I started at step 19 since I was happy to upgrade in place):</p>
<p><a title="RoR dev" href="http://afreshcup.com/2009/09/02/migrating-to-snow-leopard-for-rails-development-a-definitive-guide/">Migrating to Snow Leopard for Rails Development</a></p>
<p>As always happens when upgrading or installing, it seems, I did run into a few problems.</p>
<p><strong>Errors and Workarounds</strong></p>
<p><em>Problem</em>: Git doesn't want to install.</p>
<p><em>Error</em>:</p>
<p><code>ld: warning: in /opt/local/lib/libiconv.dylib, file is not of required architecture</code></p>
<p><em>Workaround</em>:</p>
<p>MacPorts is to blame. To uninstall MacPorts, use</p>
<p><code>sudo rm -rf \<br />
/opt/local \<br />
/etc/manpaths.d/macports \<br />
/etc/paths.d/macports \<br />
/Applications/DarwinPorts \<br />
/Applications/MacPorts \<br />
/Library/LaunchDaemons/org.macports.* \<br />
/Library/Receipts/DarwinPorts*.pkg \<br />
/Library/Receipts/MacPorts*.pkg \<br />
/Library/StartupItems/DarwinPortsStartup \<br />
/Library/Tcl/darwinports1.0 \<br />
/Library/Tcl/macports1.0</code></p>
<p>(Thanks, <a title="Simon Engledew on reinstalling git" href="http://blog.engledew.com/post/reinstalling-git-on-snow-leopard">Simon Engledew</a>)</p>
<p><em>Problem</em>: MySQL gem doesn't install.</p>
<p><em>Error</em>:</p>
<p><code>ERROR: Failed to build gem native extension mysql</code></p>
<p><em>Workaround</em>:</p>
<p>Make sure you installed the <a title="MySQL Download page" href="http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg">latest version of MySQL</a>, the <a title="Swoon" href="http://www.swoon.net/site/software.html">MySQL Preference Pane</a>, and that you started the MySQL server before trying to install the gem. iCoreTech has <a title="iCoreTech" href="http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/">directions for installing MySQL and MySQL gem on Snow Leopard</a>.</p>
<p><strong>Other Options</strong></p>
<p>HiveLogic has another method for <a title="HiveLogic" href="http://hivelogic.com/articles/compiling-git-on-snow-leopard/">installing Git on Snow Leopoard</a>. I was having trouble with the package installers, and doing it "by hand" via HiveLogic's instructions worked well.</p>
<p>My project uses RMagick. RMagick's DMG installer wouldn't work for me either. I was able to <a title="Install RMagick from source" href="http://onrails.org/articles/2009/09/04/rmagick-from-source-on-snow-leopard">install RMagick from source using a script from OnRails.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.libbyh.com/2009/10/18/ruby-on-rails-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Upgraded SVN Working on a Mac OS X Server</title>
		<link>http://www.libbyh.com/2009/06/26/get-upgraded-svn-working-on-a-mac-os-x-server/</link>
		<comments>http://www.libbyh.com/2009/06/26/get-upgraded-svn-working-on-a-mac-os-x-server/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 00:46:11 +0000</pubDate>
		<dc:creator>libbyh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.libbyh.com/?p=427</guid>
		<description><![CDATA[Jeremy Whitlock has a great blog post about how to set up your OS X-based Subversion server. His post includes instructions for Apache configs, but not for svn+ssh. When you type svn+ssh://user@host/repos you'll likely get an error such as svn: Expected FS format '2'; found format '4' which means that you're repository was created in [...]]]></description>
			<content:encoded><![CDATA[<p>Jeremy Whitlock has a <a href="http://blogs.open.collab.net/svn/2009/05/building-an-os-x-based-subversion-server.html">great blog post about how to set up your OS X-based Subversion server</a>. His post includes instructions for Apache configs, but not for svn+ssh. When you type</p>
<p><code>svn+ssh://user@host/repos</code></p>
<p>you'll likely get an error such as</p>
<p><code>svn: Expected FS format '2'; found format '4'</code></p>
<p>which means that you're repository was created in a newer version of SVN than the version you run when you call svn+ssh. Using Jeremy's instructions results in two versions of Subversion being available on your server - one in /usr/local and one in /opt/subversion. In order to use the one in /opt/subversion (the newest one) through an SSH tunnel, you need to make some SSH configuration changes on your server.</p>
<p>Getting svn+ssh to work requires:<br />
1. Set (or uncomment) <code>PermitUserEnvironment Yes</code> in <code>/etc/sshd_config</code> (on server)<br />
2. Add <code>PATH=/opt/subversion/bin:$PATH</code> to <code>~/.ssh/environment</code> (on server; may have to create the environment file)<br />
3. restart SSH (on server) with <code>sudo /sbin/service ssh stop</code> and <code>sudo /sbin/service ssh start</code><br />
Ta da!</p>
<p>Thanks for the jumpstart, Jeremy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.libbyh.com/2009/06/26/get-upgraded-svn-working-on-a-mac-os-x-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript date checking</title>
		<link>http://www.libbyh.com/2009/03/14/javascript-date-checking/</link>
		<comments>http://www.libbyh.com/2009/03/14/javascript-date-checking/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 20:27:52 +0000</pubDate>
		<dc:creator>libbyh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[adSense]]></category>

		<guid isPermaLink="false">http://www.libbyh.com/blog/?p=371</guid>
		<description><![CDATA[Sometimes we ask users to enter a date range. I wrote some code today to check whether the date a user entered was (1) after today and (2) before some other date she entered. In my situation, I was building a flight search form and wanted to check that the user-entered departure date was before [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we ask users to enter a date range. I wrote some code today to check whether the date a user entered was (1) after today and (2) before some other date she entered. In my situation, I was building a flight search form and wanted to check that the user-entered departure date was before the user-entered return date and that the user wasn't trying to depart in the past. To do this, I needed to turn the user's input into a JavaScript Date and then compare that Date to Today's date. I found a lot of similar code online, but none of it work quite right.</p>
<p>I have a form with text box inputs for dateDepart and dateReturn. This code takes those inputs, turns them in JavaScript dates, compares them to each other and to today, and returns alerts or submits the form, depending on how the comparisons shake out.</p>
<p>Here's my code:</p>
<pre class="code">// check to make sure Return date is after Departure date, and both are after today
if ( (the_form.dateDepart.value !="") &amp;&amp; (the_form.dateReturn.value !="") )
{
	var strFromDate = the_form.dateDepart.value;
	var dayPartFromDate = parseInt(strFromDate.substring(3,5),10);
	var monPartFromDate = parseInt(strFromDate.substring(0,2),10);
	var yearPartFromDate = parseInt(strFromDate.substring(6,10),10);
	var dtDepart = new Date(yearPartFromDate, monPartFromDate-1, dayPartFromDate);

	var strToDate = the_form.dateReturn.value;
	var dayPartToDate = parseInt(strToDate.substring(3,5),10);
	var monPartToDate = parseInt(strToDate.substring(0,2),10);
	var yearPartToDate = parseInt(strToDate.substring(6,10),10);
	var dtReturn = new Date(yearPartToDate, monPartToDate-1, dayPartToDate);
	var now = new Date();
	var today = new Date(now.getFullYear(),now.getMonth(),now.getDate());	

	if(dtDepart &gt; dtReturn)
	{
		alert('Departure date must be before return date. Please fix and resubmit.');
		return false;
	}
	else if (dtDepart &lt; today)
	{
		alert('Departure date must be after today. Please fix and resubmit.');
		return false;
	}
	else
	{
		the_form.submit();
	}
}</pre>
<p><strong>Turn User Input into a JavaScript Date</strong><br />
To turn the user's input into a Date, I needed to parse the input and then pass the pieces to the <code>Date()</code> function.</p>
<p>The JavaScript <code>substr</code> function syntax I used corresponds to <code>dateToChange.substring(start,finish)</code>. My users are mostly in the U.S., and they enter dates in the form MM/DD/YYYY, e.g., 03/14/2009. JavaScript starts counting at 0, so the <code>substr</code> functions above grab "14" for the day, "03" for the month, and "2009" for the year and then pass those substrings to the <code>Date()</code>function to be converted in a Date JavaScript understands.</p>
<p><code>getFullYear();</code> returns a four-digit year such as "2009" that makes it easy to compare to the default version of today's date that<br />
<code>var now = new Date();<br />
var today = new Date(now.getFullYear(),now.getMonth(),now.getDate());</code><br />
gives.</p>
<p>Why <code>monPartToDate-1</code>? Remember, JavaScript starts counting at 0, so January is month 0, and December is month 11. That means I need to subtract 1 from what my user entered to get the right month for JavaScript.</p>
<p><strong>Compare Dates</strong><br />
I needed to compare the two dates the user entered to make sure she had departure first, then return. Once I have converted both her inputs to JavaScript dates, the comparison uses a simple "greater than" operator:  <code>dtDepart &amp;gt; dtReturn</code></p>
<p><strong>Calling the Date-checking Function</strong><br />
You'll notice my code doesn't include a function declaration; that's because this date-checking procedure is part of a larger function to validate my form. You could wrap this code in a function declaration such as<br />
<code>function checkDates(the_form){}</code></p>
<p>In order to call the code when the user submits the form, I like to use something like</p>
<p><code>&lt;input id="search" onclick="checkDates(this.form);" type="button" value="Submit Form" /&gt;</code></p>
<p>in the HTML.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.libbyh.com/2009/03/14/javascript-date-checking/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Technology I could use</title>
		<link>http://www.libbyh.com/2008/08/06/technology-i-could-use/</link>
		<comments>http://www.libbyh.com/2008/08/06/technology-i-could-use/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 00:12:04 +0000</pubDate>
		<dc:creator>libbyh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.libbyh.com/blog/?p=192</guid>
		<description><![CDATA[Here are two things I want that I don't have the time (or probably the skills) the code: 1. A flight search engine that searches flights from multiple destinations to one.  I want to use this when planning trips with my family and friends.  We don't all live in the same place.  We'd like to [...]]]></description>
			<content:encoded><![CDATA[<p>Here are two things I want that I don't have the time (or probably the skills) the code:</p>
<p>1. A flight search engine that searches flights from multiple destinations to one.  I want to use this when planning trips with my family and friends.  We don't all live in the same place.  We'd like to get together.  This seems like a pretty common task (e.g. national holidays, girls' weekend, bachelor parties, etc.).  I shouldn't have to search each person's flight independently and then hope that the one around the time of everyone else's doesn't sell out or go up in price before I find flights for everyone.  I'm pretty sure Kayak's API could do this, but I don't have time to figure it out.</p>
<p>2. Movies starting near me in the next couple of hours with the added bonus of web ticket sales.  This seems like an iPhone app that should already exist.  I can't even find this on the web though.  Does movietickets.com or some other site let me search by zip code and time?</p>
<p>Anybody know where I can find these or want to build them for me for free?  Sweet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.libbyh.com/2008/08/06/technology-i-could-use/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Moving Data</title>
		<link>http://www.libbyh.com/2008/07/27/moving-data/</link>
		<comments>http://www.libbyh.com/2008/07/27/moving-data/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 02:07:44 +0000</pubDate>
		<dc:creator>libbyh</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.libbyh.com/blog/?p=182</guid>
		<description><![CDATA[A couple months ago someone hacked into a perfectly innocent server some friends and I use for things like storing backups of our dissertations and running Perl scripts. I was in Seattle when this happened so couldn't be much help in the recovery process. The helpful people at SI Computing recovered all the data from [...]]]></description>
			<content:encoded><![CDATA[<p>A couple months ago someone hacked into a perfectly innocent server some friends and I use for things like storing backups of our dissertations and running Perl scripts.  I was in Seattle when this happened so couldn't be much help in the recovery process.  The helpful people at SI Computing recovered all the data from the server and put in on another server ("SIC") for me to access.  My job was to move all the data from SIC to a third place so that SI Computing could have their Projects space back.  I haven't ever had to remotely administer such a data transfer task.  So, I had to learn a few new UNIX commands.  Here's how I was able to move 57GB of data from the "SIC" server to the "Hosted" server.  I used "<code>screen</code>" and "<code>scp</code>" commands to securely copy my data without requiring a Terminal window to stay open for the 36 hours it took the data transfer to complete.  The most helpful websites I could find for those are</p>
<p>screen: <a href="http://jmcpherson.org/screen.html">http://jmcpherson.org/screen.html</a><br />
scp: <a href="http://kb.iu.edu/data/agye.html">http://kb.iu.edu/data/agye.html</a></p>
<p><code>1. ssh libbyh@sic.edu<br />
2. screen<br />
3. scp MyData libbyh@hosted.com:MyData<br />
4. Ctrl+A, d<br />
5. exit</code></p>
<p>That should do it.  You can check in on the data transfer by typing this at the prompt:<br />
<code>screen -r</code><br />
Hopefully your next big data migration will go as smoothly as mine did.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.libbyh.com/2008/07/27/moving-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.820 seconds -->
