"Does that mean that you’re coding both pc and other devices simultaneously? :)"

— Yup - Windows, Linux, Mac, Phones, Pads and Vitas all running the game in here. If you don’t develop all at once, you can end up with a main version and ports. Not good. (via tonyrevdev)


Canadian Business Number Regex

Just a quick regular expression to match on Canadian Business numbers as specified by the CRA.


Animal Crossing friend code

Code: 2452-6467-2895
Name: Devon
Town: Funkyton

Come hang! Feel free to message me.


Markdown2 vs Markdown

While working on a style-overhaul. I noticed that portions of our views are generated with markdown2, which as it turns out, produces terrible markup.

Markdown like


Produces HTML like


When it ought to be


This is something that the original python markdown module does as it should. The 2 in markdown 2 is a little misleading; the original markdown module is still being actively maintained.

After the switch, it necessary for me to port over our markdown extensions. Namely, we want some blocks of markdown to open their links in a new tab because they will always refer to external resources. Fortunately markdown has a robust extensions API and the end result looked like so:

# -*- coding: utf-8 -*-

""" Text generation and transformation utilities """

import markdown as md
from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor

class NewTabLinksTreeProcessor(Treeprocessor):
    def link_process(self, element):
        """ Traverse the element tree. """
        children = element.getchildren()
        for child in children:
            if child.tag == 'a':
                child.attrib['target'] = '_blank'

    def run(self, root):
        return root

class NewTabLinksExtension(Extension):
    """ Makes links open in a new tab. """
    def extendMarkdown(self, md, md_globals):
                              NewTabLinksTreeProcessor(self), "_end")

def markdown(text):
    """ Return markdown `text` rendered in HTML. """
    return md.markdown(text, [NewTabLinksExtension()])
Tags: cats

Bilingual Money Regex

When entering money into a form, there’s all sorts of potential ways a person could want to format the value, especially when you’re trying to serve a bilingual user base. To match every possible format (I could think of) I came up with the following regular expression:

^(\$?\d{1,3}((,\d{3})*|( \d{3})*|\d*)(\.\d{2})?|\d{1,3}((,\d{3})*|( \d{3})*|\d*)(\.\d{2})?\$)$

This matches:

  • Big long numbers: 99999999
  • Leading and trailing dollar signs: $99, 99$
  • Space delimited numbers: 99 999 999$
  • Comma delimited numbers: $99,999,999
  • Cents: $99.99

This DOES NOT match:

  • Improper use of delimters: $9 99, 999 9 etc.
  • Mixed delimters: $99,999 999
  • Mixed dollar signs: $99$

Drop this regex in your validator and enjoy!



Today at Goodwill, I found this:


(sorry for poor image quality, i only had my cell phone available today)

It is a magnificent Model 500 telephone, with only very minor damage, for a princely 3.99. This was a find, as I’d been wanting one of these for some time. What follows is what I did…

Tags: cats keyboards
Tags: keyboards