Skip to content

Instantly share code, notes, and snippets.

View foxx's full-sized avatar

Cal Leeming foxx

View GitHub Profile
@foxx
foxx / blogsnippets.js
Last active January 15, 2016 13:37
blog
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:
http://stackoverflow.com/a/10018792/1267398
@foxx
foxx / sanity.py
Created December 4, 2015 21:59
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...")
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.
<!-- BEM EXAMPLE -->
<style>
.btn { display: block; color: red; }
.btn--orange { color: orange; }
</style>
<div class="btn btn--orange"></div>
<!-- NON-BEM EXAMPLE -->
<style>
(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
foxx / gist:17a951750d4d7264b983
Created January 27, 2015 11:01
The Conscience of a Hacker
==Phrack Inc.==
Volume One, Issue 7, Phile 3 of 10
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following was written shortly after my arrest...
\/\The Conscience of a Hacker/\/
by
@foxx
foxx / gist:77856da964cc986ab3ee
Last active August 29, 2015 14:12
keybase.md
### Keybase proof
I hereby claim:
* I am foxx on github.
* I am sleepycal (https://keybase.io/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
foxx / jquery.togglr.js
Created December 1, 2014 19:27
Element toggle for jQuery
(function (factory) {
// loader from https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
@foxx
foxx / gist:1968fe19f759e608452a
Created November 27, 2014 00:10
Django partial forms mixin (alpha as fuck)
class FormFieldQuerySetMixin(object):
"""
Adds support for changing RelatedField queryset
easily without having to patch __init__.
def get_FIELDNAME_queryset(self):
pass
"""