Skip to content

Instantly share code, notes, and snippets.


Matt Westcott gasman

View GitHub Profile
View twitter_oauth_setup.rb
#!/usr/bin/env ruby
# Command line util for acquiring a one-off Twitter OAuth access token
# Based on
require 'rubygems'
require 'oauth'
puts <<EOS
Set up your application at (as a 'Client' app),
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5('utf-8')).hexdigest()
extractions[digest] =
return "{gfm-extraction-%s}" % digest
gasman / pnginator.rb
Created Apr 30, 2012
pnginator: pack Javascript into a self-extracting PNG
View pnginator.rb
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <>
# from an original idea by Daeken:
gasman / Vagrantfile
Last active Aug 29, 2015
Wagtail developer setup in Vagrant
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby : do |config|
# Base box to build off, and download URL for when it doesn't exist on the user's system already = "wagtail-base-v0.1"
config.vm.box_url = ""
# You can also build from a vanilla precise32 box, although it'll take longer
gasman / gist:0e6b5551104830e51e5f
Last active Aug 29, 2015
Re: requirements/base.txt on wagtaildemo
View gist:0e6b5551104830e51e5f

On 17 Jul 2014, at 11:41, Matthew Westcott wrote:

So, as a compromise, how about we keep the packages in there, but use a '>=' rule so that they pick up the latest version? The downside is that new versions can be released at any time, and we can no longer guarantee that local and live installations of a site are running the same version - which is bad news if the packages introduce breaking changes (hellooo elasticsearch!). But then again, that already happens to some extent (e.g. packages that define their own dependencies using >=) and it doesn't seem to have been a problem up to now.

Having pondered the '>=' versus '==' conundrum some more, I'm starting to think that the "best practice" for requirements files as codified by the Two Scoops book has some room for improvement. The root of the problem is that the requirements file has two conflicting purposes:

  1. a description of the range of package versions that our app is able to work with, presented as a list of constraints which pip has to solve: e.
gasman / pt3_player.asm
Created Jan 14, 2015
Vortex Tracker II PT3 playback routine
View pt3_player.asm
; Vortex Tracker II PT3 playback routine - written by Sergey Bulba
; usage:
; ld hl,address_of_pt3_data
; call pt3_init
; then every 1/50 second:
; call play
; to silence:
; call mute
View gist:8e7eb18686af0af966ef
import six
class ModelBase(type):
def __new__(meta, name, bases, dct):
print("ModelBase.__new__(%s)" % name)
result = super(ModelBase, meta).__new__(meta, name, bases, dct)
print("/ModelBase.__new__(%s)" % name)
return result
def __init__(cls, name, bases, dct):

Keybase proof

I hereby claim:

  • I am gasman on github.
  • I am mattwestcott ( on keybase.
  • I have a public key whose fingerprint is 4D33 A325 2D66 7384 42E7 FF9E 1A92 6186 FECD 38FE

To claim this, I am signing this object:

from __future__ import unicode_literals
from django.db import models
from wagtail.wagtailcore.blocks import StructBlock, CharBlock, URLBlock, StreamBlock
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import StreamField, RichTextField
from wagtail.wagtailimages.blocks import ImageChooserBlock
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, \
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible
from modelcluster.models import ClusterableModel
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Orderable
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel