In a old, but still relevant post James Bennet argues for a way of handling the choice tuples used by Django. One of the reasons I haven’t always followed that advice was that it was just a lot of extra mundane keystrokes, and I’m lazy. It was well suited for a quick Python hack, and I now use the script below as a TextMate bundle so that I can just type in a list and have it converted to “the right way”.
Entries Tagged 'Random Observation' ↓
Easy Django choices done right
May 10th, 2010 — Random Observation
Turning a Mac Lab into a disc burning machine
March 12th, 2010 — Random Observation
Have a lab of Macs – need to burn a bunch of CD or DVDs? Harness those monkeys!
Bash completion for diskutil (and others…)
March 12th, 2010 — Random Observation
A few of the tools I use have spent some time working up bash completing. django-admin and virtualenvwrapper to name two. As a Mac sysadmin I use a number of CLI tools for stuff, and was interested in working up some bash completion for these.
Integrating a paper based stage in a digital workflow with Django and QR code
March 8th, 2010 — Random Observation
There are several procedural things at work that still involve a signature, or hand written note on a piece of paper. This reality has made it hard to digitize these practices. While much of the process could be replace with a web app, with plenty of benefits. The reality is that because the paper step is required, the process would become disjointed. One way to reconcile the paper with the digital record, is to scan in the signed document and attach it to the digital record. However this doesn’t pass my “ugh” test in that even with ajax, manually attaching scanned documents to the correct record is still a tedious process. That is where qrcode comes in.
Kevin Nails it
February 15th, 2010 — Random Observation
The Django Advent site is proving to be some great writing. The recent piece by Kevin Fricovsky hits the nail on the head in so many ways.
a little tip on color
February 11th, 2010 — Random Observation
Not much to say other than I’ve been using this for a while and want to pass it on.
This post has a great tool for randomizing terminal colors.
If you have a lot of terminal windows open – this can make expose very handy (I don’t really use tabs).
I have this bound to CMD-Shift-C
Python,Multiprocessing,Hyperthreading, and image resizing
January 13th, 2010 — Random Observation
I have the occasional need to resize a set of images. I used to use Photoshop batch actions, then I used some droplets, and recently I’ve been using a simple python script with PIL (Python Image Library)
We recently got an 8 core Mac Pro, and I wanted to see if I could take more advantage of all those cores when resizing images.
Pretty view of hg diff
November 20th, 2009 — Random Observation
Been using hg, and like to use hg diff to help me make better commit notes – but been spoiled by bitbuckets HTML view of diffs
So here is a quick script that I keep on my path for viewing hg diff, formated with pygments – I’m sure it would be very easy to adopt this to git.
Installing MySQL Python bindings on OS X Leopard server
October 22nd, 2009 — Random Observation
Installing the mysql-python package on Leopard is relatively easy if you’ve installed MySQL from the mysql.org distribution – but installing on Leopard Server is a bit more problematic.
Local editing of remote files
October 15th, 2009 — Random Observation
So found this buried under some dust. I had forgotten that I had ever set this up, but in adding some stuff to a .bash_profile on an older server found some code that I’ve spruced up bit for this post that lets you locally edit a remote file initiated via command in a remote SSH session.
Marking all read in Mail.app
September 14th, 2009 — Random Observation
I’ve always been annoyed that the only way to mark all as read for a mailbox was with a contextual menu in the sidebar – lets change that.
Letting users get to (i)Work
August 13th, 2009 — Random Observation
iLife and iWork can throw up an awful lot of update dialogs and welcome screens for people who first launch them. For users on my network I wanted to prevent those from coming up
Geek distractions
August 7th, 2009 — Random Observation
Tools are getting so sophisticated now – that they can be a distraction for the lightweight or part time coder.
You can get lost in the ins and outs of git vs hg, choosing a database engine (SQL vs Key-Value etc), javascript frameworks, PIP vs Buildout and integrating with virtualenv.
They all have their merit, especially to people who sit in this world all day long, but none of them directly produce work product for you. They are tools – and its best to learn them bit by bit, not all at once, or you will be overwhelmed.
watchedinstall
July 15th, 2009 — Random Observation
[update: project now on bitbucket]
The Problem
There is often the need in a deployment scenario to repackage an installer into some other format. This might be a [radmind][1] transcript, a simple payload only installer package or perhaps just a manifest of what exactly changed on the system.
Apple installer style packages contain simple payloads, but often contain pre or postflight scripts which can make additional and important changes to the filesystem.
There are a couple methods that have been used to try to deduce what exactly was installed:
calling to the shell in python
July 14th, 2009 — Random Observation
This is one of the most frequent utility routines I have in many (most?) of my python scripts. Creating subprocesses in python is very flexble and powerful, but a bit verbose. Sometimes you just want to run a command and set a variable to the output.
from subprocess import Popen, call, STDOUT, PIPE
def sh(cmd):
return Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE).communicate()[0]
You can then just use this as:
sh('ps -x')
