Skip to content

Instantly share code, notes, and snippets.

@phooky
phooky / no_masters.sh
Last active December 16, 2020 16:54
A quick bash script for changing the "master" branch of your github repo(s) to an alternative of your choosing.
#!/bin/bash
# There's a better way to do this! Use:
# https://github.com/dfm/rename-github-default-branch
# instead.
#
# Also: don't change the default branch name on your gists! Github appears to have them
# locked to master; it will break your gist.
set -e
@phooky
phooky / randomorganelle.py
Created November 6, 2019 22:34
terrible fm synthesis, it's just awful
#!/usr/bin/python3
import wave
import sys
import struct
import math
outpath=sys.argv[0].rsplit('.',1)[0]+".wav"
print("Writing to {}".format(outpath))

Keybase proof

I hereby claim:

  • I am phooky on github.
  • I am phooky (https://keybase.io/phooky) on keybase.
  • I have a public key whose fingerprint is 8D02 E4ED 9CB7 9E1D 739A A5AE 2811 F88B 2064 A861

To claim this, I am signing this object:

@phooky
phooky / clone_repos.py
Created November 9, 2012 22:32
A quick script for cloning all the githup repositories for your user. Requires the github3 package; install with "pip install github3"
#!/usr/bin/python
from github3 import authorize, login
from getpass import getuser, getpass
from os.path import exists, expanduser
from subprocess import Popen
CREDENTIALS_PATH = expanduser('~/.clone_repo.token')
def cloneAllRepos(gh):
@phooky
phooky / moore.py
Created February 6, 2012 05:52
That thing for the dragon curve? Yeah, again, but for the moore curve.
#!/usr/bin/python
from itertools import chain
import sdxf
from math import sin,cos,pi
axiom = list("LFL+F+LFL")
rules = { 'L' : list("-RF+LFL+FR-"),
'R' : list("+LF-RFR-FL+") }
@phooky
phooky / dragon.py
Created January 25, 2012 01:08
Script for generating a dragon curve in dxf format; requires sdxf.
#!/usr/bin/python
import sdxf
from math import sqrt, sin, cos, pi
iterations = 11
def move(pos,angle,distance):
nx = pos[0] + sin(angle)*distance
ny = pos[1] + cos(angle)*distance
@phooky
phooky / git-wrapper.sh
Created January 5, 2012 05:17
A simple wrapper script for git that tracks cloned repositories and implements "git pull-all" to do a git pull in each such repository.
#!/bin/sh
#
# Git wrapper for tracking cloned repositories and implementing
# "pull-all" to update all cloned repositories from their origins.
#
# Add the following to your bashrc to enable:
# alias git=/PATH/TO/git-wrapper.sh
# Todo: parse out options to clone to avoid completely messing up
#!/usr/bin/env python
# Here's a useful skeleton for generating (in this case) an intel hex file
# for filling size bytes with 0xff; it can be easily modified to convert
# bytes from stdin.
size = 0x200
offset = 0
blocksize = 16