plaidzooks

Jan 23

[video]

Dec 16

“Sometimes I feel like I’m not… solid. I’m hollow. There’s… nothing behind my eyes. I’m a negative of a person. It’s as if I never— I never thought anything. I never wrote… anything, I never felt anything. All I want is blackness— blackness and silence.” — Sylvia Plath (via wordsthat-speak)

(via wordsthat-speak)

Dec 07

(Source: halloween-addiction, via arcaneimages)

Dec 02

From Shapefile to GeoJSON - Jim Vallandingham

Oct 30

Oct 02

Sep 25

“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)

Aug 29

Unlimited Novelty: Don't use bcrypt

Aug 17

Canadian Business Number Regex

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

'\d{9}R[T|P|C|M|R|D|E|N|G|Z]\d{4}'

Aug 12

[video]

Aug 03

Animal Crossing friend code

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

Come hang! Feel free to message me.

Aug 01

Jul 19

Jun 26

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

###This

Produces HTML like

<h3><p>This</p></h3>

When it ought to be

<h3>This</h3>

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'
            self.link_process(child)

    def run(self, root):
        self.link_process(root)
        return root


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


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