Balancing innovation against deadlines because work and life have hard deadlines…..

2Apr/110

Using python-dulwich to load any version of a file from a local git repo

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 repo given the path and tree hash.

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.

Here is the short answer:

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)

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.

2Jan/112

OSX vs Ubuntu, Windows wins?

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.

I picked up a 4lb HP DM4 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.

Developing was a joy and eclipse opened nearly instantly.

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.

Around this time I picked up a python update on OSX and spent about 4 hours trying to get mysql and python to talk to each other.  I booted into windows and thought about how to use this platform as a development machine.

Enter BitNami. 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.

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.

1May/080

SpringSource – proving once again Java doesn’t get the web

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 style of Spring is really compelling.

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.

http://www.springsource.com/web/guest/home

what is with the /web/guest/home for the homepage?  That is really bad SEO mojo

The idea of bundles that you can drop in for added functionality is fantastic, but you hit an ugly query string laden url like:

http://www.springsource.com/repository/app/library/version/detail?name=org.apache.myfaces&version=1.2.2

as opposed to the far more buzzword complient library of plugins for something like django:

http://djangoplugables.com/projects/django-compress/

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.

And compare the old school search page of:

http://www.springsource.com/repository/app/search

to the happiness of a large input box with realtime results on:

http://djangoplugables.com/repositories/

At least this is better then the time I read the Jython website and was greeted by a 'blink' tag

Tagged as: , No Comments
22Apr/080

Rest as a boring servlet

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 handle rest and didn't invent a new paradigm.

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.

The beauty of REST is its simplicity, yet there is so much energy being expended to 'simplify' it.

The real magic is to standardize on sending XML or JSON rather then url encoded data of an http form POST.

Tagged as: , No Comments