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
# refactoring of http://sandrotosi.blogspot.com/2010/03/project-euler-problem-14.html | |
cache = {1: 1} | |
def collatz(n): | |
if n not in cache: | |
if n % 2 == 0: | |
cache[n] = 1 + collatz(n/2) | |
else: | |
cache[n] = 1 + collatz(3*n + 1) |
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
# This is the actual file that combines all of the other snippets | |
# I've been using it for a while, so it's officially Bug Free (TM) | |
# Python startup script. vim: set ft=python : | |
# from http://www.norvig.com/python-iaq.html | |
# also see Tarek Ziade's _Expert_Pythom_Programming_ page 19 | |
import os, sys | |
# Coloured prompt | |
if os.getenv('TERM') in ('xterm', 'vt100', 'rxvt', 'Eterm', 'putty'): |
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
diff collectd-4.10.1.orig/configure.in collectd-4.10.1/configure.in | |
--- collectd-4.10.1.orig/configure.in | |
+++ collectd-4.10.1/configure.in | |
@@ -1626,7 +1626,7 @@ | |
# Check for the iptc_init symbol in the library. | |
if test "x$with_libiptc" = "xyes" && test "x$with_own_libiptc" = "xno" | |
then | |
- AC_CHECK_LIB(iptc, iptc_init, | |
+ AC_CHECK_LIB(ip4tc, iptc_init, | |
[ |
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
[buildout] | |
extensions = buildout-versions | |
versions = versions | |
parts = foo | |
[foo] | |
recipe = zc.recipe.egg:scripts | |
eggs = Pyramid | |
zilch | |
scripts = zilch-web |
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 | |
verbose=0 | |
unknown=0 | |
svn=0 | |
bzr=0 | |
git=0 | |
hg=0 | |
for arg in "$@"; do |
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/python | |
""" | |
Update TCP port assignments page in /var/www/HOSTNAME/ports/index.html. | |
""" | |
import datetime | |
import optparse | |
import os | |
import pwd | |
import socket |
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
[loggers] | |
keys = root, foo | |
[logger_root] | |
handlers = stdout | |
level = DEBUG | |
[logger_foo] | |
qualname = foo | |
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
import sys | |
from PIL import Image | |
tile_size = (1024, 1024) | |
def main(): | |
img = Image.open(sys.argv[1]) | |
tile_w, tile_h = tile_size | |
img_w, img_h = img.size |
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/python | |
"""Print a swatch using all 256 colors of 256-color-capable terminals.""" | |
__author__ = "Marius Gedminas <[email protected]>" | |
__url__ = "https://gist.github.com/mgedmin/2762225" | |
__version__ = '2.0' | |
def hrun(start, width, padding=0): |
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
class CustomValidationErrorMixin(object): | |
"""Schema field with a custom validation error message. | |
Mix this class with your schema fields and specify | |
which exception they should raise by overriding the | |
_validation_exception attribute. | |
""" | |
_validation_exception = ConstraintNotSatisfied |
OlderNewer