This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding a semi-dynamic field to Django ModelAdmin | |
# | |
# Motivation behind this is to see if django.conf.settings contains a | |
# setting of some type. I know this could be done with a factory too. | |
# | |
# django.forms.Form allows adding extra fields to forms initialization | |
# time by modifying self.fields dict in __init__. However, ModelAdmin | |
# only looks at the *class* of the form, not the instance created from | |
# it, to determine the fields it should draw in the admin interface. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
( foo="bar"; echo "Within first shell (pid: $BASHPID): \$foo=$foo" ) | |
( unset foo; echo "Within second shell (pid $BASHPID): \$foo=$foo" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deaccent unicode strings. | |
# | |
# unicodedata.normalize('NFKD', unicodestring): do a compatibility | |
# decomposition of the unicode string | |
# | |
# unicodedata.category(somecharacter): Find the unicode category | |
# for a character. Category 'Mn' contains all combining accents | |
import unicodedata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import errno | |
import socket | |
import select | |
class EventLoop(object): | |
def __init__(self): | |
self.callbacks = [] | |
self.sources = [] | |
self.handlers = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[couchdb] | |
database_dir = tmp/couch | |
view_index_dir = tmp/couch | |
[httpd] | |
port = 8922 | |
bind_address = 127.0.0.1 | |
[log] | |
file = tmp/couch.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sass' | |
module Sass::Script::Functions | |
def inline_image(image, type) | |
path = image.value | |
image_data = [data(path)].flatten.pack('m').gsub('\n', '') | |
declaration = "url('data:#{type};base64,#{image_data}')" | |
Sass::Script::String.new(declaration) | |
end | |
declare :inline_image, :args => [:string, :string] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Bieberizing. Please wait..." | |
git reset --soft `git log --pretty=oneline | tail -n 1 | awk '{ print $1 }'`; git commit --amend -m "Implemented the software as specified." --author="Justin Bieber <[email protected]>" | |
echo "Done & Done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable tab completion | |
import rlcompleter | |
import pdb | |
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete | |
# Sometimes when you do something funky, you may lose your terminal echo. This | |
# should restore it when spanwning new pdb. | |
import termios, sys | |
termios_fd = sys.stdin.fileno() | |
termios_echo = termios.tcgetattr(termios_fd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import time | |
from tornado.ioloop import IOLoop | |
def printer(digit): | |
def _do_print(): | |
print digit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun single-window-mode () | |
(interactive) | |
(delete-other-windows) | |
(set-frame-size (selected-frame) 80 65)) | |
(defun double-window-mode () | |
(interactive) | |
(delete-other-windows) | |
(set-frame-size (selected-frame) 163 65) | |
(split-window (selected-window) 83 t)) |