This file contains 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
# Packages required to get emacs to compile will all optional stuff. (all yes's on ./configure) | |
sudo apt-get install libjpeg62-dev libtiff4-dev libgif-dev libgtk2.0-dev libxpm-dev libpng12-dev xaw3dg-dev librsvg2-dev libgconf2-dev libgpm-dev libdbus-1-dev libotf-dev libm17n-dev libncurses5-dev |
This file contains 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
class TestActiveField(object): | |
models_to_test = ['Model1', 'Model2', 'foo'] | |
def test_valid_choice(self): | |
for model in self.models_to_test: | |
yield self.check_valid_choice_for_active_field, model | |
def check_valid_choice_for_active_field(self, model): | |
# implement test logic here |
This file contains 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.paths.unshift(__dirname + '/../lib'); | |
var sys = require('sys'); | |
var irc = require('irc'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var bot = new irc.Client('irc.freenode.net', 'iShouldChangeBotName', { | |
channels: ['#node.js'] | |
}); |
This file contains 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
from flask import Module, request, redirect, url_for, render_template, abort | |
from formalchemy import FieldSet | |
from example import db | |
from example import Service, User, Forum, Category, Topic, Post | |
mod = Module(__name__) | |
models = { |
This file contains 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
# from __future__ import with_statement # py2.5 | |
from contextlib import contextmanager | |
import logging | |
@contextmanager | |
def log_execution_time(log_msg): | |
""" | |
Context manager which logs the time spent doing a | |
particular activity. |
This file contains 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
# START_TIME is an instance of datetime.time() | |
datetime.combine(datetime.today(), START_TIME) |
This file contains 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
now = datetime.today() | |
time_list = now.timetuple()[:3] # get year,month,day | |
time_list.extend([START_TIME.hour, START_TIME.minute]) | |
start_datetime = datetime(*time_list) |
This file contains 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
from collections import defaultdict | |
import logging | |
class ErrorDict(defaultdict): | |
""" | |
Stores a list of errors per host, when initialized with a list. | |
>>> ed = ErrorDict() | |
>>> ed['google.com'].append('first') | |
>>> ed['google.com'].append('another error') |
This file contains 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
class TestRound(object): | |
def _check_rounding(self, test, expected): | |
assert round(test) == expected | |
def test_rounding(self): | |
for x, y in [(1, 1), | |
(1.9, 2)]: | |
yield self._check_rounding, x, y | |
# VERSUS |
This file contains 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 python2.6 | |
# | |
# Simple class I used for a little while to play my D&D character when I didn't have dice. Worked okay, but I then found dice. | |
# | |
from collections import defaultdict | |
from random import randint | |
def roll(dice_type): | |
rolls = [] | |
mod = 0 |