Skip to content

Instantly share code, notes, and snippets.

View gasman's full-sized avatar

Matt Westcott gasman

View GitHub Profile
@gasman
gasman / gist:0e6b5551104830e51e5f
Last active August 29, 2015 14:13
Re: requirements/base.txt on wagtaildemo

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
gasman / Vagrantfile
Last active August 29, 2015 13:56
Wagtail developer setup in Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# Base box to build off, and download URL for when it doesn't exist on the user's system already
config.vm.box = "wagtail-base-v0.1"
config.vm.box_url = "http://downloads.torchbox.com/wagtail-base-v0.1.box"
# You can also build from a vanilla precise32 box, although it'll take longer
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/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 <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@gasman
gasman / gfm.py
Created March 6, 2011 00:57 — forked from mvasilkov/gfm.py
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0).encode('utf-8')).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
#!/usr/bin/env ruby
# Command line util for acquiring a one-off Twitter OAuth access token
# Based on http://blog.beefyapps.com/2010/01/simple-ruby-oauth-with-twitter/
require 'rubygems'
require 'oauth'
puts <<EOS
Set up your application at https://twitter.com/apps/ (as a 'Client' app),