I hereby claim:
- I am dryan on github.
- I am dryan (https://keybase.io/dryan) on keybase.
- I have a public key whose fingerprint is 7E76 E4D1 C6A2 B6FD 8D5E 251E 0B1C D282 DD21 7A08
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
if [ -f 'package.json' ]; | |
then | |
npm install | |
fi | |
if [ -f 'bower.json' ]; | |
then | |
bower install | |
fi | |
if [ -f 'requirements.txt' ]; |
from django.template import Library | |
from django.conf import settings | |
from django.template.defaultfilters import slugify | |
register = Library() | |
def input_class(input): | |
try: | |
slug = slugify(input.field.widget.__class__.__name__.replace('Input','')) | |
if hasattr(input.field.widget, 'attrs') and 'class' in input.field.widget.attrs: |
/* Convert Selection to Entities */ | |
#!/usr/bin/env ruby | |
$KCODE = 'U' | |
$char_to_entity = { } | |
File.open("#{ENV['TM_BUNDLE_SUPPORT']}/entities.txt").read.scan(/^(\d+)\t(.+)$/) do |key, value| | |
$char_to_entity[[key.to_i].pack('U')] = value | |
end | |
def encode (text) | |
text.gsub(/[^\x00-\x7F]|["'<>&]/) do |ch| |
class ErrorHandler(object): | |
def process_response(self, request, response): | |
status = response.status_code | |
if status == 200: | |
return response | |
else: | |
from django.http import HttpResponse | |
from django.template import RequestContext, loader | |
try: | |
t = loader.get_template( u'%d.html' % status ) |
#!/usr/bin/env python | |
# requires optipng library | |
import os,optparse | |
parser = optparse.OptionParser() | |
parser.add_option('--file', '-f', default=False, help="The file to optimize. Omit to optimize all pngs in the current directory.") | |
parser.add_option('--optimization', '-o', default=7, help="The optimatization level to run. Defaults to 7.") | |
options,args = parser.parse_args() |
# for determining current file path in python | |
import os | |
here = lambda x: os.path.join(os.path.abspath(os.path.dirname(__file__)), x) |
# Requires BeautifulSoup | |
class Ampersands(object): | |
from BeautifulSoup import BeautifulSoup | |
import re | |
def process_response( self, request, response ): | |
if response.has_header('Content-Type') and response['Content-Type'].startswith('text/html') and request.META['PATH_INFO'][0:7] != '/admin/': | |
content = BeautifulSoup(response.content) | |
try: | |
for t in content.body.findAll(text = re.compile( r'.*&.*' )): |