Pseudo-Immutable Dictionaries in Python

2013 Jan03
E

very so often a situation arises where you need to keeps some small bits of data around where you know the value, and want to ensure that it won't get fudged with in the lifespan of the application. Say, for example, you want to map some Classes to some known values for quick lookup to dynamically generate some output - [Like a dynamic django form](/2012/05/05/dynamic-django-modelforms/) In other words, you want [ENUMS](http://en.wikipedia.org/wiki/Enumerated_type).

Python doesn't have an implementation for ENUMS, and most of the standard data types are mutable, which doesn't sit well in this situation. Usually, the python swiss army knife - The Dictionary is a one size fits

Read More

Running Django On wsgid with Mongrel2 & ZeroMQ

2012 Jun27
I

love Django and I love Python. However, I also love javascript, Node.js, and I even like playing with Ruby and Ruby on Rails. I love playing around with cool web technology in general. But the the one thing I've always hated was building apache correctly to handle all of these different apps and languages only to have to sit Nginx In front of it. What I really want is a single light weight server that can deal with any application written in any language with out having to build modules, plugins or even recompile the server to get everything to work right. What would be even better is if all of these apps running on a single server

Read More

Pythonic Iterators With Mootools

2012 Jun12
P

ython comes standard with an interesting module called, itertools, which provides a set of functions that make performing complex computations that revolve around iteration much easier. It is actually a invaluable set of tools to have at your disposal when you get comfortable with them. The module itself can work with anything that implements the iterator interface. An iterator is an object wrapper around some sequence that exposes a method called next. When the next method is called, the iterator should return the next item in the sequence and throws a StopIteration exception when there is nothing left in the sequence. While JavaScript doesn't offer anything that would resemble an iterator, that are actually very simple to implement when

Read More

Dynamic Django ModelForms

2012 May05
T

he forms module in Django is pretty amazing and it allows you to do some rather complex things with not a lot of code. Django forms ships with a class called, ModelForm. ModelForm, if you are not familiar, when given a model class, on an instance of a model, will generate a form instance for you complete with validation. You can, of course, specify which fields to exclude from the form and which widgets to use for each field.

Django forms ships with a class called, ModelForm. ModelForms, if you are not familiar, when given a model class, or an instance of a model, will generate a form instance for you complete with validation. You can, of course, specify

Read More
filed under:  python django closure modelform

Base64 Encode Images With Django

2012 Apr13
L

ately, having spent a good deal of time in the mobile web realm, I have increasingly become more of a performance freak. For mobile websites one of the biggest performance killers is doing HTTP requests. It takes a lot of time to setup / tear down the connection. The transfer rates tend to be rather terrible and they chew up battery life. I noticed that images were the biggest culprit of excessive HTTP traffic. Not only from the HTML itself, but CSS background images, which many web developer tend to forget about, can really slow things down. One easy solution around this is to Base64 encode the images and either deliver them in the style sheets or HTML itself.

So

Read More

Handling Large Files With NodeJS and Elastic Search

2012 Apr12
S

o consider myself to be an equal opportunity coder. I like investigating different tools built in different languages to solve different types of problems. Recently at work I had the opportunity to play around with [elasticsearch](http://www.elasticsearch.org). Elasticsearch brings the whole distributed / non relational data craze to the world of search. It is actually a rather impressive piece of tech. If you are at all interested in search as a problem, I recommend you give it a look. In any event, I need to get some data into the search engine to play around with. Where could I get a good deal of data without doing the heavy lifting myself? Twitter! Sure the twitter activity stream.

Read More
filed under:  csv python elasticsearch io json node