Skip to content

Instantly share code, notes, and snippets.

Aron Jones defrex

Block or report user

Report or block defrex

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gifs.json
"title": "Spendwell JS Test",
"posts": [
"title": "Power",
"gif": ""
"title": "Disgusting",
"text": ""
defrex /
Created Jan 20, 2015
A couple utility functions for pretty printing Django request and response objects
from __future__ import unicode_literals, print_function
import re
import colorama
header_regex = re.compile('^HTTP_')
def print_header(key, value):
defrex /
Created Sep 30, 2014
Add ptpython support to Django's shell command
from import Command as ShellCommand
class Command(ShellCommand):
shells = ['ptpython', 'ipython', 'bpython']
def ptpython(self):
from prompt_toolkit.contrib.repl import embed
embed(globals(), locals(), vi_mode=False, history_filename=None)
from storages.backends.s3boto import S3BotoStorage
class StaticS3BotoStorage(S3BotoStorage):
location = 'static'
class MediaS3BotoStorage(S3BotoStorage):
location = 'media'
View gist:10008795

Keybase proof

I hereby claim:

  • I am defrex on github.
  • I am defrex ( on keybase.
  • I have a public key whose fingerprint is 1486 B752 395C B552 C0DF 8604 D2BB 926C 932E D7E4

To claim this, I am signing this object:

View parseUrl.js
function parseUrl(url) {
var urlParser = document.createElement('a');
urlParser.href = url;
return {
hostname: urlParser.hostname,
pathname: urlParser.pathname,
hash: urlParser.hash,
port: urlParser.port,
defrex /
Created Aug 9, 2013
`django.contrib.markup` is deprecated in Django 1.5. Here is a simple replacement for the markdown filter.
import markdown as mkdn
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
def markdown(value):
defrex /
Last active Dec 23, 2019
A simple function to print a Django request the way requests are meant to be printed.
def pretty_request(request):
headers = ''
for header, value in request.META.items():
if not header.startswith('HTTP'):
header = '-'.join([h.capitalize() for h in header[5:].lower().split('_')])
headers += '{}: {}\n'.format(header, value)
return (
defrex / jquery.500frame.js
Created Apr 11, 2011
pop-up any 500s in an iframe using jQuery. Especially useful for Django errors.
View jquery.500frame.js
$(document).bind('ajaxError', function(e, jqXHR){
if (jqXHR.status == 500){
var erframe = document.createElement('iframe');
'position': 'absolute',
'top': '5%', 'left': '50%',
'width': '90%', 'height': '90%',
'marginLeft': '-45%'
}).attr('id', 'errorframe');
You can’t perform that action at this time.