Skip to content

Instantly share code, notes, and snippets.

View hamiltont's full-sized avatar
🕵️‍♂️
huntin' wabbits

Hamilton Turner hamiltont

🕵️‍♂️
huntin' wabbits
View GitHub Profile
@hamiltont
hamiltont / data.R
Created November 19, 2012 03:37
Using stat_contour on ggplot2
hybrid_data_regular <- structure(list(sample = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@hamiltont
hamiltont / bex2csv.py
Last active December 15, 2021 14:37 — forked from shanewholloway/gist:3536969
Converts Billings 3 Slips into CSV readable. Export entire Slip Log by right-clicking on slips, choosing to export, saving as bex. Run this script in any folders containing the bex files. They will be found, parsed, and the output will be written to a CSV file in the same folder
import csv
import glob
import plistlib
clientProject = 'My Project'
for filename in glob.glob("*.bex"):
root = plistlib.readPlist(filename)
with open(filename+'.csv', 'wb') as out:
out = csv.writer(out, delimiter='|')
out.writerow(['Slip', 'Start', 'End', 'Duration (minutes)'])
@hamiltont
hamiltont / 0_reuse_code.js
Created November 12, 2013 04:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hamiltont
hamiltont / QuickLogger.java
Created November 16, 2013 01:28
A one-file logger. Can easily be replaced with a more advanced system, but useful for starting
/**
* <p>
* This is a one-file logger that can be used to get you started quickly. You
* can send it any array of objects that it will print to stdout/stderr.
* Reflection is used to print the class/line/method. QuickLogger is pretty darn
* slow, so don't use it in production.
* </p>
* <p>
* All methods are static, and you can (if your IDE supports it, which most do)
* use static imports to make your life even easier
@hamiltont
hamiltont / walk.py
Created November 17, 2013 21:00
Testing performance of os.walk vs glob for FrameworkBenchmarks My results: gather_tests function took 400.566 ms glob_tests function took 10.128 ms
import os
import json
import time
import importlib
import sys
import glob
# From http://stackoverflow.com/a/5478448/119592
def timing(f):
def wrap(*args):
@hamiltont
hamiltont / dynamic_dnsimple.sh
Created December 18, 2013 05:38 — forked from mislav/dynamic_dnsimple.sh
Using username and password authentication
#!/bin/bash
set -e
domain=mislav.net
record=511770 # mysubdomain.mislav.net
ip="$( curl -s icanhazip.com )"
payload="{ \"record\": { \"content\": \"${ip}\" } }"
curl -fsS --netrc \
@hamiltont
hamiltont / update.sh
Created January 21, 2014 22:22
Update dnsimple.com using domain token and record ID (more secure than storing username and password in script)
#!/bin/bash
DOMAIN_ID="yourdomain.com"
RECORD_ID="9348341"
DOMAIN_TOKEN="8339c723c223445f6c876bca3fafffd3345"
IP="`curl http://ipv4.icanhazip.com/`"
JSON="{\"record\":{\"content\":\"$IP\"}}"
curl -H "X-DNSimple-Domain-Token: $DOMAIN_TOKEN" \
-H "Accept: application/json" \
#include <stdio.h>
#include <unistd.h>
int main()
{
/* fork a child process */
fork();
/* fork another child process */
fork();
/* and fork another */
@hamiltont
hamiltont / pdock.sh
Last active August 29, 2015 13:56
Initial version of a micro platform for rapidly proxying docker containers
# Pdock rapidly sets up a tiny platform for you automatically discover and
# serve your docker services. It uses the hipache and skydock projects
# to enable rapidly connecting to your containers via subdomain names.
# Only port 80 has to be opened, and UDP,TCP,HTTP,WebSocket should
# work (mostly) out of the box
#
# Copyright 2014 Hamilton Turner <hamiltont@gmail.com>
#
#
# Examples:
@hamiltont
hamiltont / brew_ls_pygtk_-v
Created February 24, 2014 19:19
Output of brew ls pygtk -v
hamiltont$ brew ls pygtk -v
/usr/local/Cellar/pygtk/2.24.0/AUTHORS
/usr/local/Cellar/pygtk/2.24.0/bin/pygtk-codegen-2.0
/usr/local/Cellar/pygtk/2.24.0/bin/pygtk-demo
/usr/local/Cellar/pygtk/2.24.0/ChangeLog
/usr/local/Cellar/pygtk/2.24.0/COPYING
/usr/local/Cellar/pygtk/2.24.0/include/pygtk-2.0/pygtk/pygtk.h
/usr/local/Cellar/pygtk/2.24.0/INSTALL_RECEIPT.json
/usr/local/Cellar/pygtk/2.24.0/lib/pkgconfig/pygtk-2.0.pc
/usr/local/Cellar/pygtk/2.24.0/lib/pygtk/2.0/demos/__init__.py