phil wade dot org
I'm Phil Wade, a developer who works on the web and on android. This is a blog about me and my life.

Interflix is my first android app. It's a netflix que manager currently in development.

If you'd like to get in touch with me, fire an email to phil (at) philwade (dot) org

I also occasionally post on twitter if you're into that sort of thing. I'm @phil_wade

My girlfriend and I write about the things we cook: Us Versus Dinner

Subscribe to RSS

Interflix
by phil | Dec 9, 2010 - 07 p.m.


Oh hello,
Just thought I'd stop in and say I've just released Interflix, a Netflix que management app for android phones. Here is the appbrain widget if you'd like to get it: If you'd just like to read a bit more about it, there is a link to the informational wiki page in the sidebar. As a side note, I've added the sidebar (over there on the left), and changed the styles around a little bit to be not quite so dark. I think I like it. 0 comments
Ghost in the shell
by phil | Nov 11, 2010 - 12 p.m.


I recently needed to create eight Symfony templates for something at work. Quick breakdown: every page in Symfony is a combination of an action and a template. You create a function and follow a naming convention to create the corresponding template. So, the action "public function executeFoobar()" renders with the template "foorbarSuccess.php". It's a bit more complicated than that, but that's all you really need to know at the moment.

I had written this set of eight actions, and wanted to create all the templates. Normally, I just create the files by hand, but that's boring. The correct answer? Shell script.
[web@dnysnweb05:~/htdocs_symfony/symfony/apps/content/modules/minisites]$ grep Pretty ../actions/actions.class.php  | awk '{ print $3 }' | sed s/\(.*\/Success\.php/g | sed s/execute//g | sed s/P/p/ | awk '{ system("touch " $1) }'

Instead of writing "touch blahfile.php" eight times, I wrote the above. It probably took three times as long, but it was a hundred times as much fun, and if I had needed to create a thousand templates, it would have saved me a lot of time. The moral of the story is keep sharp in the shell. It might come in handy. 0 comments
What's new
by phil | Dec 23, 2009 - 12 p.m.


Its been a while since I wrote an update here, and this is because its been a while since I've spent much of my leisure time hacking on anything particularly interesting. I've had some fairly interesting problems to play with at work, and the thing is, I really only have so much coding in me every day. When that isn't being used up with work related stuff, I find myself itching to spend my leisure time cranking stuff out. Lately that hasn't been the case. I know that it's in my best interest to spend time coding and writing about coding outside of work, but my personal resolve to do that tends to vary in the extreme. A graph of my posting frequency looks like a sine wave with a rapid interval.

What have I been up to? Pretzels. If you've got the ingredients, give it a shot. They're real awesome, and it's very satisfying to see them come out of the oven. If there are too many, freeze those suckers. I'm still experimenting with how to thaw them, but 300 degrees for about 7 minutes seems to be the sweet spot. 0 comments
Using pygments for syntax highlighting
by phil | Oct 18, 2009 - 02 p.m.


In a previous post I talked a bit about trying to get syntax highlighting working properly in blog posts. I said something or other about it being more difficult than all the implementations available would imply, but it turns out its (as suspected) just as simple as I thought it might be. The real issue was that it didn't work the way I wanted it to. So I slapped together two other implementations with features I liked. I've lost the links to those (sorry anonymous other programmers).

My version requires Beautiful Soup and Pygments and combines two features that I liked in other versions - automatically including the relevant stylesheets (cause I don't want to write my own) and understanding the code language based on the class of the page element (because using the lexer to automatically figure out the code is a crappy method).

Anywho, here is the code:
from django import template
from BeautifulSoup import BeautifulSoup
import pygments
import pygments.lexers as lexers
import pygments.formatters as formatters

register = template.Library()

@register.filter(name='pygmentize')
def pygmentize(value):
    try:
        formatter = formatters.HtmlFormatter(style='trac')
        tree = BeautifulSoup(value)
        for code in tree.findAll('code'):
            if not code['class']: code['class'] = 'text'
            lexer = lexers.get_lexer_by_name(code['class'])
            new_content = pygments.highlight(code.decodeContents(), lexer, formatter)
            new_content += u"%s" % formatter.get_style_defs('.highlight')
            code.replaceWith ( "%s\n" % new_content )
        content = str(tree)
        return content
    except KeyError:
      return value


Used like so in a template:
{{ value|pygmentize }}
If you need some instructions for putting that in place, the django book has some pointers

Anywho, back to trying to solve the rubik's cube. 0 comments
dirty little database secret
by phil | Oct 1, 2009 - 09 p.m.


Recently I tweeted about one of my blog posts, and surprisingly saw a mini spike in traffic - when traffic is almost zero, any traffic is a spike. Regardless, when slapping together this blog, in many places I took the path of least resistance. With regards to database, that path was sqlite. I knew full well that it couldn't hold up against any real sort of traffic, but the idea of creating a database and users and yada yada yaaa was just not something that looked like a lot of fun at the time. So I've been running the site on sqlite.
Now back to that traffic spike - it got me thinking about using sqlite. Maybe not so much thinking as worrying. Nobody wants concurrency issues. Nobody really wants to switch database engines either. Both are unpleasant, but only one affords the opportunity to learn PostgreSQL. I could have gone with MySQL, which I have installed and know, but I've been on a bit of a learning kick (this site is the product of that).

I installed the macports Postgres on my mac to teach myself how to port the data from sqlite. Installing it that way was super easy. The hard parts were installing the python database library and actually using Django's manage.py to dump and reinstate the data. I won't go into my particular difficulties (unless somebody asks) but lets just say manage.py makes it much easier than it would be otherwise, but it still could go a ways towards making it easier. After all, I'm no DBA :) I think I may continue to use sqlite in dev, but I'm glad I got through the switch.
Overall, I've got a little Postgres experience now and I don't have to lay awake thinking about my database concurrency issues. 0 comments