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
def foo(a, b=None, cache={}): | |
if b is not None: | |
cache[a] = b | |
return b | |
if a in cache: | |
return cache[a] | |
raise KeyError('Bleh, no %s' % a) |
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/local/bin/python2.7 | |
from __future__ import print_function | |
import os | |
import threading | |
import time | |
startup_lock = threading.Lock() | |
COUNTER = None |
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
>>> def foo(alpha, *args, **kwargs): | |
... print 'Foo called, alpha = %s' % repr(alpha) | |
... for a in args: | |
... print 'Arg: {%s}' % repr(a) | |
... for k, v in kwargs.iteritems(): | |
... print 'Arg \"%s\" = \"%s\"' % (k, v) | |
... | |
>>> foo(234234, 'snert', 'wibble', 'bleurgh', fred=42, barney=-1) | |
Foo called, alpha = 234234 | |
Arg: {'snert'} |
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
package main | |
import ( | |
"container/list" | |
"flag" | |
"fmt" | |
"os" | |
"sync" | |
"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
#!/usr/bin/env perl | |
# | |
# For a file containing PEM objects or PGP objects or whatever, emit the file | |
# filtering the objects through a command-line which takes the object on stdin. | |
# | |
# foreach-beginend bundle.crt openssl x509 -noout -text | |
# The filename may be specified as '-' to act as a filter reading from stdin. | |
# | |
use strict; |
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
// this is C99 | |
// compile: gcc -std=c99 -ggdb -O3 -Wall guarded_memory_alloc_test.c | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <stdarg.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
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 python3.2 | |
""" | |
polygon: moo.com polygon puzzle solver | |
moo.com business cards might have a polygon puzzler on a promotional card in | |
the pack. This tool finds the words. | |
""" | |
__author__ = '[email protected] (Phil Pennock)' |
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
#!/bin/sh | |
SUBDIRECTORY_OK=true | |
[ -d /opt/local/bin ] && PATH="/opt/local/bin:$PATH" | |
. "$(git --exec-path)/git-sh-setup" | |
set -e | |
git fsck --full | |
git prune -v |
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
#!/bin/sh | |
groupname="${1:?Need a group to push to}" | |
branch="${2:-master}" | |
for r in $(git config "remotes.${groupname}"); do | |
echo >&2 "Pushing '${branch}' to '${r}'" | |
git push "$r" "$branch" | |
done |
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
#!/bin/sh -u | |
CMD_NOT_FOUND=127 | |
PORT="${1:-8000}" | |
python3 -m http.server "$PORT" | |
ev=$? | |
[ $ev -ne $CMD_NOT_FOUND ] && exit $ev | |
python2 -m SimpleHTTPServer "$PORT" |
OlderNewer