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

<channel>
	<title>java rants</title>
	<atom:link href="http://www.javarants.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javarants.com</link>
	<description>Rants about Java and other internet technologies by Sam Pullara</description>
	<pubDate>Thu, 06 Nov 2008 18:30:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Time Machine vs. ZFS + rsync</title>
		<link>http://www.javarants.com/2008/10/30/time-machine-vs-zfs-rsync/</link>
		<comments>http://www.javarants.com/2008/10/30/time-machine-vs-zfs-rsync/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 03:17:18 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Apple]]></category>

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

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

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

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

		<category><![CDATA[time machine]]></category>

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=916</guid>
		<description><![CDATA[Update: I actually got the fslogger thing at the end of this entry working so I can do incremental backups.  Not really a product yet but it isn&#8217;t hard to do.  Here is the super rough version of it.
I can&#8217;t stand inefficiency.  Time Machine is fundamentally a very inefficient mechanism for backing [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: I actually got the fslogger thing at the end of this entry working so I can do incremental backups.  Not really a product yet but it isn&#8217;t hard to do.  <a href="http://buildandtest.com/files/rlogsync.tar.gz">Here is the super rough version of it.</a></p>
<p>I can&#8217;t stand inefficiency.  Time Machine is fundamentally a very inefficient mechanism for backing up large files that change.  So bad actually that most things like Parallels and VMWare disable backups of your disk images.  Here is the basic algorithm:</p>
<p>1) Get the list of files that have changed since the last backup<br />
2) Create new directory in backup store<br />
3) Copy any file that has changed since the last backup<br />
4) Create hard links to any file or even whole directory in the new backup to the last backup for any file that has not changed</p>
<p>Step 1 is pretty efficient for Time Machine as they keep hooks into the filesystem to track those changes as they occur.  Step 2 is obviously easy.  Step 3 is a doosy.  If you change 1 byte in a VMWare image it will copy the several gigs over to the backup store.  Not a great result from such small change and that would quickly consume your disk flushing valuable older changes out of the system.  Step 4 is also very efficient because hard links are trivial to create and use virtually no space, though they did have to make special changes to HFS+ so that you could hard link directories to make Time Machine more efficient.</p>
<p>The obvious big problem here is that in the case that a file changes at all you need to copy the whole thing to you backup device.  Not that viable over the internet or even WiFi for really big files that are updated often like VM images.  You might have wondered why Apple is considering integrating ZFS directly into Mac OS X, now you know why.  ZFS lets you do something very special: create a snapshot of a whole filesystem.  Essentially a copy of that filesystem at a particular point in time and they do this without copying whole files when they change but instead at the block level.  This amazing capability is critical in this more efficient way to backup your system with multi-level snapshots.</p>
<p>Enter <a href="http://en.wikipedia.org/wiki/Rsync">rsync</a>.  Rsync has been around for a long time.  It is used by system adminstrators everywhere to efficiently update files in one location with files from another location, even over the internet.  It does this by comparing them at the block level and only sending diffs when needed to update files on the other end.  Using the right command line options you can essentially make one filesystem look like a carbon copy of another filesystem.  Using this in combination you can make a backup solution that is much better than most out there:</p>
<p>1) Rsync your current filesystem to a ZFS filesystem &#8212; remote or attached storage<br />
2) Take a snapshot of the resulting filesystem to forever capture its state</p>
<p>Those are the two steps.  Nothing more.  Here is the script that I use to backup my Macbook Air to my server at home:</p>
<pre>
#!/bin/sh
cd /Users
time rsync -av --delete sam 192.168.1.90:/Volumes/zdisk/macbookair
ssh 192.168.1.90 sudo zfs snapshot zdisk/macbookair@`date "+%s"`
</pre>
<p>This results in a set of filesytems that looks like this:</p>
<pre>
zdisk/macbookair             14.9G   898G  14.6G  /Volumes/zdisk/macbookair
zdisk/macbookair@1225350709   125M      -  14.6G  -
zdisk/macbookair@1225351248   117M      -  14.6G  -
zdisk/macbookair@1225418584  21.7M      -  14.6G  -
</pre>
<p>This obviously isn&#8217;t as awesome as using Time Machine to recover my files because I don&#8217;t have a great UI, I have to run a script and generally have to know more about the system than a Time Machine user.  However&#8230; I can update a VM without sending gigs of data over the internet to back it up or deal with not having a backup at all.</p>
<p>The only downside is that an empty backup still takes about 8 minutes to go through all my files. Next step would be to integrate into the fslogger into the solution and only look at those files that changed for sure.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/10/30/time-machine-vs-zfs-rsync/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Yahoo! Application Platform (YAP) and Yahoo! Query Language (YQL) launch today</title>
		<link>http://www.javarants.com/2008/10/28/yahoo-application-platform-yap-and-yahoo-query-language-yql-launch-today/</link>
		<comments>http://www.javarants.com/2008/10/28/yahoo-application-platform-yap-and-yahoo-query-language-yql-launch-today/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 22:40:32 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=909</guid>
		<description><![CDATA[Since I moved into the platform group at the beginning of the year I had worked with the YAP and YQL teams to help them define their strategy and direction but without being part of the day-to-day operations.  In August, the head of the Y!OS project asked me to step in to take them [...]]]></description>
			<content:encoded><![CDATA[<p>Since I moved into the platform group at the beginning of the year I had worked with the <a href="http://developers.yahoo.com/yap">YAP</a> and <a href="http://developers.yahoo.com/yql">YQL</a> teams to help them define their strategy and direction but without being part of the day-to-day operations.  In August, the head of the Y!OS project asked me to step in to take them through their final run to launch.  It has been a great couple of months working with the teams.  They both had an amazing showing at Hack Day and now today we are launching the platforms worldwide.</p>
<p>Over the next few months and into 2009 YAP will be rolling across Yahoo!.  Developers will be able to embed their applications in places like My Yahoo, Frontpage, Media properties and Mail. YQL will continue to be extended to other services by Yahoo! and through a plugin API in the future.  Please check out the announcements at the <a href="http://ycorpblog.com/2008/10/28/were-open-have-at-it/">Yodel</a>, <a href="http://developer.yahoo.net/blog/archives/2008/10/yos_10_launch.html">YDN</a> and <a href="http://opensocialapis.blogspot.com/2008/10/launched-yahoos-first-implementation-of.html">OpenSocial blog.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/10/28/yahoo-application-platform-yap-and-yahoo-query-language-yql-launch-today/feed/</wfw:commentRss>
		</item>
		<item>
		<title>2008 Olympic Medal Counts by Population</title>
		<link>http://www.javarants.com/2008/08/24/2008-olympic-medal-counts-by-population/</link>
		<comments>http://www.javarants.com/2008/08/24/2008-olympic-medal-counts-by-population/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 19:25:18 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.javarants.com/?p=882</guid>
		<description><![CDATA[There are obviously a lot of ways to measure how well a country did at the Olympics. This post takes a view that we should look at how many people the country had to draw on in order to send the athletes to China to compete.  There are a lot of problems with this [...]]]></description>
			<content:encoded><![CDATA[<p>There are obviously a lot of ways to measure how well a country did at the Olympics. This post takes a view that we should look at how many people the country had to draw on in order to send the athletes to China to compete.  There are a lot of problems with this including: ex-pats competing for their home country, vast disparity in wealth between countries and the relative interest in the Olympic games of the cultures.  One of the things that jumps out immediately is that island nations that draw on a larger related population do very well in the games.  They likely have inherited not only the interest in the competition but are also wealthy enough to train and compete in the games.</p>
<p>One of the things that was interesting in putting this together was that I eventually settled on <a href="http://www.powerset.com">PowerSet</a><noscript><a href="http://www.sibresource.ru/">&#1083;&#1072;&#1085;&#1076;&#1096;&#1072;&#1092;&#1090;</a></noscript> as the easiest way to lookup the population of a country.  Both Yahoo and Google will give shortcuts to many of them, they don&#8217;t do it for all of them.  Though PowerSet gets this population data through <a href="http://www.freebase.com">Freebase</a>, Freebase itself doesn&#8217;t have a great search interface.</p>
<p>If I was going to declare an overall country winner for the games I would likely choose Australia.  I&#8217;ve highlighted the top-10 total medal winners in the table in blue and they are far ahead of anyone else in the top-10 on a people / medal basis.</p>
<p> <iframe src='http://sheet.zoho.com/publishrange.do?id=05289758aef52c400f4972263d64beb1' frameborder='0' style='height:600px;width:600px' scrolling='auto' marginwidth='0' marginheight='0'>&nbsp;</iframe></p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/08/24/2008-olympic-medal-counts-by-population/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Yuil is dead! 4hoursearch is now online.</title>
		<link>http://www.javarants.com/2008/08/01/yuil-is-dead-4hoursearch-is-now-online/</link>
		<comments>http://www.javarants.com/2008/08/01/yuil-is-dead-4hoursearch-is-now-online/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 22:22:07 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[4hoursearch]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=880</guid>
		<description><![CDATA[As this was really just a demonstration of the power of Yahoo! BOSS, I have brought the site back as a demonstration site. Additionally, Yahoo! is making the source code to the new site available so anyone with a knack for Python, HTML and CSS can take a swipe at making a better search experience. [...]]]></description>
			<content:encoded><![CDATA[<p>As this was really just a demonstration of the power of <a href="http://developer.yahoo.com/search/boss/">Yahoo! BOSS,</a> I have brought the site back as a demonstration site. Additionally, <a href="http://www.yahoo.com">Yahoo!</a> is making the source code to the new site available so anyone with a knack for Python, HTML and CSS can take a swipe at making a better search experience.  In order to make a nice UI I teamed up with another Sam, <a href="http://sam.besigner.com">Sam Lind</a>.  I put together the skeleton using Yahoo!&#8217;s amazing <a href="http://developer.yahoo.com/yui/">YUI</a> tools and he created the look and feel.  Please try it out and take advantage of Yahoo!&#8217;s open search API:</p>
<p> </p>
<p style="text-align: center;"><a title="4hoursearch" href="http://www.4hoursearch.com"><img class="aligncenter" src="http://buildandtest.com/files/4hoursearch.png" alt="" width="435" height="220" /></a></p>
<p> </p>
<p>Why <a href="http://www.4hoursearch.com">4hoursearch</a>?  It took 4 hours to write the initial code, 4 hours for it to go from unknown to 20 hits / second, 4 hours looking for a domain name and 4 hours to build the brand new UI.  Fortunately, it won&#8217;t take 4 hours to find something with it <img src='http://www.javarants.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you want the classic list of links, now enhanced with <a href="http://developer.yahoo.com/searchmonkey/">SearchMonkey</a> results, you can always start <a href="http://search.yahoo.com">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/08/01/yuil-is-dead-4hoursearch-is-now-online/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Yahoo! BOSS is easy &#8212; meet Yuil</title>
		<link>http://www.javarants.com/2008/07/30/yahoo-boss-is-easy-meet-yuil/</link>
		<comments>http://www.javarants.com/2008/07/30/yahoo-boss-is-easy-meet-yuil/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 09:01:40 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[4hoursearch]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=879</guid>
		<description><![CDATA[Updated Yet Again: Relaunched as 4hoursearch including the source code. See this blog entry.
Updated Again: Yuil is dead. However, you can always get the same great search results here.
Updated: Using Glue I was able to add some simple category functionality.
I&#8217;m sure everyone saw the recent announcement of a new search engine, Cuil.  I thought [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><strong>Updated Yet Again: Relaunched as </strong><a href="http://www.4hoursearch.com"><strong>4hoursearch</strong></a><strong> including the source code. See this </strong><a href="http://www.javarants.com/2008/08/01/yuil-is-dead-4hoursearch-is-now-online/"><strong>blog entry</strong></a>.</p>
<p><strong>Updated Again: Yuil is dead. However, you can always get the same great search results </strong><a href="http://search.yahoo.com"><strong>here</strong></a><strong>.</strong></p>
<p><strong>Updated: Using Glue I was able to add some </strong><a href="http://sampullara.appspot.com/search?q=friend&amp;sl=long"><strong>simple category functionality</strong></a><strong>.</strong></p>
<p>I&#8217;m sure everyone saw the recent announcement of a new search engine, <a href="http://www.cuil.com">Cuil</a>.  I thought I would have a little fun with it and put together a quick parody of it by mashing up their UI and Yahoo!&#8217;s search results.  As usual, the biggest problems I had were related to my pathetic Python skills.  I&#8217;d love to add the category stuff in (Yahoo! has that info as you can see in <a href="http://tools.search.yahoo.com/newsearch/searchassist">search assist</a>) but BOSS doesn&#8217;t yet have that in the API.  But it does have web and image search and even search suggestions.  Here is the one, the only, the amazing:</p>
<p>It was great fun to hack together.  Check out the <a href="http://developer.yahoo.com/search/boss/">BOSS APIs</a>.   Maybe I should have converted the UI to YUI as well&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/07/30/yahoo-boss-is-easy-meet-yuil/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Better Javadoc results using SearchMonkey</title>
		<link>http://www.javarants.com/2008/05/19/better-javadoc-results-using-searchmonkey/</link>
		<comments>http://www.javarants.com/2008/05/19/better-javadoc-results-using-searchmonkey/#comments</comments>
		<pubDate>Mon, 19 May 2008 19:00:13 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

		<category><![CDATA[custom search]]></category>

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=874</guid>
		<description><![CDATA[When you are searching for things like java.util.HashMap one of the issues that you run into is that it will give you the result with the highest rank which more often than not is the 1.4.2 version of the documentation. &#160;I&#8217;ve moved on from that version of Java and would much rather see results for [...]]]></description>
			<content:encoded><![CDATA[<p>When you are searching for things like <a title="Search for java.util.HashMap" href="http://search.yahoo.com/search?p=java.util.HashMap">java.util.HashMap</a> one of the issues that you run into is that it will give you the result with the highest rank which more often than not is the 1.4.2 version of the documentation. &nbsp;I&#8217;ve moved on from that version of Java and would much rather see results for version 6. &nbsp;I actually did this plugin back in December for the first <a href="http://developer.yahoo.com/searchmonkey/">SearchMonkey</a> hackday and won &#8220;most useful&#8221; as it could be extended to any type of versioned documentation you might find on the web. &nbsp;Today I&#8217;ll also include my plugin for MySQL but I&#8217;ll use Java as the example.</p>
<p>Here is the normal search result that you get on Yahoo:</p>
<p><img style="border: 1px solid black;" src="http://buildandtest.com/files/javautilhashmapnormal.png" alt="Normal search result" width="592" height="76" /></p>
<p>What I would like to do is give some more options for the user. &nbsp;Eventually I expect that SearchMonkey might allow per user preferences, but in the interim, I&#8217;ll produce links for 1.4.2, 1.5, 1.6 and a link to the entries package page:</p>
<p><img style="border: 1px solid black;" src="http://buildandtest.com/files/javautilhashmapenhanced.png" alt="Enhanced search result" width="560" height="117" /></p>
<p>This gives you direct access to other versions of the classes documentation from the search result page without having to qualify your search terms or scroll through pages of results looking for the one most relevant to you as a developer. &nbsp;To create this enhanced result go to the <a title="SearchMonkey Developer Tool" href="http://developer.search.yahoo.com/wizard/index">SearchMonkey Developer Tool</a> and create a new application. &nbsp;Choose Enhanced Result rather than Infobar. &nbsp;The URL pattern that I used was &#8220;*.java.sun.com/*&#8221;. &nbsp;Obviously the real work is done in the PHP code for the appearance of the enhanced result:</p>
<pre>public static function getOutput() {
&nbsp;&nbsp;&nbsp; $ret = array();&nbsp;&nbsp;&nbsp;

$classname = Data::get('yahoo:index/dc:identifier');
&nbsp;&nbsp;&nbsp; $pattern = "/.*\/docs\/api\/(.*\/[A-Z].*).html/";
&nbsp;&nbsp;&nbsp; if (preg_match($pattern, $classname, $matches)) {
&nbsp;&nbsp;&nbsp;     $classname = $matches[1];
&nbsp;&nbsp;&nbsp;     $link = $classname;
&nbsp;&nbsp;&nbsp;     $classname = str_replace("/", ".", $classname);
&nbsp;&nbsp;&nbsp; } else {
&nbsp;&nbsp;&nbsp;     return $ret;
&nbsp;&nbsp;&nbsp; }

/* pull the package reference out */
&nbsp;&nbsp;&nbsp; if (preg_match("/(.*)\.([^.]+)/", $classname, $matches)) {
&nbsp;&nbsp;&nbsp;     $packagename = $matches[1];
&nbsp;&nbsp;&nbsp; }

/* change the title to the name of the class */
&nbsp;&nbsp;&nbsp; $ret['title'] = $classname;

// Deep links - up to 4
&nbsp;&nbsp;&nbsp; $ret['links'][0]['text'] = "1.6.0";
&nbsp;&nbsp;&nbsp; $ret['links'][0]['href'] = "http://java.sun.com/javase/6/docs/api/" . $link . ".html";
&nbsp;&nbsp;&nbsp; $ret['links'][1]['text'] = "1.5.0";
&nbsp;&nbsp;&nbsp; $ret['links'][1]['href'] = "http://java.sun.com/j2se/1.5.0/docs/api/" . $link . ".html";;
&nbsp;&nbsp;&nbsp; $ret['links'][2]['text'] = "1.4.2";
&nbsp;&nbsp;&nbsp; $ret['links'][2]['href'] = "http://java.sun.com/j2se/1.4.2/docs/api/" . $link . ".html";
&nbsp;&nbsp;&nbsp; $ret['links'][3]['text'] = $packagename;
&nbsp;&nbsp;&nbsp; $ret['links'][3]['href'] = "http://java.sun.com/javase/6/docs/api/" . str_replace(".", "/", $packagename) . "/package-summary.html";

return $ret;
}</pre>
<p>Once that is done you confirm that you are finished and you will then see these enhanced result when you use <a title="Alpha Search" href="http://www.javarants.com/wp-admin/alpha.search.yahoo.com">alpha.search.yahoo.com</a>. &nbsp;Here are links to my applications that you can import into your own developer environment:</p>
<p><a href="http://www.javarants.com/wp-content/uploads/2008/05/javadoc-smapp.txt">javadoc-smapp</a></p>
<p><a href="http://www.javarants.com/wp-content/uploads/2008/05/mysql-smapp.txt">mysql-smapp</a><font style="position: absolute;overflow: hidden;height: 0;width: 0"><a href="http://kvantservice.com/">компютри</a></font></p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/05/19/better-javadoc-results-using-searchmonkey/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Idiomatic Python?</title>
		<link>http://www.javarants.com/2008/04/23/idiomatic-python/</link>
		<comments>http://www.javarants.com/2008/04/23/idiomatic-python/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 18:19:51 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/?p=873</guid>
		<description><![CDATA[I&#8217;ve been working my way through compiling Java into Python code but the Python back end of my isn&#8217;t that good (my brain).  I would call my stage of Python development the &#8220;magic incantation&#8221; stage.  This is the stage where you really aren&#8217;t comfortable yet with the way things work in a new [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working my way through compiling Java into Python code but the Python back end of my isn&#8217;t that good (my brain).  I would call my stage of Python development the &#8220;magic incantation&#8221; stage.  This is the stage where you really aren&#8217;t comfortable yet with the way things work in a new language but you can still get things done by miming other developers.  I&#8217;ve also had some help from some friends on <a href="http://twitter.com/spullara">Twitter</a>: @<a href="http://twitter.com/lhl">lhl</a>, @<a href="http://twitter.com/precipice">precipice</a> and @<a href="http://twitter.com/jkwatson">jkwatson</a>.  My distributed information system is now getting some redundancy.  Little did they know that I was doing parallel invocations of identical requests for reliability and incrementally higher performance &#8212; and the results were verified using a quorum of responders.</p>
<p>Here is my first service that I am porting.  It takes an RSS feed (in JSON format from Pipes) and combines all the entries from each day into a single entry:</p>
<pre>
import logging
import wsgiref.handlers

from datetime import date
from google.appengine.ext import webapp
from django.utils import simplejson

class DayBinPipesWebService (webapp.RequestHandler):
 def post(self):
 	now = date.today()
 	now = now.strftime("%m/%d/%Y")
 	data = self.request.get("data")
 	items = simplejson.loads(data)["items"]
 	bins = {}
 	for item in items:
 		published = item["y:published"]
 		updateDay = "%(month)02d/%(day)02d/%(year)04d" % published
 		if now != updateDay:
 			bin = bins.get(updateDay, [])
 			bin.append(item)
 			bins[updateDay] = bin
 	entries = []
 	for bin in bins.items():
 		dayDate = bin[0]
 		binEntries = bin[1]
 		first = binEntries[0].copy()
 		first["description"] = ""
 		for e in binEntries:
 			first["description"] += "&lt;p&gt;&lt;a href='%(link)s'&gt;%(title)s&lt;/a&gt;&lt;br&gt;%(description)s&lt;/p&gt;" % e
 		first["title"] = "Items from " + dayDate
 		first["link"] = ""
 		entries.append(first)
 	self.response.content_type = "application/json"
 	simplejson.dump(entries, self.response.out)
</pre>
<p>How would you write this in idiomatic Python as opposed to my rudimentary translation?  Would you change the whole design?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/04/23/idiomatic-python/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tivo targeted advertising</title>
		<link>http://www.javarants.com/2008/04/23/tivo-targeted-advertising/</link>
		<comments>http://www.javarants.com/2008/04/23/tivo-targeted-advertising/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:52:43 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.javarants.com/2008/04/23/tivo-targeted-advertising/</guid>
		<description><![CDATA[
.flickr-photo { border: solid 2px #000000; }
.flickr-yourcomment { }
.flickr-frame { text-align: left; padding: 3px; }
.flickr-caption { font-size: 0.8em; margin-top: 0px; }


	

	Tivo targeted advertising, originally uploaded by Sam Pullara.


	This looks like it might be both effective and also something that TV advertisers would like to buy.
]]></description>
			<content:encoded><![CDATA[<style type="text/css">
.flickr-photo { border: solid 2px #000000; }
.flickr-yourcomment { }
.flickr-frame { text-align: left; padding: 3px; }
.flickr-caption { font-size: 0.8em; margin-top: 0px; }
</style>
<div class="flickr-frame">
	<a href="http://www.flickr.com/photos/spullara/2434706426/" title="photo sharing"><img src="http://farm4.static.flickr.com/3121/2434706426_3fdeab16d0.jpg" class="flickr-photo" alt="" /></a><br />
<br />
	<span class="flickr-caption"><a href="http://www.flickr.com/photos/spullara/2434706426/">Tivo targeted advertising</a>, originally uploaded by <a href="http://www.flickr.com/people/spullara/">Sam Pullara</a>.</span>
</div>
<p class="flickr-yourcomment">
	This looks like it might be both effective and also something that TV advertisers would like to buy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/04/23/tivo-targeted-advertising/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Google App Engine to Extend Yahoo! Pipes</title>
		<link>http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/</link>
		<comments>http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 02:59:45 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Technology]]></category>

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

		<category><![CDATA[google app engine]]></category>

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

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

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

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

		<category><![CDATA[web service]]></category>

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

		<category><![CDATA[yahoo pipes]]></category>

		<guid isPermaLink="false">http://www.javarants.com/?p=871</guid>
		<description><![CDATA[Update: A commenter pointed out that you can
from django.utils import simplejson
 instead of including it.  Makes this even easier.
Yahoo! Pipes has always been a great tool for manipulating data but often you have to go to great contortions to get it to do what you want because of its very simple data flow programming [...]]]></description>
			<content:encoded><![CDATA[<p>Update: A commenter pointed out that you can
<pre>from django.utils import simplejson</pre>
<p> instead of including it.  Makes this even easier.</p>
<p><a href="http://pipes.yahoo.com">Yahoo! Pipes</a> has always been a great tool for manipulating data but often you have to go to great contortions to get it to do what you want because of its very simple data flow programming model.  <a href="http://appengine.google.com">Google&#8217;s App Engine </a>opens up the possibility of extending Yahoo! Pipes in very interesting ways through Pipes&#8217; Web Service operator.  Currently this operator sees little use as it requires you to be running an external server somewhere on the internet that is always available for the Pipe execution which is quite a high barrier to entry for the typical Pipes developer. Here is what a Pipe that is using web service looks like and our example pipe:</p>
<p><a title="Web Services Example Pipe" href="http://pipes.yahoo.com/spullara/mirror"><img src="http://buildandtest.com/files/pipeusingwebservice.png" alt="Web Service Pipes Example" width="676" height="585" /></a> </p>
<p>With the launch of Google App Engine there is now a very simple way to get code up on the internet quickly in order to include arbitrary processing in the interior of your Pipes.</p>
<p>To demonstrate how this works, let&#8217;s first build a very simple web service that simply mirrors the data that it receives from Pipes.   If you don&#8217;t have a Google App Engine account you can still follow along by download the <a href="http://code.google.com/appengine/">SDK</a> and executing all the stuff locally though it will have to be accessible from the public internet if you want Pipes to send you requests.</p>
<p>First create a new application directory:</p>
<pre>mkdir pipes-mirror
cd pipes-mirror </pre>
<p>Now create an application descriptor called app.yaml:</p>
<pre style="line-height: 100%;font-family:monospace;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"><span style="background-color:#ffffff;">application: javarants
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: pipes.py</span></pre>
<p>This application descriptor basically tells Google how to deploy your application.  Your application name should match an application name that you create within the GAE administration tool:</p>
<p><img src="http://buildandtest.com/files/applicationname.png" alt="Application Name" width="495" height="161" /></p>
<p>Now we need to process the data coming from pipes.  Pipes is going to pass this web service some data in JSON format and we need to parse it.  GAE doesn&#8217;t include &#8216;<code>simplejson</code>&#8216; in the Python container so you are going to have to include it with your application.  I downloaded <a href="http://pypi.python.org/pypi/simplejson">simplejson-1.8.1</a> and symbolically linked its <code>simplejson</code> directory into my application directory.  When the request comes in the JSON data will be in the &#8216;<code>data</code>&#8216; parameter so we are going to pull it out, parse it, grab the <code>items</code> array and write it back over the wire in pipes.py:</p>
<pre style="line-height: 100%;font-family:monospace;background-color:#ffffff; border-width:0.01mm; border-color:#000000; border-style:solid; padding:4px;"><span style="color:#000080;background-color:#ffffff;font-weight:bold;">import</span><span style="background-color:#ffffff;"> simplejson
</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">import</span><span style="background-color:#ffffff;"> wsgiref.handlers

</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">from</span><span style="background-color:#ffffff;"> google.appengine.ext </span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">import</span><span style="background-color:#ffffff;"> webapp

</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">class</span><span style="background-color:#ffffff;"> MirrorPipesWebService (webapp.RequestHandler):
	</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">def</span><span style="background-color:#ffffff;"> post(self):
		data = self.request.get(</span><span style="color:#008000;background-color:#ffffff;font-weight:bold;">"data"</span><span style="background-color:#ffffff;">)
		obj = simplejson.loads(data)
		obj = obj[</span><span style="color:#008000;background-color:#ffffff;font-weight:bold;">"items"</span><span style="background-color:#ffffff;">]
		self.response.content_type = </span><span style="color:#008000;background-color:#ffffff;font-weight:bold;">"application/json"
</span><span style="background-color:#ffffff;">		simplejson.dump(obj, self.response.out)

</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">def</span><span style="background-color:#ffffff;"> main():
  application = webapp.WSGIApplication([(</span><span style="color:#008000;background-color:#ffffff;font-weight:bold;">'/mirror'</span><span style="background-color:#ffffff;">, MirrorPipesWebService)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

</span><span style="color:#000080;background-color:#ffffff;font-weight:bold;">if</span><span style="background-color:#ffffff;"> __name__ == </span><span style="color:#008000;background-color:#ffffff;font-weight:bold;">"__main__"</span><span style="background-color:#ffffff;">:
  main()</span></pre>
<p>Now you should have a directory structure that looks a lot like this:</p>
<pre>-rw-r--r--@ 1 sam  sam  106 Apr 13 18:55 app.yaml
-rw-r--r--  1 sam  sam  559 Apr 13 19:28 pipes.py
lrwxr-xr-x  1 sam  sam   47 Apr 13 17:40 simplejson -&gt; /Users/sam/Software/simplejson-1.8.1/simplejson</pre>
<p>Now that we have all the pieces we can deploy the application to GAE with a simple command from the GAE SDK:</p>
<pre>appcfg.py update .</pre>
<p>At this point you should be able to replace my <a href="http://javarants.appspot.com/mirror">web service URL</a> that you find in my example Pipe with your application URL which will be
<pre>http://[application name].appspot.com/mirror</pre>
<p> and get the same results as mine.</p>
<p>What kind of uses can you put this great power?  I currently have a web service that I run that combines RSS entries from the same day into a single entry and have it deployed on my own server.  I will likely port that to GAE as it doesn&#8217;t require a lot of CPU and it is a pain having to administer it.  In fact, most of the functionality that you see in a service like <a href="http://feedburner.com">FeedBurner</a> would be easy to build on top of this framework.  More exotic use cases can be found on Y! Pipes itself where at least one person uses web services to pass in <a href="http://pipes.yahoo.com/pipes/pipe.info?_id=qKDcUk1r3BGBg4HtODY80A">photo URLs and return the coordinates of human faces</a> in the images.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JPA 2.0 with Criteria</title>
		<link>http://www.javarants.com/2008/03/15/jpa-20-with-criteria/</link>
		<comments>http://www.javarants.com/2008/03/15/jpa-20-with-criteria/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 01:51:12 +0000</pubDate>
		<dc:creator>sam</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

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

		<category><![CDATA[EJB-QL]]></category>

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

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

		<guid isPermaLink="false">http://www.javarants.com/2008/03/15/jpa-20-with-criteria/</guid>
		<description><![CDATA[(see: JSR 317 Persistently Improving)
I love the idea of adding a criteria API to JPA, the only thing I hope that they do differently than Hibernate is to implement that API in addition to string queries.  In Gauntlet we had issues where we wanted to use EJB-QL for selecting the right data and then a criteria-like [...]]]></description>
			<content:encoded><![CDATA[<p>(see: <a href="http://www.sdtimes.com/content/article.aspx?ArticleID=31655">JSR 317 Persistently Improving</a>)</p>
<p>I love the idea of adding a criteria API to JPA, the only thing I hope that they do differently than Hibernate is to implement that API in addition to string queries.  In Gauntlet we had issues where we wanted to use EJB-QL for selecting the right data and then a criteria-like API for applying security and filtering constraints on the query.  We ended up writing a criteria-like API that augmented the WHERE clause of the query to get the behavior that we needed (like described <a href="http://www.javalobby.org/articles/hibernatequery102/">here</a>).  For example, you could do this:</p>
<pre>
Query q = em.createQuery("SELECT p FROM Project p");
q.addExpression(Expression.notEqual("id", 2));
</pre>
<p>Or something like that. This would give you the best of both worlds, where you have the expressiveness of the textual query and the ability to further hone that query programmatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/03/15/jpa-20-with-criteria/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
