Skip to content

Instantly share code, notes, and snippets.

Phil Pennock philpennock

Block or report user

Report or block philpennock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
philpennock /
Created Jan 12, 2011
Demo of Python one-time eval of function declaration default params, used for caching.
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)
philpennock /
Created Mar 20, 2012
Sample WSGI debug application
from __future__ import print_function
import os
import threading
import time
startup_lock = threading.Lock()
philpennock / gist:3505352
Created Aug 28, 2012
Demonstrate python function *args & **kwargs
View gist:3505352
>>> 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'}
philpennock / exit_check.go
Created Oct 24, 2012
Showing interactions of defer, os.Exit and panic in Golang.
View exit_check.go
package main
import (
philpennock / foreach-beginend
Last active Dec 25, 2015
Used to iterate over PEM-encoded items in a file
View foreach-beginend
#!/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
use strict;
use warnings;
View guarded_memory_alloc_test.c
// 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>
#!/usr/bin/env python3.2
polygon: polygon puzzle solver business cards might have a polygon puzzler on a promotional card in
the pack. This tool finds the words.
__author__ = ' (Phil Pennock)'
philpennock / git-dessicate
Created Nov 13, 2013
git subcommand to work on serious cleanup and space reclamation
View git-dessicate
[ -d /opt/local/bin ] && PATH="/opt/local/bin:$PATH"
. "$(git --exec-path)/git-sh-setup"
set -e
git fsck --full
git prune -v
philpennock / git-pushgroup
Created Nov 13, 2013
git: Push a branch to a group of remotes
View git-pushgroup
groupname="${1:?Need a group to push to}"
for r in $(git config "remotes.${groupname}"); do
echo >&2 "Pushing '${branch}' to '${r}'"
git push "$r" "$branch"
View serve_here
#!/bin/sh -u
python3 -m http.server "$PORT"
[ $ev -ne $CMD_NOT_FOUND ] && exit $ev
python2 -m SimpleHTTPServer "$PORT"
You can’t perform that action at this time.