Skip to content

Instantly share code, notes, and snippets.

View mikeboers's full-sized avatar

Mike Boers mikeboers

View GitHub Profile
# encoding: utf8
from __future__ import print_function
import base64
import ast
def dumps(x):
if x in (True, False, None):
return repr(x)
t = type(x)
from __future__ import division
import random
import math
import hashlib
import hmac
def str_to_int(input):
out = 0
for c in input:
import re
from mako.template import Template
source = '''pre %{for i in range(10)}
${- i -}
%{- if i % 2 -}
-
%{- else -}
|
%{- endif -}
@mikeboers
mikeboers / convert.py
Created August 27, 2012 13:59
How to use Google Authenticator links with OATH Token
import base64
import re
import sys
if len(sys.argv) > 1:
code = ''.join(sys.argv[1:])
else:
code = sys.stdin.read()
# Parse the Google URL.
@mikeboers
mikeboers / tsv_transpose.py
Last active December 26, 2015 03:55
Python script to transpose tab-delimited data (e.g. copy-pasted data from a spreadsheet).
import csv
import itertools
import sys
# Read all Tab-delimited rows from stdin.
tsv_reader = csv.reader(sys.stdin, delimiter='\t')
all_data = list(tsv_reader)
# Transpose it.
all_data = list(itertools.izip_longest(*all_data, fillvalue=''))
@mikeboers
mikeboers / X.mc-parsed.txt
Created February 27, 2013 21:50
Parsed 3x3x3 Maya fluid caches; one for each axis where the density increased in the positive direction.
Start CACH (FOR4) of length 40
<Chunk 'VRSN' size=4 value=None>
0014: 302e3100 0.1.
<Chunk 'STIM' size=4 value=None>
0020: 000001f4 ....
<Chunk 'ETIM' size=4 value=None>
002c: 000001f4 ....
@mikeboers
mikeboers / ks.core.partio.conv.py
Created March 13, 2013 16:25
Wrapper around partio's `partconv` tool for handling Maya file naming conventions.
#!/usr/bin/env python
from subprocess import call
import os
import sys
import re
if len(sys.argv) < 3:
print 'usage: %s particle_folder output_type+' % sys.argv[0]
exit(1)
@mikeboers
mikeboers / shotgun_api3_registry.py
Created May 7, 2013 21:57
Example Shotgun API key registry.
import os
import sys
import logging
# Turn logging down premptively.
logging.getLogger("shotgun_api3").setLevel(logging.WARNING)
import shotgun_api3
@mikeboers
mikeboers / .bash_history
Created May 15, 2013 18:08
Tiny fork example
2013-05-15 11:06:20 mikeboers@faraday: ~/Desktop
$ gcc fork.c
2013-05-15 11:07:25 mikeboers@faraday: ~/Desktop
$ ./a.out
Before the fork.
I am the parent of 9761.
I am the child.
@mikeboers
mikeboers / traceroute-failing
Last active December 17, 2015 11:29
2013-05-17 TekSavvy routing issue
2013-05-16 17:28:17 mikeboers@maxwell: ~
$ traceroute -w 1 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * 64.59.148.241 (64.59.148.241) 16.647 ms !X *