Skip to content

Instantly share code, notes, and snippets.

View craigcalef's full-sized avatar
💭
It is by my will alone that I set my mind in motion.

Craig Calef craigcalef

💭
It is by my will alone that I set my mind in motion.
View GitHub Profile
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@craigcalef
craigcalef / tengutins.py
Created June 23, 2011 06:44
Figure out how many tengus you have to eat to get both teleportitis and teleport control. Also calculate the probability of getting teleportitis and teleport control using Monte Carlo integration.
"""
Figure out how many tengus I have to eat to get both teleportitis and teleport control.
Author: Craig Calef <craig@dod.net>
"""
import random, sys, os, pprint
def rn2(i):
return random.randint(0, i-1)
@craigcalef
craigcalef / startscum.py
Created July 17, 2011 23:16
Automate 'start scumming' -- repeatedly generating characters till an advantageous starting inventory is found.
USERNAME = 'NAOUSERNAME'
PASSWORD = 'NAOPASSWORD'
import pexpect, traceback, sys, time
def scum(n):
try:
#n = pexpect.spawn('nethack')
print "BEGIN"
r = n.expect(['Shall I pick', 'Restoring save file', 'Too many hacks', 'stale' ])
@craigcalef
craigcalef / wrapmod.py
Created January 11, 2012 01:29
Wrapping a module
import sys, warnings
def WrapMod(mod, deprecated):
"""Return a wrapped object that warns about deprecated accesses"""
deprecated = set(deprecated)
class Wrapper(object):
def __getattr__(self, attr):
if attr in deprecated:
warnings.warn("Property %s is deprecated" % attr)
@craigcalef
craigcalef / exception_printer.py
Created February 22, 2012 04:36
Exception printing decorator
import traceback
def printexceptions(f):
def a(*args, **kwargs):
try:
return f(*args, **kwargs)
except:
traceback.print_exc()
return a
@craigcalef
craigcalef / gist:2724527
Created May 18, 2012 10:25
Monte Carlo simulation of the "Left, Right, Center" dice game showing how it is a loaded game.
import random
class GameFinished(Exception):
pass
def lrc_roll():
return random.randint(0,2)
def finish_condition(pool):
@craigcalef
craigcalef / gist:6403297
Created September 1, 2013 09:28
Access the EVE Online CREST API to obtain information on Dust 514 Planetary Conquest districts and produce reports of various useful information.
import requests, json
from collections import Counter
districts = json.loads(requests.get('http://public-crest.eveonline.com/districts/').text)['items']
systems = {}
constellations = {}
s_times = {}
c_times = {}
@craigcalef
craigcalef / vmwareparse.py
Created November 15, 2013 00:43
Rackspace gave me a 'dump' from VMware of all my VMs, so I made a crappy little python script to parse it into something more usable...
import pprint
import re
pattern = r'.*(\d*) GB \[(.*)\]'
example = '______|Virtual Disk: 25 GB [421451-san-fc-hlu00]'
vmd = [l.strip() for l in open("vmmap.txt", "r").readlines()]
vmm = {}
latch = False
for l in vmd:
if l == "":
latch = False
@craigcalef
craigcalef / gist:7983832
Created December 16, 2013 08:23
The Obituary Guest Book of John W. Eklund
November 19, 2013
My deepest sympathies to you and yours. Sending all of my love and strength.
~ Kelly Smith Kilmer, Los Angeles, California
Contact Me
November 19, 2013
Jenn and Brian we are so sorry for you loss. May all your memories comfort you. We love you and are here if you need us
~ Deb Rob and Liam Ahern, Pascoag, Rhode Island
November 18, 2013
RIP uncle John! I'm so sorry I didn't see you first. Thanks for always being so good to us kids. Love you forever!
~ Cameron Calef, Quincy, Massachusetts
@craigcalef
craigcalef / slipstream
Last active January 1, 2016 21:08
Ubuntu preseed for fast, automated installation.
# Ubuntu Server Quick Install
# Based on http://bit.ly/uquick-doc by Dustin Kirkland <kirkland@ubuntu.com>
# Boot via DHCP, seriously wipe the disk DO IT
# Add boot options: priority=critical locale=en_US url=https://gist.github.com/craigcalef/8201088/raw
#
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/splash boolean false
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us