<?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>Evan Meagher &#187; Programming</title>
	<atom:link href="http://evanmeagher.net/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://evanmeagher.net</link>
	<description>Pragmatic design and tech</description>
	<lastBuildDate>Sat, 13 Feb 2010 00:35:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Geolocation API for distributed computing research</title>
		<link>http://evanmeagher.net/2010/01/geolocation-api-for-distributed-computing-research</link>
		<comments>http://evanmeagher.net/2010/01/geolocation-api-for-distributed-computing-research#comments</comments>
		<pubDate>Sat, 16 Jan 2010 00:54:38 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://evanmeagher.net/?p=143</guid>
		<description><![CDATA[Last quarter, I quit my web development job at the UW Clinical Trial Center in order to pursue research within UW&#8217;s CSE department. As a startup project for a distributed computing research project called Seattle, I put together a simple geolocation library that uses a Python library called pygeoip to look up location data for [...]]]></description>
			<content:encoded><![CDATA[<p>Last quarter, I quit my web development job at the UW Clinical Trial Center in order to pursue research within UW&#8217;s CSE department. As a startup project for a distributed computing research project called <a href="http://cs.washington.edu/">Seattle</a>, I put together a simple geolocation library that uses a Python library called <a href="http://code.google.com/p/pygeoip/">pygeoip</a> to look up location data for hostnames and IP addresses.</p>
<p>The first step was to set up an XML-RPC server to serve remote calls to the pygeoip API. This was fairly easy to do using Python&#8217;s SimpleXMLRPCServer class:</p>
<pre class="prettyprint lang-python">from SimpleXMLRPCServer import SimpleXMLRPCServer
import pygeoip
...
# Create server
server = SimpleXMLRPCServer((ip, port), allow_none=True)</pre>
<p>The location-lookup methods within the pygeoip library must be registered for use via the XML-RPC server. We first initialize a GeoIP object, passing it the filename of a valid <a href="http://www.maxmind.com/app/ip-location">binary GeoIP database</a>. Then the GeoIP object is passed to the XML-RPC server&#8217;s register_instance method to expose its methods for remote execution:</p>
<pre class="prettyprint lang-python"># Initialize and register GeoIP object
gi = pygeoip.GeoIP(geoipdb_filename)
server.register_instance(gi)

# Run the server's main loop
server.serve_forever()</pre>
<p>The lookup methods of pygeoip can now be called remotely. To demonstrate my project, I wrote a script that fetches the IPs of all nodes in the distributed computing network that you&#8217;ve allocated, looks up their lat/lang coordinates, and plots them on a Google map. For funsies I used the <a href="https://developer.mozilla.org/en/using_geolocation">geolocation API built into Firefox 3.5+</a>to include a pointer to the user&#8217;s current location.</p>
<div id="attachment_154" class="wp-caption aligncenter" style="width: 310px"><a href="http://evanmeagher.net/wp-content/uploads/2009/12/pygeoip_demo_screenshot.jpg"><img class="size-medium wp-image-154 " title="pygeoip_demo_screenshot" src="http://evanmeagher.net/wp-content/uploads/2009/12/pygeoip_demo_screenshot-300x192.jpg" alt="" width="300" height="192" /></a><p class="wp-caption-text">Screenshot of project demo</p></div>
<p>Hopefully my little library will get some use. Moving into the new year, I&#8217;m hoping to increase my involvement in the Seattle project and become more familiar with networking and API design.</p>
]]></content:encoded>
			<wfw:commentRss>http://evanmeagher.net/2010/01/geolocation-api-for-distributed-computing-research/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculating server time with a Javascript date object</title>
		<link>http://evanmeagher.net/2009/10/calculating-server-time-with-a-javascript-date-object</link>
		<comments>http://evanmeagher.net/2009/10/calculating-server-time-with-a-javascript-date-object#comments</comments>
		<pubDate>Tue, 13 Oct 2009 17:46:15 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://evanmeagher.net/?p=119</guid>
		<description><![CDATA[A few weeks ago at work I was assigned to develop a warning banner to be displayed across our intranet data entry site to warn users of impending code launches. Our users tend to leave pages open for a while as they enter data, so we wanted the banner to display dynamically. For example, if someone [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago at work I was assigned to develop a warning banner to be displayed across our intranet data entry site to warn users of impending code launches. Our users tend to leave pages open for a while as they enter data, so we wanted the banner to display dynamically. For example, if someone had a page open during a specified warning time, the banner should be displayed without having to refresh the page. My solution was a 60-second time-comparison poll closed over by an anonymous function.</p>
<p>My initial implementation created a Javascript date object and compared the results of its <code>getUTCDay</code>, <code>getUTCHours</code>, and <code>getUTCMinutes()</code> functions to the developer-specified warning times. If the current time was greater than the set warning time, the banner was displayed. There&#8217;s some cookie-handling in there so that the user can close the warning banner and not have it show up until the next warning time, but no bother.</p>
<p>A potential problem arose in that Javascript uses the client&#8217;s local time to create date objects. Thus if the user&#8217;s computer had incorrect time, the warning banner wouldn&#8217;t display when it was supposed to. A better way to go about it would be to use the server&#8217;s time instead of the client&#8217;s.</p>
<p>Luckily I could make use of <a href="http://www.masonhq.com/">Mason</a>&#8217;s preprocessor to insert the results of the Perl <code>time()</code> function into clientside Javascript to get the server time. I first calculate the client/server time difference and then use it to create an accurate date object inside the poll function.</p>
<pre class="prettyprint lang-javascript">// Determine delta between client and server times
var time_delta = (<% time %> * 1000) - Date.now();

function launchWarningPoll() {
    var d = new Date(Date.now() + time_delta);
    ...
}</pre>
<p>As <code>launchWarningPoll()</code> gets called every 60 seconds, it will accurately portray the server time regardless of how much the user&#8217;s local time is off.</p>
]]></content:encoded>
			<wfw:commentRss>http://evanmeagher.net/2009/10/calculating-server-time-with-a-javascript-date-object/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Eureka Invention Generator</title>
		<link>http://evanmeagher.net/2009/08/introducing-eureka-invention-generator</link>
		<comments>http://evanmeagher.net/2009/08/introducing-eureka-invention-generator#comments</comments>
		<pubDate>Fri, 07 Aug 2009 04:46:42 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://evanmeagher.net/?p=75</guid>
		<description><![CDATA[I just submitted a little web app I&#8217;ve been working on this summer for Sunlight Labs&#8217; Apps for America 2 programming challenge. The idea of the contest is to build an app around one of the datasets provided by our friendly US government on the new Data.gov website. My app is called Eureka and it [...]]]></description>
			<content:encoded><![CDATA[<p>I just submitted a little web app I&#8217;ve been working on this summer for Sunlight Labs&#8217; <a href="http://sunlightlabs.com/contests/appsforamerica2/">Apps for America 2</a> programming challenge. The idea of the contest is to build an app around one of the datasets provided by our friendly US government on the new <a href="http://www.data.gov/">Data.gov</a> website. My app is called<a href="http://eurekaapp.com/"> Eureka</a> and it generates inventions.</p>
<p style="text-align: center;"><a class="imglink" href="http://eurekaapp.com/"><img class="aligncenter" src="http://eurekaapp.com/img/branding.png" alt="Eureka Invention Generator" /></a></p>
<p>The app is built around a <a href="http://en.wikipedia.org/wiki/Markov_process">Markov processor</a> assignment I had last quarter in a programming languages course. Essentially the program uses Markov chains and a binary tree of <a href="http://en.wikipedia.org/wiki/N-gram">n-grams</a> to generate random text based on word frequencies of whatever source text you feed it. In effect, the generated text is babble in the language of whatever source document you input.</p>
<p>I had a lot of fun playing with the program last quarter. I&#8217;d give it the <a href="http://www.gutenberg.org/etext/18127">history of America as a text file</a> and get to read about English settlers crossing the Delaware under siege by the Confederate army. Or noticing how randomly-generated text in the language of <a href="http://www.gutenberg.org/etext/7999">the Bible</a> wasn&#8217;t really any easier to read than the real thing.</p>
<p>After hearing about the Apps for America 2 challenge, I spent a few weeks scoping out datasets on Data.gov and thinking about ways to use them. I zeroed in on the <a href="http://www.data.gov/details/2">XML files of US patent application bibliographic data</a> and eventually connected the dots back to the Markov processor assignment.</p>
<p>The contest entry page for Eureka can be viewed <a href="http://sunlightlabs.com/contests/appsforamerica2/apps/eureka-invention-generator/">here</a>. All source code is available on <a href="http://github.com/mongoose/eureka/tree/master">GitHub</a>. This includes some shell and Python scripts to validate and parse the XML, a Ruby port of my Markov processor (originally in ML), and the website frontend of the app.</p>
]]></content:encoded>
			<wfw:commentRss>http://evanmeagher.net/2009/08/introducing-eureka-invention-generator/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The future of computer science on TWiT</title>
		<link>http://evanmeagher.net/2008/07/the-future-of-computer-science-on-twit</link>
		<comments>http://evanmeagher.net/2008/07/the-future-of-computer-science-on-twit#comments</comments>
		<pubDate>Fri, 04 Jul 2008 20:52:58 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://evanmeagher.net/?p=29</guid>
		<description><![CDATA[Just listened to This Week In Tech, episode 149. About an hour in, the panel took a brief break from trading Bill Gates stories and got into a discussion of the future of computers and the science thereof. Jerry Pournelle predicted that in three or four years, computers will have 64 cores and virtually infinite [...]]]></description>
			<content:encoded><![CDATA[<p>Just listened to <a href="http://twit.tv/149">This Week In Tech, episode 149</a>. About an hour in, the panel took a brief break from trading Bill Gates stories and got into a discussion of the future of computers and the science thereof. <a href="http://jerrypournelle.com/">Jerry Pournelle</a> predicted that in three or four years, computers will have 64 cores and virtually infinite computing power, memory, and storage capacity. As a result, softwares&#8217; strain on hardware will become a nonissue and&#8230;</p>
<blockquote><p>&#8220;The people who are going to make money are the ones who are going to figure out how a guy who knows how to do something useful and doesn&#8217;t care about computer science can sit down and teach the damn machine to do something useful without having to spend four years learning to program.&#8221;<br />
<a href="http://jerrypournelle.com/"><cite>Jerry Pournelle</cite></a>
</p></blockquote>
<p>Good food for thought, to say the least. As a prospective computer science student, this both fascinates and worries me. On the one hand, the engineer in me is excited by the thought of creating this kind of uniformly-accessible development environment, but I also worry that if this were to come true, a degree in computer engineering would be worth that much less. I agree that programming and software development is currently somewhat of a walled garden. Anyone unwilling to spend countless hours learning the semantics and logic of seemingly meaningless code is left dependent on the output of those who are. However, it&#8217;s this specialization and difficulty of craft that leads to engineers&#8217; high salaries. Cognitive dissonance FTL.</p>
<p><a href="http://twit.tv/149">This week&#8217;s TWiT</a> is definitely worth a listen, if this kind of thing interests you. They had some interesting things to say regarding natural language programming, too. It&#8217;s refreshing to FINALLY listen to an episode where they don&#8217;t spend 45 minutes talking about Twitter.</p>
]]></content:encoded>
			<wfw:commentRss>http://evanmeagher.net/2008/07/the-future-of-computer-science-on-twit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object-Oriented Sandwich Making</title>
		<link>http://evanmeagher.net/2008/01/object-oriented-sandwich-making</link>
		<comments>http://evanmeagher.net/2008/01/object-oriented-sandwich-making#comments</comments>
		<pubDate>Fri, 25 Jan 2008 09:48:49 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[oriented]]></category>

		<guid isPermaLink="false">http://evanmeagher.net/2008/01/object-oriented-sandwich-making</guid>
		<description><![CDATA[The phrase &#8220;object-oriented&#8221; is thrown around a lot. It&#8217;s a very interesting concept and paradigm, but it can be a hard one for non-programmers to understand. Imagine that you want to write a recipe for making peanut butter and jelly sandwiches. Imagine that the person you&#8217;re writing the recipe for has no idea what a [...]]]></description>
			<content:encoded><![CDATA[<p>The phrase &#8220;<a href="http://en.wikipedia.org/wiki/Object_oriented">object-oriented</a>&#8221; is thrown around a lot. It&#8217;s a very interesting concept and paradigm, but it can be a hard one for non-programmers to understand.</p>
<p>Imagine that you want to write a recipe for making peanut butter and jelly sandwiches. Imagine that the person you&#8217;re writing the recipe for has no idea what a peanut butter and jelly sandwich is, so you have to write explicitly what to do, step by step.</p>
<p>The resulting recipe would be very long and contain a lot of seemingly-trivial tasks that any idiot should take for granted like &#8220;find a jar in cupboard labeled &#8216;Crunchy Peanut Butter&#8217;&#8221; and &#8220;transfer a glob of peanut butter from the jar onto bread using a butter knife.&#8221;</p>
<p>To relate this example to programming, the person you&#8217;re writing the recipe for is a computer (compiler), the sandwich is a program, and the recipe itself is an algorithm. All a program is is a set of directions telling a computer what to do, step by step.</p>
<p>So, back to object-oriented programming&#8230; imagine now that you&#8217;re writing the same recipe for a person who knows a bit about the culinary arts. You won&#8217;t have to explicitly tell them every step. You&#8217;re recipe will be <em>much</em> shorter:</p>
<ol>
<li>Get 2 pieces of bread, 1 jar of peanut butter, and 1 jar of raspberry jam</li>
<li>Spread peanut butter and jelly onto corresponding slices of bread.</li>
<li>Put two slices together.</li>
<li>Eat! (optional)</li>
</ol>
<p>This is object-oriented recipe-making. You assume that the person knows what they&#8217;re doing and thus you can give higher-level instructions. In object-oriented programming, the program that you write takes advantage of already-written packages of code (called object classes), and allows you to tell the computer what to do without having to go into the nitty gritty details of every complex task.</p>
<p>In the sandwich example, the more complex steps of the second recipe can be abstracted as objects to be used in the sandwich-making algorithm.</p>
<p>Who said algorithms can&#8217;t be tasty?</p>
]]></content:encoded>
			<wfw:commentRss>http://evanmeagher.net/2008/01/object-oriented-sandwich-making/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
