<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>thirstymind.org &#187; programming</title>
	<atom:link href="http://www.thirstymind.org/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thirstymind.org</link>
	<description>andrew watts' weblog</description>
	<lastBuildDate>Sat, 17 Oct 2009 22:11:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fixing twitterrific&#8217;s iphone lat lon cryptography the hard way</title>
		<link>http://www.thirstymind.org/2008/08/03/fixing-twitterrifics-iphone-lat-lon-cryptography-the-hard-way/</link>
		<comments>http://www.thirstymind.org/2008/08/03/fixing-twitterrifics-iphone-lat-lon-cryptography-the-hard-way/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 00:10:18 +0000</pubDate>
		<dc:creator>Andrew Watts</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[twitterrific]]></category>

		<guid isPermaLink="false">http://www.thirstymind.org/?p=381</guid>
		<description><![CDATA[Twitterrific&#8217;s iPhone App updates your location on twitter using the twitter api.  This is fine and dandy but the problem is that it updates with the actual latitude and longitude that (I assume) comes from the iphone api.
So, since most people simply just want to know where you are without hurting their heads doing [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://iconfactory.com/software/twitterrific">Twitterrific&#8217;s iPhone App</a> updates your location on twitter using the <a href="http://groups.google.com/group/twitter-development-talk/web/api-documentation#AccountMethods">twitter api</a>.  This is fine and dandy but the problem is that it updates with the actual latitude and longitude that (I assume) comes from the iphone api.</p>
<p>So, since most people simply just want to know where you are without hurting their heads doing a reverse geocode,  I have created a <a href="https://addons.mozilla.org/en-US/firefox/addon/748">greasemonkey</a> user script to help them out.  </p>
<p><em>It takes a twitterrific created location that says &#8220;iPhone: 40.733956,-73.992789&#8243; and turns it into &#8220;New York, New York, US&#8221;</em></p>
<p>If you have greasemonkey installed, all you need to do is <a href="http://www.thirstymind.org/playpen/js/twitter-latlon2address/twitter-latlon2address.user.js" alt="twitter-latlon2address.user.js">download and install this user script</a> and you will be set.  If you don&#8217;t have greasemonkey, then you will need to obviously install it first and revisit this page to download the user script.</p>
<p>Hopefully one day the twitterrific iphone app will do this automatically so this script is not needed, but until then, I hope this helps some people out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thirstymind.org/2008/08/03/fixing-twitterrifics-iphone-lat-lon-cryptography-the-hard-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brief Thoughts on PyOhio</title>
		<link>http://www.thirstymind.org/2008/08/02/brief-thoughts-on-pyohio/</link>
		<comments>http://www.thirstymind.org/2008/08/02/brief-thoughts-on-pyohio/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 18:31:12 +0000</pubDate>
		<dc:creator>Andrew Watts</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[pyohio]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.thirstymind.org/?p=379</guid>
		<description><![CDATA[Last Saturday I attended PyOhio in Columbus and I wanted to write a few words before too much time went by.  I went for a couple reasons, mainly because I have just begun learning about python and have made it about half way through Mark Lutz&#8217;s Learning Python, so I was hoping to get [...]]]></description>
			<content:encoded><![CDATA[<p>Last Saturday I attended <a href="http://www.pyohio.org/">PyOhio</a> in Columbus and I wanted to write a few words before too much time went by.  I went for a couple reasons, mainly because I have just begun learning about python and have made it about half way through Mark Lutz&#8217;s <a href="http://www.amazon.com/Learning-Python-3rd-Mark-Lutz/dp/0596513984/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1217700828&#038;sr=8-1">Learning Python</a>, so I was hoping to get some real world examples and learn more about the language.  Another reason I went, is that I haven&#8217;t been to a tech conference in a while and you learn so many new things when you go to these types of events to see what other geeks are up to.</p>
<p>2 talks stick out in my mind.</p>
<p>First the &#8220;<a href="http://scratch.tplus1.com/decoratortalk/">Decorators Are Fun</a>&#8221; discussion by <a href="http://blog.tplus1.com/">Matthew Wilson</a> was easily the most enjoyable discussion for me.  Obviously, he demonstrated python decorators, which allow you to dynamically modify functions without actually changing the function.  Decorators are not totally unlike AOP or java annotations and it was interesting to see python examples.  If there was a downside, it was that his presentation was a little too fast, when you start nesting functions and talking about functions that modify other functions, it gets a little hairy especially if you are new to the concept.  But it also makes a ton of sense once you get the hang of it.</p>
<p>The second talk I really enjoyed was <a href="http://blog.extracheese.org/">Gary Bernhardt&#8217;s</a> Talking to the Web with Python.  During the talk Gary demonstrated 2 python modules, <a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a> and <a href="http://www.feedparser.org/">Universal Feed Parser</a>, for parsing html &#038; xml.  I enjoyed this because he provided some very practical examples (eg: parse a webpage for links) of things you may want to do with parsing web pages or syndication feeds.  He even showed a simple web crawler in about 8 lines of code, using these modules.  Plus Gary had the first talk of the day, which is tough, but he brought a lot of energy to the discussion and kept me focused on his talk, which was good since I was up until 4:30 the night before and the red bull hadn&#8217;t kicked in yet.</p>
<p>All in all it was a good day and I am glad I went, I don&#8217;t know that I have ever been so excited to learn a new programming language, there is something about python that just clicks in my head, it makes a ton of sense to me.  Back in college the president of ACM tried to get me to learn it, but I didn&#8217;t listen, not sure why it has taken me 7 years to dig in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thirstymind.org/2008/08/02/brief-thoughts-on-pyohio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Handling whitespace in bash for loops</title>
		<link>http://www.thirstymind.org/2008/06/27/handling-whitespace-in-bash-for-loops/</link>
		<comments>http://www.thirstymind.org/2008/06/27/handling-whitespace-in-bash-for-loops/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 03:31:24 +0000</pubDate>
		<dc:creator>Andrew Watts</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[macports]]></category>

		<guid isPermaLink="false">http://www.thirstymind.org/?p=366</guid>
		<description><![CDATA[Tonight I was trying to cleanup my macports installation by uninstalling the packages that are no longer active.  I decided to write a script to do this, instead of manually uninstalling them one by one.  But in writing the script I came across something I had never seen and the google didn&#8217;t give [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I was trying to cleanup my <a href="http://www.macports.org/">macports</a> installation by uninstalling the packages that are no longer active.  I decided to write a script to do this, instead of manually uninstalling them one by one.  But in writing the script I came across something I had never seen and the google didn&#8217;t give me a clear answer so I thought I would share.</p>
<p>A typical for loop might look like:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">$ <span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> `<span class="kw2">ls</span>`</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> &nbsp; &nbsp; <span class="kw3">echo</span> <span class="re1">$file</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">done</span></div>
</li>
</ol>
</div>
<p>And this assumes there are no spaces in any of the files returned by ls.  I did not know this.  So I started doing something similar with this:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">$ <span class="kw1">for</span> package <span class="kw1">in</span> `port installed <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st0">&#39;NF==2{print $0}&#39;</span> `</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">do</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> &nbsp; &nbsp; <span class="kw3">echo</span> <span class="re1">$package</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">done</span></div>
</li>
</ol>
</div>
<p>But I got output that looked like this:</p>
<div class="geshi no none">
<ol>
<li class="li1">
<div class="de1">curl
</div>
</li>
<li class="li1">
<div class="de1">@7.17.1_0
</div>
</li>
<li class="li1">
<div class="de1">gettext
</div>
</li>
<li class="li1">
<div class="de1">@0.17_2</div>
</li>
</ol>
</div>
<p>And wanted output like this:</p>
<div class="geshi no none">
<ol>
<li class="li1">
<div class="de1">curl @7.17.1_0
</div>
</li>
<li class="li1">
<div class="de1">gettext @0.17_2</div>
</li>
</ol>
</div>
<p>The problem is the awk output had spaces in it which were split by the for loop processing.  And well to handle the spaces as desired you need to pipe the output to a while loop like so:</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1">$ port installed <span class="sy0">|</span> <span class="kw2">awk</span> <span class="st0">&#39;NF==2{print $0}&#39;</span> <span class="sy0">|</span> <span class="kw1">while</span> <span class="kw2">read</span> pakage</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">do</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> &nbsp; &nbsp; <span class="kw2">sudo</span> port uninstall <span class="re1">$package</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&gt;</span> <span class="kw1">done</span></div>
</li>
</ol>
</div>
<p>And now $package is what I expect including the spaces, and my macports installation is a little cleaner.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thirstymind.org/2008/06/27/handling-whitespace-in-bash-for-loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
