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
@defrex
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');
$('body').append(erframe);
$(erframe).css({
'position': 'absolute',
'top': '5%', 'left': '50%',
'width': '90%', 'height': '90%',
'marginLeft': '-45%'
}).attr('id', 'errorframe');
@defrex
defrex / pretty_request.py
Last active Jul 30, 2019
A simple function to print a Django request the way requests are meant to be printed.
View pretty_request.py
def pretty_request(request):
headers = ''
for header, value in request.META.items():
if not header.startswith('HTTP'):
continue
header = '-'.join([h.capitalize() for h in header[5:].lower().split('_')])
headers += '{}: {}\n'.format(header, value)
return (
@defrex
defrex / markup.py
Created Aug 9, 2013
`django.contrib.markup` is deprecated in Django 1.5. Here is a simple replacement for the markdown filter.
View markup.py
import markdown as mkdn
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter()
def markdown(value):
View parseUrl.js
function parseUrl(url) {
var urlParser = document.createElement('a');
urlParser.href = url;
return {
hostname: urlParser.hostname,
pathname: urlParser.pathname,
search: urlParser.search,
hash: urlParser.hash,
port: urlParser.port,
View gist:10008795

Keybase proof

I hereby claim:

  • I am defrex on github.
  • I am defrex (https://keybase.io/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 storages.py
from storages.backends.s3boto import S3BotoStorage
class StaticS3BotoStorage(S3BotoStorage):
location = 'static'
class MediaS3BotoStorage(S3BotoStorage):
location = 'media'
@defrex
defrex / shell.py
Created Sep 30, 2014
Add ptpython support to Django's shell command
View shell.py
from django.core.management.commands.shell 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)
@defrex
defrex / print_request.py
Created Jan 20, 2015
A couple utility functions for pretty printing Django request and response objects
View print_request.py
from __future__ import unicode_literals, print_function
import re
import colorama
header_regex = re.compile('^HTTP_')
def print_header(key, value):
View gifs.json
{
"title": "Spendwell JS Test",
"posts": [
{
"title": "Power",
"gif": "http://i.giphy.com/WmDxBPSHdEBtS.gif"
},
{
"title": "Disgusting",
"text": "http://i.giphy.com/xThuWgQbkshXOAlUHu.gif"
You can’t perform that action at this time.