<?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>Balancing innovation against deadlines &#187; python</title>
	<atom:link href="http://www.aaronheld.com/post/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://www.aaronheld.com</link>
	<description>because work and life have hard deadlines.....</description>
	<lastBuildDate>Wed, 02 Nov 2011 19:25:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using python-dulwich to load any version of a file from a local git repo</title>
		<link>http://www.aaronheld.com/post/using-python-dulwich-to-load-any-version-of-a-file-from-a-local-git-repo</link>
		<comments>http://www.aaronheld.com/post/using-python-dulwich-to-load-any-version-of-a-file-from-a-local-git-repo#comments</comments>
		<pubDate>Sat, 02 Apr 2011 19:49:29 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Professional]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[labweek2011]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=305</guid>
		<description><![CDATA[On Monday we are kicking off an innovation week (more to come on that topic) and I've devised a little project that includes nearly every buzzword I'm interested in. I'm spending some time doing some technical spikes to see what is possible and I found a need to load a particular file from a git [...]]]></description>
			<content:encoded><![CDATA[<p>On Monday we are kicking off an innovation week (more to come on that topic) and I've devised a little project that includes nearly every buzzword I'm interested in.</p>
<p>I'm spending some time doing some technical spikes to see what is possible and I found a need to load a particular file from a git repo given the path and tree hash.</p>
<p>I grabbed my trusty python, dulwich (native python-git library) and gave it a shot. After a few minutes writing complicated looking recursive code I jumped over to irc where the friendly author pointed me to a convenience function that does what I needed.</p>
<p>Here is the short answer:</p>
<pre>from dulwich.repo import Repo
from dulwich.object_store import tree_lookup_path

r = Repo('/Documents/projects/gitdep/rails')
def get_file(tree, path):
    (mode,sha) = tree_lookup_path(r.get_object,tree,path)
    return r[sha].data

tree = '7e7331fce169bbe1d6be71a30c1e1f7ab2e6ceba'
path = 'activemodel/examples/validations.rb'

print get_file(tree,path)</pre>
<p>This gives me a rails validation file from last year.  Nothing special about this file, I just find the rails git repo an interesting playground for git experimentation. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/using-python-dulwich-to-load-any-version-of-a-file-from-a-local-git-repo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSX vs Ubuntu, Windows wins?</title>
		<link>http://www.aaronheld.com/post/osx-vs-ubuntu-windows-wins</link>
		<comments>http://www.aaronheld.com/post/osx-vs-ubuntu-windows-wins#comments</comments>
		<pubDate>Sun, 02 Jan 2011 16:23:50 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[windows7]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=299</guid>
		<description><![CDATA[Ever since Barcamp I've been shopping for a personal laptop for general use as well as a development machine that I could use for work.  Our work issued machine is a loaded mac powerbook.  With a unix core osx has given me much of the power that I used to enjoy when I'd used linux [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since Barcamp I've been shopping for a personal laptop for general use as well as a development machine that I could use for work.  Our work issued machine is a loaded mac powerbook.  With a unix core osx has given me much of the power that I used to enjoy when I'd used linux as a primary os. However Apple is not doing wonders for free software and I felt the need to get back to my roots and move back to Linux.</p>
<p>I picked up a 4lb HP <a href="http://www.shopping.hp.com/webapp/shopping/computer_can_series.do?storeName=computer_store&amp;category=notebooks&amp;a1=Category&amp;v1=Ultra-Portable&amp;series_name=dm4t_series&amp;jumpid=in_R329_prodexp/hhoslp/psg/notebooks/Ultra-Portable/dm4t_series" target="_blank">DM4</a> and dual booted to Ubuntu with not issues.  The trackpad didn't work right, but a script off someones blog made it work reasonably ok.  A quick hop into debug mode showed that the drivers returned negative x-y coordinates when you use 2 fingers.  I downloaded the open source drivers to take a look at the code and saw that a patch was already in head.</p>
<p>Developing was a joy and eclipse opened nearly instantly.</p>
<p>Microsoft silverlight DRM is not (yet?) ported to linux so I dual boot to windows 7 to get the customer experience and use CIM products.  A funny thing happened to me while getting the 'customer' experience.   I liked it!   Windows 7 is much more usable then either osx or Linux and IE9 looks like it will be a really powerful platform for future development.</p>
<p>Around this time I picked up a python update on OSX and spent about 4 hours trying to get mysql and python to<a href="http://www.google.com/search?q=mysql+python+osx" target="_blank"> talk to each other</a>.  I booted into windows and thought about how to use this platform as a development machine.</p>
<p>Enter <a href="http://bitnami.org/" target="_blank">BitNami</a>. Rather then deal with version conflicts I grabbed a virtual machine that is close to my target server and installed VMware Player.  Mapping a windows directory to the virtual machine lets me edit files in native windows while running my build chain on Linux.  The browser I use for development is finally the same browser used by the majority of my customers and my dev environment is much closer to my server environment as well.</p>
<p>For not I'm working through the rough edges of this setup and trying to find a decent windows SSH client but this setup seems to have legs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/osx-vs-ubuntu-windows-wins/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SpringSource &#8211; proving once again Java doesn&#8217;t get the web</title>
		<link>http://www.aaronheld.com/post/springsource-proving-once-again-java-doesnt-get-the-web</link>
		<comments>http://www.aaronheld.com/post/springsource-proving-once-again-java-doesnt-get-the-web#comments</comments>
		<pubDate>Thu, 01 May 2008 22:49:11 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=10</guid>
		<description><![CDATA[I just read an article in a java trade mag entitled: SpringSource CEO: "The Future of Enterprise Java is Clear and Bright" The premise sounds positive.  Basically they took OSGI, Spring and threw it on Tomcat as a web server.  The idea of being able to deploy OSGI bundles with the bag of beans development [...]]]></description>
			<content:encoded><![CDATA[<p>I just read an article in a java trade mag entitled: <a title="Syscon on Java" href="http://java.sys-con.com/read/557307.htm">SpringSource CEO: "The Future of Enterprise Java is Clear and Bright"</a></p>
<p>The premise sounds positive.  Basically they took OSGI, Spring and threw it on Tomcat as a web server.  The idea of being able to deploy OSGI bundles with the bag of beans development style of Spring is really compelling.</p>
<p>What this negative post is about is how they still don't get the 'web'.  My biggest issue with Java web development is that not enough attention is paid to modern web basics.  The very first thing that I noticed on the SpringSource website was the 15 year old style url.</p>
<p>http://www.springsource.com/web/guest/home</p>
<p>what is with the /web/guest/home for the homepage?  That is really bad SEO mojo</p>
<p>The idea of bundles that you can drop in for added functionality is fantastic, but you hit an ugly query string laden url like:</p>
<p>http://www.springsource.com/repository/app/library/version/detail?name=org.apache.myfaces&#038;version=1.2.2</p>
<p>as opposed to the far more buzzword complient library of plugins for something like django:</p>
<p>http://djangoplugables.com/projects/django-compress/</p>
<p>While the Java page shows you the really easy lines of Maven xml to paste into your pom, the python based django system talks about the usefulness of the actual bundle you are looking at.</p>
<p>And compare the old school search page of:</p>
<p>http://www.springsource.com/repository/app/search</p>
<p>to the happiness of a large input box with realtime results on:</p>
<p>http://djangoplugables.com/repositories/</p>
<p>At least this is better then the time I read the Jython website and was greeted by a 'blink' tag</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/springsource-proving-once-again-java-doesnt-get-the-web/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rest as a boring servlet</title>
		<link>http://www.aaronheld.com/post/rest-as-a-boring-servlet</link>
		<comments>http://www.aaronheld.com/post/rest-as-a-boring-servlet#comments</comments>
		<pubDate>Tue, 22 Apr 2008 14:32:36 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=8</guid>
		<description><![CDATA[A coworker whipped up a generic REST interface for any Ruby on Rails activerecord (data model).  What he described (in 5 minutes) was a nice implementation.  I wanted see how the generic django REST interface was coded. http://code.google.com/p/django-rest-interface/ I was pleasantly surprised to realize that they Python developers simply used the normal form processing to [...]]]></description>
			<content:encoded><![CDATA[<p>A coworker whipped up a generic REST interface for any Ruby on Rails activerecord (data model).  What he described (in 5 minutes) was a nice implementation.  I wanted see how the generic django REST interface was coded.</p>
<p><a href="http://code.google.com/p/django-rest-interface/">http://code.google.com/p/django-rest-interface/</a></p>
<p>I was pleasantly surprised to realize that they Python developers simply used the normal form processing to handle rest and didn't invent a new paradigm.</p>
<p>On an early project we tried to implement RESTlet for a java based REST application.  Under load we saw some strange problems and the code was reverted to normal servlets without too much pain.</p>
<p>The beauty of REST is its simplicity, yet there is so much energy being expended to 'simplify' it.</p>
<p>The real magic is to standardize on sending XML or JSON rather then url encoded data of an http form POST.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/rest-as-a-boring-servlet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motocycles and Python turn toil into joy</title>
		<link>http://www.aaronheld.com/post/motocycles-and-python-turn-toil-into-joy</link>
		<comments>http://www.aaronheld.com/post/motocycles-and-python-turn-toil-into-joy#comments</comments>
		<pubDate>Sat, 19 Apr 2008 17:40:51 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[motorcycle]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=7</guid>
		<description><![CDATA[So today started out great. Temperatures in the 80's, so I took the kiddies outside. I put my cellphone on the trunk of my sisters's car, put the kids on their bikes, put skates on my feet and rolled out to enjoy the day. Things were going well with my littlest one making turns at [...]]]></description>
			<content:encoded><![CDATA[<p>So today started out great.</p>
<p>Temperatures in the 80's, so I took the kiddies outside.   I put my cellphone on the trunk of my sisters's car, put the kids on their bikes, put skates on my feet and rolled out to enjoy the day.</p>
<p>Things were going well with my littlest one making turns at each end of the block. My sister pulled up and shouted some encouragement as she drove past.  I waved and noticed my black cell phone on the white trunk of her car!</p>
<p>I started to skate hard, but I couldn't leave my girl in the street.  I shuffled the girls back into the house and summoned the boy to watch them and tore off after my sister.  I searched all the likely routes she would have taken but could not find it.</p>
<p>I called her and found out where she went and was determined to look again.</p>
<p>At this point I was pretty upset about this and feeling down.</p>
<p>So I got on my motorcycle and started looking for it.  I rode a block at a time and dismounted to look.  After about 15 minutes I realized it was looking pretty grim.  I also realized I was out on my bike on a beautiful day, and any day you ride simply isn't that bad.</p>
<p>I had a similar occurrence with python the other day.  I had to scrape some data out of a nasty, IE only, webapp.  It was pretty ugly but I got into writing the app as a pyunit test case and using assertions to ensure I got all the data.  The difficult nature of the data coming in made me appreciate just how much you can do with test cases.  The scraping task was about as pleasurable as looking for my cellphone across town.</p>
<p>But at least I got to do it in python and enjoy the ride!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/motocycles-and-python-turn-toil-into-joy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>csv to xml via python</title>
		<link>http://www.aaronheld.com/post/cvs-to-xml-python</link>
		<comments>http://www.aaronheld.com/post/cvs-to-xml-python#comments</comments>
		<pubDate>Tue, 15 Apr 2008 01:19:51 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.aaronheld.com/?p=6</guid>
		<description><![CDATA[Today at work our main Flash developer asked me about expanding his skills and learning either Ruby or Python. My personal preference is towards python but ruby has its place. Flash is really doing well in the Java/Enterprise space lately so I went that way. Most of the Flash backend in our work is xml [...]]]></description>
			<content:encoded><![CDATA[<p>Today at work our <a href="http://arpitonline.com">main Flash developer</a> asked me about expanding his skills and learning either Ruby or Python. My personal preference is towards python but ruby has its place.  Flash is really doing well in the Java/Enterprise space lately so I went that way.</p>
<p>Most of the Flash backend in our work is xml based so XML was on my mind anyway.  Recently we needed to mock up a xml data data file for a project while the real APIs are being completed. We had the data in a csv file so we asked some developers to whip up a xml file.</p>
<p>As I started writing up the ticket I started thinking it would be easier to just do it myself.</p>
<p>Given the speed of python development I was right!.</p>
<pre style="font-size:8pt">#!/usr/bin/env python
"""
cvs2xml.py

Created by Aaron Held on 2008-04-11.
Make the xml from the csv using dom and other three letter acronyms
"""import sys,os
import unittes
import csv

from pprint import pprint
import xml.etree.ElementTree as ET

class Cvs2xml:
    def loadCSV(self):
        """Load the data and return a list of maps"""
reader = csv.DictReader(open(r"input.csv",'r'))
        rows = []
for row in reader:
            rows.append(row)
return rows

def mappings(self):
        """
        Map csv file to xml field names
        """
mapping = { 'id':"store_number"
        return mapping

def createXML(self,listofrows):
"""Turn lists into xml
"""
root = ET.Element("stores")
for row in listofrows:
store = ET.SubElement(root, "store")
for xml_field in row.keys():
csv_field = self.mappings().get(xml_field,xml_field)
ET.SubElement(store, xml_field).text = row.get(csv_field,"")
print(ET.tostring(root))
#tree = ET.ElementTree(root)
#tree.write("output.xml")

class Cvs2xmlTests(unittest.TestCase):
def setUp(self):
pass

def testRun(self):
'''Lazy way of main()'''
cvs2xml = Cvs2xml()
rows = cvs2xml.loadCSV()
cvs2xml.createXML(rows)

if __name__ == '__main__':
unittest.main()</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.aaronheld.com/post/cvs-to-xml-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

