<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Dabbler &#187; Software</title>
	<atom:link href="http://sethjust.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://sethjust.com</link>
	<description>If it ain&#039;t broke, fix it!</description>
	<lastBuildDate>Sun, 14 Aug 2011 18:56:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>IndieWeb, or how to avoid Digital Sharecropping</title>
		<link>http://sethjust.com/2011/08/14/indieweb-or-how-to-avoid-digital-sharecropping/</link>
		<comments>http://sethjust.com/2011/08/14/indieweb-or-how-to-avoid-digital-sharecropping/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 18:54:57 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[addon]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[social]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=332</guid>
		<description><![CDATA[Thanks to the DorkbotPDX blog I found my way onto the website of this year&#8217;s IndieWebCamp, which took place in Portland June 25 &#38; 26. Although I was saddened that I wasn&#8217;t in town for it, the projects that ended up being developed by the camp immediately grabbed my interest. Although I had never been [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to the <a href="http://dorkbotpdx.org/">DorkbotPDX blog</a> I found my way onto the website of this year&#8217;s <a href="http://indiewebcamp.com/Main_Page">IndieWebCamp</a>, which took place in Portland June 25 &amp; 26. Although I was saddened that I wasn&#8217;t in town for it, the <a href="http://indiewebcamp.com/Demos">projects</a> that ended up being developed by the camp immediately grabbed my interest.</p>
<p>Although I had never been aware of the term &#8220;indie web&#8221; (which seems to have been around for almost 15 years, judging by <a href="http://www.uzine.net/article63.html">this article</a> from uzine.net), I&#8217;ve been building my own independent web presence for more than four years. In the words of the IndieWebCamp home page:</p>
<blockquote><p>Rather than posting content on many third-party silos of content, we should all begin owning the content we&#8217;re creating. Publish short status updates on your own domain, and syndicate to Twitter. Publish photos on your own domain, syndicate to Flickr, etc, etc.</p></blockquote>
<p>For some good summaries of the ideas and goals of the IndieWebCamp, <a href="http://gigaom.com/collaboration/the-indie-web-who-owns-your-identity/">this article</a> from GigaOm and <a href="http://markmhendrickson.com/homesteading-on-the-indie-web">this post</a> from Mark Hendrickson are a great place to start, while each of the camp&#8217;s <a href="http://indiewebcamp.com/Guest_List">guests</a> also have their own websites, each with a wealth of information.</p>
<p>While I&#8217;ve been using this domain for quite a while, it&#8217;s been in use alongside Facebook, Delicious (and Flickr, to a smaller degree) as a part of my web presence. However, since I ditched Facebook five or six months ago, I&#8217;ve been relying on this domain for more, and overall I&#8217;ve been pleased. However, as the IndieWebCamp is readily willing to admit, there is room for a lot of room for technical innovation in expanding the functionality of the indie web. Towards that end, I see three threads of work that I&#8217;m interested in pursuing:</p>
<ul>
<li>Using my site for Flickr-like photo sharing. While this might include syndication to Flickr at some point, I mostly want a light-weight DIY solution to photo sharing.</li>
<li>Similarly, using my site for bookmarking. I really like the service that delicious offers, but I want to own the data and let delicious simply keep a copy of it (see <a href="http://adactio.com/journal/4197/">http://adactio.com/journal/4197/</a> for some ideas).</li>
<li>Finally, I&#8217;m hugely enamored of the work on delivery-agnostic messaging that took place at IndieWebCamp, which you can find details of <a href="http://aaronparecki.com/IndieWeb_Messaging">here</a>. Not only is it a ridiculously simple protocol, but it starts to address some real issues of a distributed social web, in that it allows two-party communication based solely on domain names as unique identifiers, therefore eliminating the middleman in social-web-type communications.</li>
</ul>
<div>Hopefully I&#8217;ll have time to get one of these ideas worked out and running on my site soon (before school starts), so check back here soon, I&#8217;ll be sure to keep you posted.</div>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/08/14/indieweb-or-how-to-avoid-digital-sharecropping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Map Tiles with Python + GDAL</title>
		<link>http://sethjust.com/2011/07/13/map-tiles-with-python-gdal/</link>
		<comments>http://sethjust.com/2011/07/13/map-tiles-with-python-gdal/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 21:36:55 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[gdal]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=341</guid>
		<description><![CDATA[After getting GPSDrive running on OS X I started looking into different sources for maps. The GPSDrive wiki has a couple of interesting pages about this: one on creating maps and one on map sources. The second page pointed me to the LibreMap Project which has a complete collection of  USGS 1:24000 (large scale) topographic maps for the [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://sethjust.com/2011/07/13/gpsdrive-on-os-x/">getting GPSDrive running on OS X</a> I started looking into different sources for maps. The GPSDrive wiki has a couple of interesting pages about this: one on <a href="http://sourceforge.net/apps/mediawiki/gpsdrive/index.php?title=Creating_maps">creating maps</a> and one on <a href="http://sourceforge.net/apps/mediawiki/gpsdrive/index.php?title=Data_sources">map sources</a>. The second page pointed me to <a href="http://libremap.org/">the LibreMap Project</a> which has a complete collection of  USGS 1:24000 (large scale) topographic maps for the entire US. These files are distributed as high-resolution GeoTIFF files, along with <a href="http://en.wikipedia.org/wiki/World_file">world files</a>, so the maps are fully geotagged. This means that they contain all of the information needed to generate GPSDrive-friendly map tiles, but GPSDrive will not read them directly. The <a href="http://sourceforge.net/apps/mediawiki/gpsdrive/index.php?title=Creating_maps">creating maps</a> page gives some (heavily out-of-date) advice on how to use the <span style="font-family: monospace;">gdal_slice.sh</span> script distributed with GPSDrive to create map tiles using the tools from <a href="http://gdal.org/">GDAL</a>. Sadly, this script is completely unusable on OS X, because of incompatibilities in the command line tools that are used by the shell script. After spending about five minutes trying to tune it to work with the tools that Apple ships, I completely gave up and looked into other approaches.</p>
<p>Luckily, I quickly found out that GDAL ships with Python bindings. I installed GDAL from <a href="https://trac.osgeo.org/gdal/wiki/DownloadSource">source</a> using the <a href="https://trac.osgeo.org/gdal/wiki/BuildingOnUnix">instructions</a> from their wiki. To make sure it built with Python modules I ran <span style="font-family: monospace;">./configure &#8211;with-python</span>. After that <span style="font-family: monospace;">make</span> and <span style="font-family: monospace;">sudo make install</span> ran without a hitch.</p>
<p>I then set about re-implementing <span style="font-family: monospace;">gdal_slice.sh</span> in Python. Once I got a handle on how to use the Python bindings it was fairly easy to write. You can find the script <a href="http://homepage.sethjust.com/files/gdal_slice.txt">here</a>.</p>
<p>Using <span style="font-family: monospace;">gdal_slice.py</span> is very similar to using <span style="font-family: monospace;">gdal_slice.sh</span>:</p>
<pre>$ ./gdal_slice.py -h
Usage: gdal_slice.py [options] FILENAME

Options:
  -h, --help            show this help message and exit
  -o OVERLAP, --overlap=OVERLAP
                        percentage tiles will overlap. should be at least 20%
  -a, --add             write map info to map_koord.txt in current working
                        directory
  -m, --map             use *_map folders for output; use if input image is
                        UTM. Default behavior
  -t, --topo            use *_top folders for output; use if input image is
                        not UTM
  -v, --verbose         enable debugging output</pre>
<p>The biggest difference is that <span style="font-family: monospace;">gdal_slice.py</span> does not perform any format conversion; it will write maps to TIFF files. Although the file size is decidedly larger than that of PNGs, my version of GDAL is unable to create PNGs, and disk space is (fairly) cheap. If I&#8217;m motivated I&#8217;ll get around to adding a format option, at least to allow conversion to PNG.</p>
<p>Running <span style="font-family: monospace;">gdal_slice.py filename.ext</span> will create a folder named filename_map (or _top, if you use the -t flag) that contains a set of 1280&#215;1024 TIFF files, as well as a map_koord_draft.txt file. Moving this folder into GPSDrive&#8217;s map directory, and merging filename_[map|top]/map_koord_draft.txt with map_koord.txt will make the new maps available to GPSDrive. Note that filename.ext must be in the current working directory, as the script handles filenames/paths somewhat naivëly.</p>
<p>So far I&#8217;ve only tested this with GeoTIFFs from LibreMaps, but it seems to work great, with the caveat that LibreMaps&#8217; files include the borders of map, and my script doesn&#8217;t do any cropping, so you see borders if you&#8217;re near the edges of quads. This doesn&#8217;t bother me terribly much, but you may need to turn mapsets on and off in the Map Control dialog to see the appropriate images.</p>
<p><b>Update 7-14-11:</b> I&#8217;ve modified the script with an additional flag (-a) that will automatically merge the generated map_koords file with map_koord.txt in the current working directory. This means that if you run the script from inside .gpsdrive/maps with the -a flag the generated tiles will be automatically added to GPSDrive&#8217;s database. The script avoids creating duplicate entries in map_koord.txt, as well as alphabetizing all entries.</p>
<p>I&#8217;ve modified the documentation here, as well as the links, to reference the latest version.</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/07/13/map-tiles-with-python-gdal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>GPSDrive on OS X</title>
		<link>http://sethjust.com/2011/07/13/gpsdrive-on-os-x/</link>
		<comments>http://sethjust.com/2011/07/13/gpsdrive-on-os-x/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 19:30:37 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=303</guid>
		<description><![CDATA[After getting GPSd to compile on OS X, I set my sights on GPSDrive, an open source navigation and map viewing program. When I posted about GPS a couple years ago, I installed GPSDrive, using the version from Fink. However, the latest version of GPSDrive on Fink nowadays is 2.08pre12, while the latest stable release [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/">getting GPSd to compile on OS X</a>, I set my sights on <a href="http://www.gpsdrive.de/">GPSDrive</a>, an open source navigation and map viewing program. When I <a href="http://sethjust.com/2009/01/13/gpsd-under-os-x/">posted about GPS a couple years ago</a>, I installed GPSDrive, using the version from Fink. However, the latest version of GPSDrive on Fink nowadays is 2.08pre12, while the latest stable release is 2.11. I&#8217;ve also moved away from using Fink and/or MacPorts for package management in favor of <a href="http://mxcl.github.com/homebrew/">Homebrew</a>.</p>
<p>To get GPSDrive running I had to do a little bit of fiddling, but it&#8217;s fairly easy. First off, I needed to downgrade GPSd from 2.96 to 2.95 &#8212; apparently the newest version introduced slight changes to the library that GPSDrive hasn&#8217;t yet picked up. However, building the two versions is exactly the same &#8212; see my <a href="http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/">post on building 2.96</a> for instructions that apply to 2.95. You can get the source package for either version <a href="http://developer.berlios.de/project/showfiles.php?group_id=2116">here</a>.</p>
<p>Next I used homebrew to install the dependencies that GPSDrive needs by running <span style="font-family: monospace;">brew install gtk+ cairo gtkglext postgresql gettext</span>. Note that these are just the packages I didn&#8217;t have going into the build &#8212; you may need more, depending on your setup.</p>
<p>With preliminaries out of the way, I downloaded gpsdrive-2.11 from <a href="http://www.gpsdrive.de/download.shtml">here</a>. As per their build instructions I created a build directory (mkdir build), moved into it (cd build), and then ran cmake. After some serious wrestling with dependency locations and linker flags I figured out the following two steps to get GPSDrive to compile and build.</p>
<p>First, because GPSDrive seems to want to automatically link against libcrypt, which OS X bundles in it&#8217;s libc, you need to tell cmake not to use it. I couldn&#8217;t figure out how to do with with a cmake configuration option, so I edited gpsrive-2.11/src/CMakeLists.txt and commented out (put a # in front) of the two lines containing the word &#8220;crypt&#8221;. You could also delete these lines &#8212; it has the same effect. This is along the lines of the patch <a href="http://lists.gpsdrivers.org/pipermail/gpsdrive/2010-March/002452.html">here</a> (see the attachment), that was posted to the GPSDrive mailing list last year, when I pointed out this bug. Sadly, the patch has not been applied to the source tree yet, but I can attest it works, if you care to apply it yourself.</p>
<p>With that out of the way, we can now run the following command from inside the build directory.</p>

<div class="wp_codebox"><table><tr id="p3032"><td class="code" id="p303code2"><pre class="text" style="font-family:monospace;">cmake -DCMAKE_BUILD_TYPE=Debug\
 -DWITH_FRIENDSD=OFF\
 -DWITH_KISMET=OFF\
 -DWITH_MAPNIK=OFF\
 -DWITH_POSTGIS=OFF\
 -DWITH_SPEECH=OFF\
 -DLIBGPS_OLD=OFF\
 -DGTK2_ATK_INCLUDE_PATH=/usr/local/Cellar/atk/2.0.0/include/atk-1.0\
 -DGTK2_GLIBCONFIG_INCLUDE_PATH=/usr/local/lib/glib-2.0/include\
 -DGTK2_GLIB_INCLUDE_PATH=/usr/local/include/glib-2.0\
 -DGTK2_PANGO_INCLUDE_PATH=/usr/local/Cellar/pango/1.28.4/include/pango-1.0\
 -DGTK2_CAIRO_INCLUDE_PATH=/usr/local/Cellar/cairo/1.10.2/include/cairo\
 -DGTK2_GDKCONFIG_INCLUDE_PATH=/usr/local/Cellar/gtk+/2.24.4/lib/gtk-2.0/include\
 -DGTK2_GTK_LIBRARY=/usr/local/lib/libgtk-x11-2.0.0.dylib\
 -DCMAKE_C_FLAGS=&quot;-I/usr/local/Cellar/gdk-pixbuf/2.22.1/include/gdk-pixbuf-2.0&quot;\
 -DCMAKE_EXE_LINKER_FLAGS=&quot;-lgdk_pixbuf-2.0.0 -lpango-1.0.0 -lgobject-2.0.0 -L/usr/local/Cellar/gettext/0.18.1.1/lib -lintl&quot;\
 -DMSGFMT_EXECUTABLE=/usr/local/Cellar/gettext/0.18.1.1/bin/msgfmt\
 ..</pre></td></tr></table></div>

<p>After cmake generates all the necessary files, you can run <span style="font-family: monospace;">make</span>, and assuming it doesn&#8217;t give you errors, <span style="font-family: monospace;">./src/gpsdrive</span> will allow you to test your newly built executable, and <span style="font-family: monospace;">sudo make install</span> will install it.</p>
<p>Once GPSDrive is up and running you should be able to see your current location (assuming you have a GPS connected to GPSd). If you want to get maps, you can download them from within GPSDrive, which has support for OpenStreeMap tiles, as well as NASA Landsat images (although I haven&#8217;t been able to get Landsat to download correctly).</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/07/13/gpsdrive-on-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Sign your email like Randall Waterhouse</title>
		<link>http://sethjust.com/2011/07/11/sign-your-email-like-randall-waterhouse/</link>
		<comments>http://sethjust.com/2011/07/11/sign-your-email-like-randall-waterhouse/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 00:57:04 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[Mail.app]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=307</guid>
		<description><![CDATA[Neal Stephenson&#8217;s novel Cryptonomicon is a fascinating book; I&#8217;m re-reading it for the umpteenth time and loving it every bit as much as when I first read it in 7th grade. One thing that caught my attention on this reading (especially in light of my recent GPS post) is the way that one of the main [...]]]></description>
			<content:encoded><![CDATA[<p>Neal Stephenson&#8217;s novel <em><a href="http://www.amazon.com/gp/product/B004R96U4A/ref=as_li_ss_tl?ie=UTF8&#038;tag=dabbler-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399373&#038;creativeASIN=B004R96U4A">Cryptonomicon</a><img src="http://www.assoc-amazon.com/e/ir?t=&#038;l=as2&#038;o=1&#038;a=B004R96U4A&#038;camp=217145&#038;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></em> is a fascinating book; I&#8217;m re-reading it for the umpteenth time and loving it every bit as much as when I first read it in 7th grade. One thing that caught my attention on this reading (especially in light of my recent <a href="http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/">GPS post</a>) is the way that one of the main characters, Randall Lawrence Waterhouse, signs his email:</p>
<blockquote><p>Randall Lawrence Waterhouse</p>
<p>Current meatspace coordinates, hot from the GPS receiver card in my laptop:</p>
<p>8 degrees, 52.33 minutes N latitude 117 degrees, 42.75 minutes E longitude</p>
<p>Nearest geographical feature: Palawan, the Philippines</p></blockquote>
<p>(from <a href="http://www.euskalnet.net/larraorma/crypto/slide51.html">http://www.euskalnet.net/larraorma/crypto/slide51.html</a>)</p>
<p>Using GPSd&#8217;s python bindings, and the free, CC-licenced RESTful API from <a href="http://geonames.org">GeoNames.org</a>, I wrote a short python script that will produce a similar output:</p>
<blockquote><p>Seth Just</p>
<p>Current meatspace coordinates, hot from the GPS receiver card in my laptop:</p>
<p>41.751 N latitude, 111.807 W longitude</p>
<p>Nearest geographical feature: Logan Canyon, Utah, United States</p></blockquote>
<p>The core of the script is two functions &#8212; one that gets GPS coordinates from GPSd, and a second that does a lookup for geographical features (mountains, canyons, islands, etc) on <a href="http://geonames.org">GeoNames.org</a>. For more details, see the final section of this post.</p>
<h2>Using gpssig.py</h2>
<p>To use gpssig.py, first download it from <a href="http://homepage.sethjust.com/files/gpssig.txt">here</a>, and change the extension to .py.</p>
<p>In order to be useful as an email signature, I had to produce output in HTML format, which allows almost any mail client to use the output as a signature. I&#8217;ve gone through the effort of setting it up with the two clients I use the most: Mozilla Thunderbird and Apple&#8217;s Mail.app. Of these two, Thunderbird has documented support for HTML signatures (see <a href="http://opensourcearticles.com/thunderbird_15/english/part_03">here</a> for details), and should be the most like other email clients. This script has been tested on Mac OS X Snow Leopard, and should run on Linux without problems (although I haven&#8217;t tried it on versions of python higher than 2.6.1).</p>
<p>Using gpssig.py takes two steps: first configure your Mail client to take a signature from a file, and then configure gpssig.py to run automatically to update that file.</p>
<p>Thunderbird is relatively easy to set up with an HTML signature. Because it only supports one signature per account, you simply need to tell it to draw that signature from a file. Under each account&#8217;s settings there&#8217;s an option to &#8220;Attach the signature from a file&#8221; (see <a href="http://opensourcearticles.com/thunderbird_15/english/part_03">here</a> for a detailed howto). I chose to use ~/.signature.html, but you can use any file you&#8217;d like to, just remember the location you choose.</p>
<p>Mail.app is a more finicky beast &#8212; although the script supports it, I recommend using Thunderbird, mainly because Mail only refreshes its signatures from files on every launch, whereas Thunderbird will read the file each time you compose a message. However, if that limitation is acceptable (if you don&#8217;t move very much, perhaps), it will work just fine. The main issue with Mail.app is that it doesn&#8217;t store signatures in an HTML file, but instead in the proprietary <a href="http://en.wikipedia.org/wiki/Webarchive">.webarchive</a> format. These files can be found in ~/Library/Mail/Signatures. To use gpssig.py with Mail, you need to follow steps 4&amp;5 from <a href="http://bytes.com/topic/macosx/insights/825900-setup-html-signatures-apple-mail-mail-app">http://bytes.com/topic/macosx/insights/825900-setup-html-signatures-apple-mail-mail-app</a>. First create a new signature (under Preferences-&gt;Signatures). This will create a new file in the signature folder &#8212; take note of the file name. You will use this file name to configure gpssig.py.</p>
<p>gpssig.py is configured with command line options:</p>
<pre>Usage: gpssig.py [options] NAME FILENAME
Note: NAME should be enclosed in quotes, unless it contains no spaces.

Options:
  -h, --help   show this help message and exit
  --no-gps     don't attempt to get coordinates from GPS
  -a, --amail  generate files for Apple's Mail.app (.webarchive)
  --lat=LAT    default latitude, if GPS is unavailable
  --lon=LON    default longitude, if GPS is unavailable</pre>
<p>The simplest way to use it is manually &#8212; simply running it whenever you want to update your signature. For example, I use <span style="font-family:monospace;">./gpssig.py &#8211;lat=41.752 &#8211;lon=-111.793 &#8216;Seth Just&#8217; ~/.signature.html</span> to generate a signature for Thunderbird.</p>
<p>If you want to make this automatic, you&#8217;ll need to have the script run automatically. On OS X you&#8217;ll need to use launchd, while on linux you need cron. Both of these make setting up repeating actions very easy &#8212; see <a href="https://arunxjacob.wordpress.com/2008/08/28/mac-launchd-and-launchctl-the-osx-alternative-to-cron/">here</a> for information on launchd and <a href="https://arunxjacob.wordpress.com/2008/08/28/mac-launchd-and-launchctl-the-osx-alternative-to-cron/">here</a> for information on cron.</p>
<p>Sadly I haven&#8217;t yet figured out a way to run the script whenever you write an email &#8212; if I figure it out, I&#8217;ll be sure to post something.</p>
<h2>The Script</h2>
<p>gpssig.py is built around three major functions &#8212; one gets coordinates from GPSd, one gets geographical feature information from</p>
<p>The function I use to get GPS information is a bit hacky &#8212; there doesn&#8217;t seem to be terribly much documentation on GPSd&#8217;s python bindings, so I made do with what I could figure out:</p>

<div class="wp_codebox"><table><tr id="p3076"><td class="code" id="p307code6"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> NoGPSError <span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> get_lat_lon<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># GPSd Python bindings</span>
  <span style="color: #ff7700;font-weight:bold;">import</span> gps
&nbsp;
  <span style="color: #808080; font-style: italic;"># Create GPS object</span>
  session = gps.<span style="color: black;">gps</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># Set GPS object as an iterator over reports from GPSd</span>
  session.<span style="color: black;">stream</span><span style="color: black;">&#40;</span>gps.<span style="color: black;">WATCH_ENABLE</span>|gps.<span style="color: black;">WATCH_NEWSTYLE</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># Loop until we get a report with lat and lon. The limit of 5 loops should be more than enough -- my gps never takes more than three when it has a lock</span>
  i = <span style="color: #ff4500;">0</span>
  <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      session.<span style="color: black;">next</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      lat, lon = session.<span style="color: black;">data</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'lat'</span><span style="color: black;">&#93;</span>, session.<span style="color: black;">data</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'lon'</span><span style="color: black;">&#93;</span>
      <span style="color: #ff7700;font-weight:bold;">break</span>
    <span style="color: #ff7700;font-weight:bold;">except</span>:
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>i <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span> <span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">raise</span> NoGPSError 
      i += <span style="color: #ff4500;">1</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">return</span> lat, lon</pre></td></tr></table></div>

<p>The other function is more straightforward &#8212; it makes two http requests to <a href="http://geonames.org">GeoNames.org</a> to get the nearest geographical feature and locality. It then combines those responses in a way that should provide a good response almost anywhere in the world (provided that GeoNames has good, local data). I&#8217;ve tested it with a variety of coordinates (provided by <a href="http://www.getlatlon.com/">http://www.getlatlon.com/</a>), and the responses seem to be pretty good.</p>

<div class="wp_codebox"><table><tr id="p3077"><td class="code" id="p307code7"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> get_geo_string<span style="color: black;">&#40;</span>lat, lon<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># Modules for REST/XML request from GeoNames</span>
  <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
  <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">etree</span> <span style="color: #ff7700;font-weight:bold;">import</span> ElementTree <span style="color: #ff7700;font-weight:bold;">as</span> ET
&nbsp;
  <span style="color: #808080; font-style: italic;"># Request the name of the nearest geographical feature</span>
  placename = ET.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>
      <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://api.geonames.org/findNearby?lat=&quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>lat<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;&amp;lng=&quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>lon<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;&amp;featureClass=T&amp;username=sethjust&quot;</span><span style="color: black;">&#41;</span>
      <span style="color: black;">&#41;</span>
  subdiv = ET.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>
      <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://api.geonames.org/countrySubdivision?lat=&quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>lat<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;&amp;lng=&quot;</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>lon<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;&amp;username=sethjust&quot;</span><span style="color: black;">&#41;</span>
      <span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># Format and return place, region, country</span>
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    country = subdiv.<span style="color: black;">getiterator</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;countryName&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">text</span>
  <span style="color: #ff7700;font-weight:bold;">except</span>:
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      country = placename.<span style="color: black;">getiterator</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;countryName&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">except</span>:
      country = <span style="color: #483d8b;">''</span>
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    region = subdiv.<span style="color: black;">getiterator</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;adminName1&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">text</span>
  <span style="color: #ff7700;font-weight:bold;">except</span>:
    region = <span style="color: #483d8b;">''</span>
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    name = placename.<span style="color: black;">getiterator</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;name&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">text</span>
  <span style="color: #ff7700;font-weight:bold;">except</span>:
    name = <span style="color: #483d8b;">''</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">if</span> country:
    <span style="color: #ff7700;font-weight:bold;">if</span> region:
      <span style="color: #ff7700;font-weight:bold;">if</span> name:
        result = <span style="color: #483d8b;">&quot;%s, %s, %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>name, region, country<span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">else</span>:
        result = <span style="color: #483d8b;">&quot;%s, %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>region, country<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      <span style="color: #ff7700;font-weight:bold;">if</span> name:
        result = <span style="color: #483d8b;">&quot;%s, %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>name, country<span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">else</span>:
        result = country
  <span style="color: #ff7700;font-weight:bold;">else</span>:
    result = <span style="color: #483d8b;">&quot;unknown&quot;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">return</span> result</pre></td></tr></table></div>

<p>Finally, the main method of the program parses arguments, determines what coordinates to use, gets the geographical feature string, and then generates the proper HTML and copies it into the correct place.</p>

<div class="wp_codebox"><table><tr id="p3078"><td class="code" id="p307code8"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>__name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span><span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># Parse command line options</span>
  <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser
  <span style="color: #dc143c;">parser</span> = OptionParser<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Usage: %prog [options] NAME FILENAME<span style="color: #000099; font-weight: bold;">\n</span>Note: NAME should be enclosed in quotes, unless it contains no spaces.&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--no-gps&quot;</span>, action=<span style="color: #483d8b;">&quot;store_true&quot;</span>, dest=<span style="color: #483d8b;">&quot;nogps&quot;</span>, default=<span style="color: #008000;">False</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;don't attempt to get coordinates from GPS&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-a&quot;</span>, <span style="color: #483d8b;">&quot;--amail&quot;</span>, action=<span style="color: #483d8b;">&quot;store_true&quot;</span>, dest=<span style="color: #483d8b;">&quot;amail&quot;</span>, default=<span style="color: #008000;">False</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;generate files for Apple's Mail.app (.webarchive)&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--lat&quot;</span>, action=<span style="color: #483d8b;">&quot;store&quot;</span>, <span style="color: #008000;">type</span>=<span style="color: #483d8b;">&quot;float&quot;</span>, dest=<span style="color: #483d8b;">&quot;lat&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;default latitude, if GPS is unavailable&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--lon&quot;</span>, action=<span style="color: #483d8b;">&quot;store&quot;</span>, <span style="color: #008000;">type</span>=<span style="color: #483d8b;">&quot;float&quot;</span>, dest=<span style="color: #483d8b;">&quot;lon&quot;</span>, <span style="color: #008000;">help</span>=<span style="color: #483d8b;">&quot;default longitude, if GPS is unavailable&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
  options, args = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">try</span>: <span style="color: #ff7700;font-weight:bold;">assert</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">AssertionError</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;You must provide NAME FILENAME<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">print_help</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    exit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">try</span>: <span style="color: #ff7700;font-weight:bold;">assert</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>options.<span style="color: black;">lat</span><span style="color: #66cc66;">!</span>=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> <span style="color: black;">&#40;</span>options.<span style="color: black;">lon</span><span style="color: #66cc66;">!</span>=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> | <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>options.<span style="color: black;">lat</span>==<span style="color: #008000;">None</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> <span style="color: black;">&#40;</span>options.<span style="color: black;">lon</span>==<span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">AssertionError</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;You must provide both lat and lon arguments<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #dc143c;">parser</span>.<span style="color: black;">print_help</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    exit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># Modules for creating signature file</span>
  <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">tempfile</span>, <span style="color: #dc143c;">os</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>options.<span style="color: black;">nogps</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">raise</span> NoGPSError
    lat, lon = get_lat_lon<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Got %f, %f from gps&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>lat, lon<span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span> NoGPSError:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">not</span> options.<span style="color: black;">nogps</span><span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Failed to get coordinates from GPS&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      <span style="color: #ff7700;font-weight:bold;">assert</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>options.<span style="color: black;">lat</span><span style="color: #66cc66;">!</span>=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span> <span style="color: black;">&#40;</span>options.<span style="color: black;">lon</span><span style="color: #66cc66;">!</span>=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">AssertionError</span>:
      <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;No default coordinates provided; exiting&quot;</span>
      exit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    lat, lon = options.<span style="color: black;">lat</span>, options.<span style="color: black;">lon</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Using %f, %f as coordinates&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>lat, lon<span style="color: black;">&#41;</span>
&nbsp;
  geostring = get_geo_string<span style="color: black;">&#40;</span>lat, lon<span style="color: black;">&#41;</span>
&nbsp;
  lac, loc = <span style="color: #483d8b;">'N'</span>, <span style="color: #483d8b;">'E'</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> lat <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0</span>:
    lat <span style="color: #66cc66;">*</span>= -<span style="color: #ff4500;">1</span>
    lac = <span style="color: #483d8b;">'S'</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> lon <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0</span>:
    lon <span style="color: #66cc66;">*</span>= -<span style="color: #ff4500;">1</span>
    loc = <span style="color: #483d8b;">'W'</span>
&nbsp;
  <span style="color: #008000;">file</span> = <span style="color: #dc143c;">tempfile</span>.<span style="color: black;">NamedTemporaryFile</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;html&gt;&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;p&gt;&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;p&gt;&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Current meatspace coordinates, hot from the GPS receiver card in my laptop:&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;p&gt;&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%.3f %s latitude, %.3f %s longitude&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>lat, lac, lon, loc<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;p&gt;&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Nearest geographical feature: &quot;</span> + geostring<span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;/p&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #008000;">file</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&lt;/html&gt;&lt;/body&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #008000;">file</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>options.<span style="color: black;">amail</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;textutil -convert webarchive -output &quot;</span> + args<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">&quot; &quot;</span> + <span style="color: #008000;">file</span>.<span style="color: black;">name</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">else</span>:
    <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;cp &quot;</span> + <span style="color: #008000;">file</span>.<span style="color: black;">name</span> + <span style="color: #483d8b;">&quot; &quot;</span> + args<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/07/11/sign-your-email-like-randall-waterhouse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>GPSd under OS X (revisited)</title>
		<link>http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/</link>
		<comments>http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 04:07:27 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=305</guid>
		<description><![CDATA[It&#8217;s been almost 2 and half years since I originally posted about GPSd and OS X. That post got quite a bit of traffic for a while, but a whole lot has changed since then. If you&#8217;re interested in some in-depth background information, you should check out the old post; this post is mostly about [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been almost 2 and half years since I originally posted about <a href="http://sethjust.com/2009/01/13/gpsd-under-os-x/">GPSd and OS X</a>. That post got quite a bit of traffic for a while, but a whole lot has changed since then. If you&#8217;re interested in some in-depth background information, you should check out the old post; this post is mostly about the changes in the GPSd project since then, and the process of getting it running on OS X.</p>
<p>Two and a half years ago, GPSd had just released version 2.38. The latest version, which I just downloaded, is 2.96. Most significantly, GPSd has updated their communication protocol from a simple character-command format to one based on JSON-packed data. Further, they&#8217;ve built a significant portion of the project around python, and consequently built better python interfaces into the project.</p>
<p>OS X has also been updated, from whatever 10.5.x was current three Januaries ago, to 10.6.8. Luckily, the under-the-hood changes that Snow Leopard brought to the table should only make compiling software easier.</p>
<p>Building GPSd is a whole lot easier than it was the last time I went through all of this. I downloaded the latest source package (from <a href="http://prdownload.berlios.de/gpsd/gpsd-2.96bis.tar.gz">http://prdownload.berlios.de/gpsd/gpsd-2.96bis.tar.gz</a>). The bundled INSTALL file lists only python and py-gtk2 as dependencies, which makes compilation easy, given that python comes bundled with OS X. Although py-gtk2 is available through MacPorts (using <span style="font-family: monospace;">sudo port install py-gtk2</span>) I chose to avoid install the ridiculously long list of dependencies that it requires, as it is only required for the graphical test client (xgps), and GPSd also ships the perfectly functional command-line tool cgps, which provides the same information, albeit in a more sparse manner.</p>
<p>The actual build process is surprisingly easy: I ran <span style="font-family: monospace;">./configure &#8211;x-includes=/usr/X11R6/include</span>, as suggested by the INSTALL file. As this indicated no issues, I ran <span style="font-family: monospace;">make</span> and <span style="font-family: monospace;">sudo make install</span>, which ran without a hitch, and gave me a working set of gps tools.</p>
<p>At this point it is possible for me to attach my GPS (see my old post for information about getting devices up and running), run <span style="font-family: monospace;">gpsd -n /dev/cu.usbserial</span>, and then use <span style="font-family: monospace;">cgps</span>to get coordinates, date, and satellite information. However, this isn&#8217;t everything &#8212; all of the python based GPSd tools, such as gpsprof, still don&#8217;t work. This is because of Apple&#8217;s slightly special python distribution &#8212; while GPSd&#8217;s <span style="font-family: monospace;">sudo make install</span> puts python modules into /usr/local/lib/python2.6/site-packages/, they need to be in /Library/Python/2.6/site-packages/. Instead of having to install these manually, you can use the bundled python install script to put the modules in the correct path by running <span style="font-family: monospace;">sudo python setup.py install</span> (thanks to <a href="http://docs.python.org/install/index.html">http://docs.python.org/install/index.html</a>).</p>
<p>Now that I have the most recent GPSd up and running I&#8217;m hoping to do some fun things with it. If I do, you&#8217;ll see it here!</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Chrome + Grooveshark = Blank Page!?!</title>
		<link>http://sethjust.com/2011/06/23/chrome-grooveshark-blank-page/</link>
		<comments>http://sethjust.com/2011/06/23/chrome-grooveshark-blank-page/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 20:01:42 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[grooveshark]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=296</guid>
		<description><![CDATA[Recently I was having a pretty frustrating issue viewing Grooveshark in Chrome &#8212; it would only load a blank, white page. This had me tearing my hair out, and Google was no help at all; there seemed to be a handful of people posting about this problem, but their posts didn&#8217;t offer any solutions. I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was having a pretty frustrating issue viewing <a href="http://grooveshark.com">Grooveshark</a> in Chrome &#8212; it would only load a blank, white page. This had me tearing my hair out, and Google was no help at all; there seemed to be a handful of people posting about this problem, but their posts didn&#8217;t offer any solutions.</p>
<p><a href="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.54.25-PM.png"><br />
<img class="alignright" title="Screen shot 2011-06-23 at 1.54.25 PM" src="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.54.25-PM-300x47.png" alt="" width="300" height="47" /></a> I noticed that I was able to load the website just fine in Safari, and that&#8217;s when I had an insight &#8212; I noticed that Safari was loading http://grooveshark.com, while Chrome was taking me to http<strong>s</strong>://grooveshark.com. It turns out that the issue was with a plugin I use &#8212; the <a href="https://code.google.com/p/kbsslenforcer/">KB SSL Enforcer</a>. While it&#8217;s a great piece of software, it was forcing Chrome to connect to the SSL site, which for some odd reason was causing the blank page to be displayed.</p>
<p>The fix for this issue was easy. I just opened up the SSL Enforcer options and added grooveshark.com to the blacklist; telling the plugin to never force SSL for Grooveshark.<br />
<a href="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.54.44-PM.png"><img class="aligncenter size-medium wp-image-298" title="Screen shot 2011-06-23 at 1.54.44 PM" src="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.54.44-PM-300x96.png" alt="" width="300" height="96" /></a></p>
<p>Now I&#8217;m happily listening to tunes online without having a second browser open!<br />
<a href="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.56.32-PM.png"><img class="aligncenter size-full wp-image-299" title="Screen shot 2011-06-23 at 1.56.32 PM" src="http://sethjust.com/wp-content/uploads/2011/06/Screen-shot-2011-06-23-at-1.56.32-PM.png" alt="" width="263" height="210" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/06/23/chrome-grooveshark-blank-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Web Laundry, Smart Cards, Python and OS X Smorgasbord</title>
		<link>http://sethjust.com/2011/06/14/laundry-smart-cards/</link>
		<comments>http://sethjust.com/2011/06/14/laundry-smart-cards/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 00:22:11 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[laundry]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart card]]></category>
		<category><![CDATA[stored value]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=285</guid>
		<description><![CDATA[Disclaimer: This article is for informational purposes, the author shall not be held liable for any actions taken on the basis of the information presented. I do not condone fraud, theft, or other malfeasance. In September 2010, Hans Viksler posted an article about the insecurity of the stored-value smart card system used by Web Laundry (now [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;">Disclaimer: This article is for informational purposes, the author shall not be held liable for any actions taken on the basis of the information presented. I do not condone fraud, theft, or other malfeasance.</span></p>
<p>In September 2010, <a rel="author" href="http://www.blogger.com/profile/09056609859376859009">Hans Viksler</a> posted an <a href="http://ihackiam.blogspot.com/2010/09/web-laundry-insecurity.html">article</a> about the insecurity of the stored-value smart card system used by <a href="http://weblaundry.com/">Web Laundry</a> (now <a href="http://www.washlaundry.com/">Wash Laundry</a>). I&#8217;ll let that article stand on its own &#8212; it gives a good overview of the bone-headed system that the engineers there had in place. In short, they used a secure memory card made by Atmel (specifically, from the CryptoMemory line), the AT88SC0404C (datasheet <a href="http://www.atmel.com/dyn/resources/prod_documents/doc5211.pdf" class="broken_link">here</a>), but neglected to change the default master password. This means that all you need to read or write the stored data is a ISO-7816-3 compliant smart card reader.</p>
<p>This is where my story starts &#8212; this summer I&#8217;m living in a dorm that uses a Web Laundry stored value system. That was enough of a push for me to buy a smart card reader, seeing as I&#8217;d always wanted to play with them, and this looked like a good opportunity. I picked up a smart card reader from Amazon.com, an <a id="static_txt_preview" href="http://www.amazon.com/gp/product/B0012K5P02/ref=as_li_ss_tl?ie=UTF8&amp;tag=dabbler-20&amp;linkCode=as2&amp;camp=217153&amp;creative=399349&amp;creativeASIN=B0012K5P02">SCM Microsystems SCR3310</a>. It was both cheap and, according to the manufacturer&#8217;s <a href="https://www.scmmicro.com/security/view_product_en.php?PID=4">product page</a>, offers full ISO 7816, CCID and PC/SC compatibility (i.e. all of the relevant standards), as well as drivers for OS X, which is my primary operating system for the time being.</p>
<p>Doing some research, it turns out that Apple ships a (modified) version of the open-source <a href="http://pcsclite.alioth.debian.org/">PCSC Lite</a> framework for smart card integration. This means that all I would need to get up and running was a driver for my device and a way to interface it. Once the reader arrived I installed the drivers, and ran pcsctest (from PCSC Lite) on the command line. Sadly, all I got was an error message:</p>
<pre>Testing SCardEstablishContext    : Service not available.</pre>
<p>Googling told me that the appropriate services are supposed to start whenever a smart card reader with appropriate drivers is plugged in, which made this error all the more confusing. Luckily, I found <a href="http://support.scmmicro.com/forum/viewtopic.php?f=10&amp;t=552">this thread</a> on SCM&#8217;s forums &#8212; it seems that the driver they have posted doesn&#8217;t include the USB identifiers for the version of the reader I had, but a helpful poster left instructions to modify a plist file in the driver (mirrored <a href="http://homepage.sethjust.com/files/SCM3310_OSX.html">here</a> for archival purposes). With that, I was up and running!</p>
<p>pcsctest spat out useful output this time around:</p>
<pre>$ pcsctest

MUSCLE PC/SC Lite Test Program

Testing SCardEstablishContext    : Command successful.
Testing SCardGetStatusChange
Please insert a working reader   : Command successful.
Testing SCardListReaders         : Command successful.
Reader 01: SCM SCR 3310 00 00
Enter the reader number          : 1
Waiting for card insertion
                                 : Command successful.
Testing SCardConnect             : Command successful.
Testing SCardStatus              : Command successful.
Current Reader Name              : SCM SCR 3310 00 00
Current Reader State             : 0x34
Current Reader Protocol          : 0x0
Current Reader ATR Size          : 8 (0x8)
Current Reader ATR Value         : 3B B2 11 00 10 80 00 04
Testing SCardDisconnect          : Command successful.
Testing SCardReleaseContext      : Command successful.</pre>
<p>That left me with the issue of interacting with the smart card somehow. In case you hadn&#8217;t guessed from the post title, that solution was Python. Specifically, the pyscard bindings for PCSC Lite, from <a href="http://pyscard.sourceforge.net/">pyscard.sourceforge.net</a>. There&#8217;s a nice array of examples, and so I wrote up a python script for interacting with <em>this particular </em>CryptoMemory card, based on the command set from the datasheet and the examples. It&#8217;s not as polished or feature-rich as the software Hans posted, but if you&#8217;re running OS X or Linux, it should be helpful. At the moment this script is extremely rough &#8212; it gets the job done, but in an ugly and unsafe way. I&#8217;m posting it <a href="http://homepage.sethjust.com/files/CryptoMemory.txt">here</a>, but you <strong>SHOULD NOT USE IT IF YOU DON&#8217;T KNOW WHAT YOU&#8217;RE DOING</strong>. If you aren&#8217;t careful, it will mess up your card. Hopefully I&#8217;ll have time to wrap it all in a library that will abstract away the messiness and provide nice features like exception handling; if I do, you&#8217;ll see it here.</p>
<p>Using my script I was able to verify Hans&#8217; findings &#8212; although the card is configured to require cryptographic authentication to access the user zones (where the goodies can be found), the password is left at the default value, which makes overwriting the access registers and conducting a replay attack (as demonstrated by the video in his post) a walk in the park. Following his example, I won&#8217;t post any information on how the cards store their values, but it&#8217;s surprising that this security hole still isn&#8217;t fixed, seeing as it would cost nothing to overwrite the master password when they first configure the cards.</p>
<p>Hopefully this post will give some of you who&#8217;ve wanted to work with smart cards a push in that direction &#8212; although there are a few hurdles along the way, it&#8217;s an interesting area to work on. I&#8217;m hoping to move on from poking at other people&#8217;s cards and start using my new hardware for authentication and encryption.</p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2011/06/14/laundry-smart-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>M-Set update</title>
		<link>http://sethjust.com/2010/05/27/m-set-update/</link>
		<comments>http://sethjust.com/2010/05/27/m-set-update/#comments</comments>
		<pubDate>Thu, 27 May 2010 17:16:29 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mandelbrot]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=167</guid>
		<description><![CDATA[So, I know that I&#8217;ve been harping on this a bit, but I&#8217;ve re-written my M-Set renderer in C, so it&#8217;s faster, and I&#8217;ve added a few more command line flags to make it easier to use. Get the code here.]]></description>
			<content:encoded><![CDATA[<p><a href="http://homepage.sethjust.com/files/mandel_py.png"></a><a href="http://sethjust.com/wp-content/uploads/2010/05/mandel_py.png"><img class="alignright size-medium wp-image-222" title="mandel_py" src="http://sethjust.com/wp-content/uploads/2010/05/mandel_py-300x229.png" alt="" width="300" height="229" /></a>So, I know that I&#8217;ve been harping on this a bit, but I&#8217;ve re-written my M-Set renderer in C, so it&#8217;s faster, and I&#8217;ve added a few more command line flags to make it easier to use.</p>
<p>Get the code <a href="http://sethjust.com/wp-content/uploads/2010/05/mandel.c">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2010/05/27/m-set-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>More Mandelbrot</title>
		<link>http://sethjust.com/2009/12/19/more-mandelbrot/</link>
		<comments>http://sethjust.com/2009/12/19/more-mandelbrot/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 00:27:19 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=122</guid>
		<description><![CDATA[I just recently revisited the M-Set code from my Perl Snippets post. The code I had was pretty ugly, so I decided to rewrite it in Python. The result is not only a lot cleaner and easier to understand, but it&#8217;s also a lot faster: $ time python mandel.py &#62; \dev\null real 0m0.051s user 0m0.036s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sethjust.com/wp-content/uploads/2010/05/mandel_py.png"><img class="alignright size-medium wp-image-222" title="mandel_py" src="http://sethjust.com/wp-content/uploads/2010/05/mandel_py-300x229.png" alt="" width="300" height="229" /></a>I just recently revisited the M-Set code from my <a href="http://sethjust.com/2009/03/24/perl-snippets/">Perl Snippets</a> post. The code I had was pretty ugly, so I decided to rewrite it in Python. The result is not only a lot cleaner and easier to understand, but it&#8217;s also a lot faster:</p>
<pre>$ time python mandel.py &gt; \dev\null
real	0m0.051s
user	0m0.036s
sys	0m0.010s
$ time perl mandel.pl &gt; \dev\null
real	0m3.518s
user	0m3.463s
sys	0m0.029s</pre>
<p>You can find the code <a href="http://homepage.sethjust.com/files/mandel.txt">here</a>.</p>
<p>This script works well for zooms, as long as you stay below a few thousand iterations. The following picture was generated with x=-1.1887204, y=-0.3032472, width=0.01 and 150 iterations.</p>
<p style="text-align: center;"><a href="http://sethjust.com/wp-content/uploads/2009/12/mandel_py_zoom.png"><img class="size-medium wp-image-224 aligncenter" title="mandel_py_zoom" src="http://sethjust.com/wp-content/uploads/2009/12/mandel_py_zoom-300x229.png" alt="" width="300" height="229" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2009/12/19/more-mandelbrot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Conky Calendar with Date Highlight</title>
		<link>http://sethjust.com/2009/08/03/a-useful-calendar-in-conky/</link>
		<comments>http://sethjust.com/2009/08/03/a-useful-calendar-in-conky/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 03:34:09 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cal]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://sethjust.com/?p=114</guid>
		<description><![CDATA[Since I got a new desktop a month or so ago, I&#8217;ve been running Ubuntu as my main operating system, and am using Conky for a nice heads-up-display. There are a lot of articles on the web about both Ubuntu and Conky, but one thing I couldn&#8217;t find a good, accurate how-to on was getting [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Since I got a new desktop a month or so ago, I&#8217;ve been running <a href="http://www.ubuntu.com">Ubuntu</a> as my main operating system, and am using <a href="http://conky.sourceforge.net/">Conky</a> for a nice heads-up-display. There are a lot of articles on the web about both Ubuntu and Conky, but one thing I couldn&#8217;t find a good, accurate how-to on was getting a calendar that highlighted the current date. While getting the calendar is easy using the cal command, actually getting the date highlighted is somewhat hard, and all of the articles I found suggested methods that broke in various situations. However, I managed to get it all worked out, and have a beautiful calendar that looks like this:</p>
<p style="text-align: center;"><a href="http://sethjust.com/wp-content/uploads/2009/08/conky_cal.png"><img class="size-full wp-image-230 aligncenter" title="conky_cal" src="http://sethjust.com/wp-content/uploads/2009/08/conky_cal.png" alt="" width="129" height="120" /></a></p>
<p style="text-align: left;">After the jump, I&#8217;ll give you the code and explain how it all works.<span id="more-114"></span></p>
<h2 style="text-align: left;">How it Works:</h2>
<p style="text-align: left;">The code from ~/.conkyrc that makes this calendar is simple:</p>
<p style="text-align: left;">Edit: I&#8217;ve updated the code as Zacco suggested in the comments to fix a minor bug on certain dates.</p>
<pre style="text-align: left;">${color orange}CALENDAR ${hr 2}$color
${execpi 60 DJS=`date +%_d`; cal | sed s/"\(^\|[^0-9]\)$DJS"'\b'/'\1${color orange}'"$DJS"'$color'/}}</pre>
<p>This is a somewhat complicated expression, but what it does is fairly simple. The first line simply draws the title for the section, and it&#8217;s the second line that does the magic. Let me break it down and explain it.</p>
<pre style="text-align: left;">${execpi 60</pre>
<p>This command tells Conky to execute the next argument every 60 seconds, and, importantly, parse the output of that argument. This way, when we put in commands that change the text color, Conky will obey them instead of printing them.</p>
<pre style="text-align: left;">DJS=`date +%_d`;</pre>
<p>DJS (which stands for &#8220;date&#8221; followed by my initials) is a temporary variable that holds the current day of the month, padded with a leading space, if necessary (so that we&#8217;ll catch the first of the month, not every 1 in the calendar, for example).</p>
<pre style="text-align: left;">cal |</pre>
<p>cal simply prints out a simple calendar, and the pipe feeds that output through to the next commmand:</p>
<pre style="text-align: left;">
<pre>sed s/"\([^0-9]\)$DJS"'\b'/'${color orange}'"$DJS"'$color'/</pre>
</pre>
<p>This is one big mess of a command, but the main body is a <a href="http://en.wikipedia.org/wiki/Regex">regex</a> that sed takes as an argument. The regex searches for the string &#8220;\([^0-9]\)$DJS&#8221;&#8216;\b&#8217;, which means the contents of the variable DJS (which we set earlier) preceded by anything other than a digit, and followed by a word boundary &#8211; a change from printable characters to white space. This means that it will find the current date (one or two digits) but won&#8217;t find the 3 of the 30th on the third of the month. It also means that it will work correctly if the current date is on the far left or right column of the calendar.</p>
<p>The second half of the regex simply wraps what it found the first time around in a couple of Conky commands that change to color to orange, and then back to what it was before.</p>
<p>Lastly, the closing bracket (}) at the end of the line closes out the opening one that is required for all Conky commands with arguments.</p>
<p>Now go forth and cover your desktop in beautiful calendars.</p>
<p><strong>Update: </strong>Erik in the comments has a modification to center the entire calendar, if left-aligning isn&#8217;t for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2009/08/03/a-useful-calendar-in-conky/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>iWork Autosave</title>
		<link>http://sethjust.com/2009/03/29/iwork-autosave/</link>
		<comments>http://sethjust.com/2009/03/29/iwork-autosave/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 02:10:31 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[autosave]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[iwork]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[school]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/?p=74</guid>
		<description><![CDATA[So I had the wonderful experience this weekend of losing over 1,200 words of work on a paper because I forgot to save it regularly. I was really, really sad about that and really bummed that Pages, my word processor of choice (I love the formatting tools), doesn&#8217;t support either autosaving or document recovery. However, [...]]]></description>
			<content:encoded><![CDATA[<p>So I had the wonderful experience this weekend of losing over 1,200 words of work on a paper because I forgot to save it regularly. I was really, really sad about that and really bummed that <a href="http://www.apple.com/iwork/pages/">Pages</a>, my word processor of choice (I love the formatting tools), doesn&#8217;t support either autosaving or document recovery. However, my preference for Pages is strong enough that I didn&#8217;t jump ship to an auto-saving editor. Instead I went out and found <a href="http://tristanchadwick.com/worksaver/">WorkSaver</a>. <img class="alignright size-full wp-image-78" style="float:right;" title="WorkSaver" src="http://sethjust.files.wordpress.com/2009/03/picture-3.png" alt="WorkSaver" width="265" height="212" /><br />
Worksaver simply sits in your menubar and, at a definable interval will save every iWork document you have open, provided that it&#8217;s already been saved once. This means that when I&#8217;m writing I don&#8217;t have to even worry about saving my document after creating it and choosing where to save it. Of course, it&#8217;s a shame that you have to manually save the file when you create it, but it&#8217;s a lot better than losing all your work. I can highly recommend <a href="http://tristanchadwick.com/worksaver/">WorkSaver</a> if you use iWork simply for the peace of mind it provides. Of course, it&#8217;s not perfect for everybody, but when I&#8217;d rather focus on writing a paper than on making sure my computer doesn&#8217;t decide to make it all go away, <a href="http://tristanchadwick.com/worksaver/">WorkSaver</a> is just what I need.</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2009/03/29/iwork-autosave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>GPSd under OS X</title>
		<link>http://sethjust.com/2009/01/13/gpsd-under-os-x/</link>
		<comments>http://sethjust.com/2009/01/13/gpsd-under-os-x/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 08:52:06 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/?p=47</guid>
		<description><![CDATA[Update 7-13-11: I&#8217;ve posted an updated set of instructions on getting GPSd to compile on OS X here; this post will remain for archival purposes. For information on installing GPSDrive, see this post. So I recently picked up a cheap GPS module on Amazon. It was about $30 with shipping, and I got a neat [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 7-13-11: </strong>I&#8217;ve posted an updated set of instructions on getting GPSd to compile on OS X <a href="http://sethjust.com/2011/07/10/gpsd-under-os-x-revisited/">here</a>; this post will remain for archival purposes. For information on installing GPSDrive, see <a href="http://sethjust.com/2011/07/13/gpsdrive-on-os-x/">this post</a>.</p>
<p>So I recently picked up a cheap GPS module on Amazon. It was about $30 with shipping, and I got a neat little dongle which connects over USB to my computer and communicates with software. It didn&#8217;t come with support for OS X (although interestingly enough it shipped with Mac OS 8 and 9 drivers), but it promised to send generic NMEA-0183, so I wasn&#8217;t too worried.</p>
<p>When it showed up, some quick software probing revealed that it houses a usb to serial adaptor (a Prolific PL-2303, which I&#8217;ll get to in a bit) and a gps module that&#8217;s configured to send NMEA strings through the virtual serial port. This sort of information is compatible with a host of software, but most of it is commericial, and only available at a considerable price.</p>
<p>Luckily, there&#8217;s a wonderful open source project called gpsd which provides support for a wide raft of devices and protocols, and talks to an even wider assortment of software. Primarily, I wanted to be able to get my gps to talk to the network scanner Kismac, and Randall Munroe&#8217;s cyborg.py script. Both of these were built to take information from gpsd, so I was in business. However, gpsd, which is designed to play nicely with Linux, takes some coaxing under OS X. This is meant to describe how I got it all running.<span id="more-47"></span></p>
<h3>I. Hardware driver</h3>
<p>Because the gps relies on a usb-to-serial chip to talk to the computer, it needs a driver that will emulate a serial port. The chip in my gps revealed itself as a Prolific PL-2303, a common chip that I&#8217;d had previous dealings with, and so had a driver for. This enabled me to see a serial device on my system and read raw data from it:</p>
<pre>sethjust$ ls /dev/cu.*
/dev/cu.Bluetooth-Modem		/dev/cu.Bluetooth-PDA-Sync	/dev/cu.PL2303-0000101D
sethjust$ stty -f /dev/cu.usbserial ispeed 4800 &amp;&amp; cat &lt;/dev/cu.usbserial
,,,3.6,2.2,2.8*3E
$GPRMC,060645.994,A,4537.5498,N,12259.8000,W,000.0,327.4,120109,,,A*70
$GPVTG,327.4,T,,M,000.0,N,000.0,K,A*0F
$GPGGA,060646.994,4537.5498,N,12259.8000,W,1,06,2.2,137.3,M,-21.5,M,,0000*63
$GPGSA,A,3,23,25,13,04,32,20,,,,,,,3.^C</pre>
<p>This driver also played nicely with some of the commericial software demos I&#8217;d downloaded, but oddly enough it didn&#8217;t work with gpsd. Eventually, after some debugging and consulting with one of gpsd&#8217;s developers via IRC, I replaced the driver I had (an open source replacement for proprietary driver) with the driver from Prolific&#8217;s website. Supposedly the open-source PL-2303 driver doesn&#8217;t play nicely with gpsd, and so they recommend using Prolific&#8217;s.</p>
<h3>II. gpsd and gpsdrive</h3>
<p>The gpsd package comes with several useful support utilities, but one that it doesn&#8217;t include is gpsdrive, a wonderful program that supports mapping and live data from gps. Getting both running under OS X is a little difficult, but I found a great document <a href="http://lists.gpsdrivers.org/pipermail/gpsdrive/2007-June/000136.html">here</a> that explains the process. A little has changed, so here&#8217;s how I got it working (though I never did get xgps or xgpsspeed to compile&#8230;):<br />
1) Install fink if you haven&#8217;t already.<br />
2) Install gpsdrive through fink:</p>
<pre>$ fink install gpsdrive</pre>
<p>3) Rename /sw/bin/gpsd to gpsd-1.06b:</p>
<pre>$ sudo mv /sw/bin/gpsd /sw/bin/gpsd-1.06b</pre>
<p>4) Download the latest source for gpsd. I used the latest RC for their upcoming 2.38 release and have had no problems.<br />
5) In the gpsd source directory, run ./configure with whatever options you&#8217;d like. The earlier document had some suggestions on getting it to see X11 libraries, but I haven&#8217;t been able to make them work. I ended up using</p>
<pre>$ ./configure --bindir=/usr/local/bin -without-x</pre>
<p>6) Compile the software by typing &#8220;make&#8221;. You can then either install it with &#8220;sudo make install&#8221; or test it before installing:</p>
<pre>$ ./gpsd -n /dev/cu.usbserial
$ ./cgps</pre>
<p>In my case /dev/cu.usbserial is the device representing the PL-2303. You should replace this with your own.</p>
<p>Running cgps should show a live summary of the information that gpsd is getting, along with a running log of the raw data coming from the gps. You can also test gpsd by telnetting to localhost:2947, typing w and hitting enter. You should see NMEA strings from the gps.</p>
<h3>III. Kismac and cyborg.py</h3>
<p>The original reason that I embarked on this gps adventure was to use two programs: Kismac and Randall Munroe&#8217;s cyborg.py. Kismac is easy to get running with gpsd – once you have gpsd running (e.g. gpsd -n /dev/cu.usbserial), open Kismac and set it to use gpsd for map coordinates. It should display your location on the map screen, and associate coordinates with APs.</p>
<p>cyborg.py is a little harder to get running. It&#8217;s dirty (though entirely functional) code that isn&#8217;t fully mac compatible. Notably, it uses two programs (flite and figlet) that are iffy under OS X. I patched that up, replacing flite with OS X&#8217;s built-in &#8220;say&#8221; command, and commenting out the figlet bits (which display large text) in favor of the terminal output the script gives. The modified script works beautifully, although I didn&#8217;t clean up the code at all. You can get it <a href="http://people.reed.edu/~justs/cyborg.py">here</a>.</p>
<h3>IV. Links</h3>
<ul>
<li><a href="http://gpsd.berlios.de/">gpsd</a></li>
<li><a href="http://www.gpsdrive.de/">gpsdrive</a></li>
<li>Kismac</li>
<li><a href="http://blag.xkcd.com/2008/05/20/gps-cyborg-implant/">Randall Munroe&#8217;s cyborg.py</a></li>
<li><a href="http://lists.gpsdrivers.org/pipermail/gpsdrive/2007-June/000136.html">Post by Hashim on the gpsdrive mailing list</a></li>
<li><a href="http://www.prolific.com.tw/eng/Products.asp?ID=59">Prolific PL-2303</a> and <a href="http://www.prolific.com.tw/eng/downloads.asp?ID=31">driver</a></li>
<li><a href="http://osx-pl2303.sourceforge.net/">PL-2303 Alternative Driver</a></li>
<li><a href="http://apps.sourceforge.net/mediawiki/gpsdrive/index.php?title=Creating_maps">Getting maps in gpsdrive</a></li>
<li>My gps</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2009/01/13/gpsd-under-os-x/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Fast and Simple Stock Quotes Using Perl</title>
		<link>http://sethjust.com/2008/10/23/fast-and-simple-stock-quotes-using-perl/</link>
		<comments>http://sethjust.com/2008/10/23/fast-and-simple-stock-quotes-using-perl/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 06:18:05 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[finance]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[stocks]]></category>
		<category><![CDATA[ticker]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/?p=21</guid>
		<description><![CDATA[One of the things that makes perl so powerful and fascinating is the huge number of modules that are available online, especially through the CPAN repository. Today I stumbled upon one called Finance::Quote, which does one thing, very simply: it retrieves stock (or mutual fund) quotes. You feed it a ticker symbol and it gives [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that makes perl so powerful and fascinating is the huge number of modules that are available online, especially through the CPAN repository. Today I stumbled upon one called Finance::Quote, which does one thing, very simply: it retrieves stock (or mutual fund) quotes. You feed it a ticker symbol and it gives back a hash with all sorts of information, but most importantly, the price. I&#8217;m going to show how to use this to create a command line tool that will grab an up-to-the minute stock quote for any ticker symbol you give it.</p>
<p><span id="more-21"></span><br />
To start, installing Finance::Quote is a breeze. As long as you have CPAN installed, just type at the command line:</p>
<pre>$perl -MCPAN -e shell
&gt;install Finance::Quote</pre>
<p>From there it&#8217;s easy to get start, it&#8217;s just a matter of importing the module and creating and instance. This means the beginning of our script will look like:</p>

<div class="wp_codebox"><table><tr id="p2112"><td class="code" id="p21code12"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># import module</span>
<span style="color: #000000; font-weight: bold;">use</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># create object</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$q</span> <span style="color: #339933;">=</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The instance that we created has one main method: fetch(). It takes a list of arguments, with the first being a the exchange to look for quotes on, and the remaining being a list or array of ticker symbols. The Finance::Quote documentation provides the following list of valid exchanges:</p>
<pre>australia           Australan Stock Exchange
dwsfunds            Deutsche Bank Gruppe funds
fidelity            Fidelity Investments
tiaacref            TIAA-CREF
troweprice          T. Rowe Price
europe              European Markets
canada              Canadian Markets
usa                 USA Markets
nyse                New York Stock Exchange
nasdaq              NASDAQ
uk_unit_trusts      UK Unit Trusts
vanguard            Vanguard Investments
vwd                 Vereinigte Wirtschaftsdienste GmbH</pre>
<p>For the purposes of this script, I&#8217;m going to stick to &#8220;usa&#8221; because it covers both NYSE and NASDAQ, and those are the stocks I&#8217;m interested in.<br />
Fetch() returns a two-dimensional hash of results. The first index (or dimension) is the ticker symbol of the stock and the second is the label for the specific piece of information. For now, the labels that we&#8217;re interested are the name of the company (&#8216;name&#8217;) and the price (&#8216;price&#8217;). A full listing of labels is available in the Finance::Quote documentation.<br />
Using this information we can now build a simple script to fetch a stock quote:</p>

<div class="wp_codebox"><table><tr id="p2113"><td class="code" id="p21code13"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># import module</span>
<span style="color: #000000; font-weight: bold;">use</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create object</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$q</span> <span style="color: #339933;">=</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># retrieve stock quote</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetch<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'usa'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'GOOG'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># print price</span>
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'GOOG'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'price'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This script, although it does what it&#8217;s supposed to, isn&#8217;t very pretty. By adding a little code to read ticker symbols from the command line we can check on multiple stocks at the same time, as well as remove the need to hard-code the ticker symbols. We can also make it produce much prettier results by adding more information about the company and add some basic error checking, which yields the following script:</p>

<div class="wp_codebox"><table><tr id="p2114"><td class="code" id="p21code14"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># import module</span>
<span style="color: #000000; font-weight: bold;">use</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># create object</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$q</span> <span style="color: #339933;">=</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#print usage information</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/length.html"><span style="color: #000066;">length</span></a><span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Usage: $0 ticker1, ticker2, ... , tickerN<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<a href="http://perldoc.perl.org/functions/exit.html"><span style="color: #000066;">exit</span></a><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get stock symbols from the command line and</span>
<span style="color: #666666; font-style: italic;"># format them correctly (uppercase)</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$_</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/uc.html"><span style="color: #000066;">uc</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># retrieve stock quote</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>fetch<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'usa'</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># print result for each stock</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #000000; font-weight: bold;">ARGV</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'success'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>		<span style="color: #666666; font-style: italic;"># if getting the quote succeeded</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'name'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;"># build a report</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$price</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'price'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$message</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$name</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">' ('</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$_</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">')'</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">' '</span> x<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">25</span> <span style="color: #339933;">-</span> <a href="http://perldoc.perl.org/functions/length.html"><span style="color: #000066;">length</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;$$price<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #0000ff;">$message</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Failed to retrieve quote for $_: $data{$_, 'errormsg'}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This is very simple, but it does its job well:</p>
<pre>$ quote goog msft aapl dell java
GOOGLE (GOOG)            $352.32
MICROSOFT CP (MSFT)      $22.32
APPLE INC (AAPL)         $98.23
DELL INC (DELL)          $11.99
SUN MICROSYSTEMS (JAVA)  $4.54</pre>
<p><a href="http://people.reed.edu/~justs/quote.pl">Download the script here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2008/10/23/fast-and-simple-stock-quotes-using-perl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Getting Songs Off of Your iPod</title>
		<link>http://sethjust.com/2008/08/10/getting-songs-off-of-your-ipod/</link>
		<comments>http://sethjust.com/2008/08/10/getting-songs-off-of-your-ipod/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:10:50 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[friends]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[ipod]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[sanity]]></category>
		<category><![CDATA[Senuti]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/?p=16</guid>
		<description><![CDATA[In the last couple weeks, at least four people have asked me how to get music off of their iPods. The answer I gave all of them was Senuti (iTunes spelled backwards). It&#8217;s great! It does exactly what you need: takes songs from your iPod and puts them into iTunes, and it&#8217;s super easy to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sethjust.files.wordpress.com/2008/08/eb85f55a-12bf-4620-a875-94941d5055221.jpg"><img class="alignright size-full wp-image-17" src="http://sethjust.files.wordpress.com/2008/08/eb85f55a-12bf-4620-a875-94941d5055221.jpg" alt="" width="220" height="156" /></a></p>
<p>In the last couple weeks, at least four people have asked me how to get music off of their iPods. The answer I gave all of them was Senuti (iTunes spelled backwards). It&#8217;s great! It does exactly what you need: takes songs from your iPod and puts them into iTunes, and it&#8217;s super easy to do. Once you have disk use enabled:</p>
<blockquote><p>To copy songs back to your computer, all you have to do is select the songs and click the transfer button in the upper left hand corner of the application.</p>
<p>The songs will be copied to the your computer. They will be added to iTunes if you enabled the preference to automatically add them to iTunes.</p></blockquote>
<p>It&#8217;s just that easy.</p>
<p>Of course, Senuti isn&#8217;t just a one trick pony, it can do other useful things as well, such as copying songs to a folder, or showing you what songs you already have in your iTunes library, and allowing you to hide them, so that you only transfer new songs.</p>
<p>So next time you feel like IM&#8217;ing me about how to get songs off of your iPod, remember Senuti, and save my sanity just a little bit.</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2008/08/10/getting-songs-off-of-your-ipod/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Can Apple keep this up?</title>
		<link>http://sethjust.com/2008/08/03/can-apple-keep-this-up/</link>
		<comments>http://sethjust.com/2008/08/03/can-apple-keep-this-up/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 08:42:33 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile me]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/?p=13</guid>
		<description><![CDATA[It seems to me that Apple has undergone a change in the past year or so. With the introduction of the App Store, the iPhone 3G, and Mobile Me, Apple seems to have lowered its quality standards. In the past there was the common knowledge that you shouldn&#8217;t buy the first revision of a product [...]]]></description>
			<content:encoded><![CDATA[<p>It seems to me that Apple has undergone a change in the past year or so. With the introduction of the App Store, the iPhone 3G, and Mobile Me, Apple seems to have lowered its quality standards. In the past there was the common knowledge that you shouldn&#8217;t buy the first revision of a product because there were always bugs, but now Apple seems to be having even more problems. It&#8217;s pretty well acknowledged that one of the biggest reasons for the problems with Mobile Me was that it was pushed out early to keep up with the iPhone 3G. I even saw similar problems when I opened up the preferences on iTunes 7.7:</p>
<div style="text-align:center;clear:both;"><img src="http://sethjust.files.wordpress.com/2008/08/picture-1.png" alt="Picture 1.png" border="0" width="326" height="132" /></div>
<p>I&#8217;m afraid that Apple&#8217;s new products and schedules are clashing with their characteristic way of doing business. In the past they were able to wait until a product was just perfect before releasing it. Now, with their partnerships and such, at least with the iPhone, Apple is forced to announce their products earlier, and so they have much stricter deadlines to meet, which begs the question &#8220;Can Apple keep this up and still deliver the same quality product they have in the past?&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2008/08/03/can-apple-keep-this-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Flock Update</title>
		<link>http://sethjust.com/2008/04/14/flock-update/</link>
		<comments>http://sethjust.com/2008/04/14/flock-update/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 02:21:56 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[addon]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[flock]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[stealther]]></category>
		<category><![CDATA[stylish]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/2008/04/14/flock-update/</guid>
		<description><![CDATA[So I&#8217;ve been playing around with Flock a bit more, and I&#8217;ve discovered some more. I played with the webmail integration, which isn&#8217;t great&#8230; It just detects new messages and then sends you to the website. I&#8217;d appreciate if I could get POP or IMAP into the browser, but I can live with a separate [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been playing around with <a href="http://www.flock.com" class="broken_link">Flock</a> a bit more, and I&#8217;ve discovered some more. I played with the webmail integration, which isn&#8217;t great&#8230; It just detects new messages and then sends you to the website. I&#8217;d appreciate if I could get POP or IMAP into the browser, but I can live with a separate desktop app.<br />
As to Digg support, it&#8217;s supposedly going to be integrated into the next release. I&#8217;m trying to get my hands on the latest betas, but they have a nasty tendency to crash on my machine. Oh well.<br />
I&#8217;ve also discovered that Flock supports a huge amount of Firefox Addons. I added my personal favorites Greasemonkey, Stylish, Stealther and AdBlock Plus.</p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2008/04/14/flock-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Flock</title>
		<link>http://sethjust.com/2008/04/14/flock/</link>
		<comments>http://sethjust.com/2008/04/14/flock/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 10:57:49 +0000</pubDate>
		<dc:creator>sethjust</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[1password]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[flock]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://sethjust.wordpress.com/2008/04/14/flock/</guid>
		<description><![CDATA[So, I&#8217;ve been trying out the Flock browser which is based on Firefox. However, it&#8217;s twist is that it&#8217;s designed to integrate with a bunch of different social services. I have it set up to work with my Facebook, Flickr, YouTube and Photobucket accounts, as well as this WordPress blog. It will also work with [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been trying out the <a href="http://www.flock.com" class="broken_link">Flock browser</a> which is based on Firefox. However, it&#8217;s twist is that it&#8217;s designed to integrate with a bunch of different social services. I have it set up to work with my <a href="http://www.facebook.com">Facebook</a>, <a href="http://www.flickr.com">Flickr</a>, <a href="http://www.youtube.com">YouTube</a> and <a href="http://www.photobucket.com">Photobucket</a> accounts, as well as this WordPress blog. It will also work with things like <a href="http://www.twitter.com">Twitter</a>, <a href="http://del.icio.us">del.icio.us</a>. It also supports RSS feeds, which I&#8217;ve imported my whole set of feeds into. So far it&#8217;s replaced two applications on my desktop (Safari and NetNewsWire), and if I were to set it up with my email, I could get rid of a third.<br />
It was very easy to set it up. I installed the 1Password plugin for it and fired it up. I was asked whether I wanted to import information from another browser, which let me grab EVERYTHING (bookmarks, cookies, history, saved passwords, etc.) from Safari. It auto-detected when I visited a site that it could integrate with (Facebook). However, to get it to add my Facebook I had to log out and then back in, which was a minor annoyance, but after that it worked perfectly. Getting my RSS feeds in was a bit harder, I had to export them from NetNewsWire as OMPL and then import them, but that was easy and quick.<br />
If you ask me, it does its thing pretty well. It takes a bit of getting used to to use the social features, but in the end it&#8217;s a lot more polished to do it all through the one interface than to use a bunch of tools that are inconsistent. However, I miss a few things. First off, it&#8217;s slow. A lot slower than Safari and Camino, and even a bit slower than Firefox. However, so far I&#8217;ve put up with it because I like what it&#8217;s doing. The other quibble I have is that I keep wanting more integration. One notable hole is Last.fm integration, which would be wonderful, but it would also be nice to see my Digg friends in there, and be able to Digg stories.<br />
Overall, I&#8217;d suggest that those with the time and curiosity to do so should install Flock and give it a try. It&#8217;s fun, and you might just like something.</p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://sethjust.com/2008/04/14/flock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

