Skip to content

Instantly share code, notes, and snippets.


Cal Leeming foxx

View GitHub Profile
View blogsnippets.js
for k in ['host', 'port', 'database', 'user', 'password']:
if k in dbconfig:
if type(dbconfig[k]) in (str, unicode):
match = pat.match(dbconfig[k])
if match and match.groups():
envvar = match.groups()[0]
if envvar in os.environ:
dbconfig[k] = os.environ[envvar]
if k != 'password':
def extend_instance(instance, *bases, **kwargs):
Apply subclass (mixin) to a class object or its instance
By default, the mixin is placed at the start of bases
to ensure its called first as per MRO. If you wish to
have it injected last, which is useful for monkeypatching,
then you can specify 'last=True'. See here:
foxx /
Created Dec 4, 2015
Coderpad pytest support
import os
import sys
import subprocess
def sanitypatch():
Quick hack to install any package we want in coderpad...
Because real coders use pytest, amirite?
print("applying coderpad sanity patch...")
View stop.txt
Dear Zendesk,
On behalf of the internet, and for the greater good of mankind, this is a request to
politely ask you to change the default theme of your support emails.
Currently every support email notification, for the majority of your customers,
includes a complete dump of the entire conversation. And due to the way you
have constructed the HTML in your email, most email clients fail to realise
it is duplicated text and do not remove it.
View example1.html
<!-- BEM EXAMPLE -->
.btn { display: block; color: red; }
.btn--orange { color: orange; }
<div class="btn btn--orange"></div>
View parseDesignDocs.js
(function() {
var fs = require('fs');
var path = require('path');
var current_dir = path.dirname(fs.realpathSync(__filename));
var design_docs_dir = path.join(current_dir, 'design_docs');
var files = fs.readdirSync(design_docs_dir);
var json = {};
files.forEach(function(fpath) {
foxx / gist:17a951750d4d7264b983
Created Jan 27, 2015
The Conscience of a Hacker
View gist:17a951750d4d7264b983
==Phrack Inc.==
Volume One, Issue 7, Phile 3 of 10
The following was written shortly after my arrest...
\/\The Conscience of a Hacker/\/
View gist:77856da964cc986ab3ee
### Keybase proof
I hereby claim:
* I am foxx on github.
* I am sleepycal ( on keybase.
* I have a public key whose fingerprint is 3352 5EE5 1000 1772 5033 7A4D BA90 2A3F 2D9B E20B
To claim this, I am signing this object:
foxx / jquery.togglr.js
Created Dec 1, 2014
Element toggle for jQuery
View jquery.togglr.js
(function (factory) {
// loader from
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
}(function ($) {
foxx / gist:1968fe19f759e608452a
Created Nov 27, 2014
Django partial forms mixin (alpha as fuck)
View gist:1968fe19f759e608452a
class FormFieldQuerySetMixin(object):
Adds support for changing RelatedField queryset
easily without having to patch __init__.
def get_FIELDNAME_queryset(self):