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
@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: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 / 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 / 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 / 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 / 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 / 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 <[email protected]>
"""
import random, sys, os, pprint
def rn2(i):
return random.randint(0, i-1)
/*
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.