Skip to content

Instantly share code, notes, and snippets.

View gravitymonkey's full-sized avatar

gravitymonkey gravitymonkey

View GitHub Profile
@jacobstern
jacobstern / gen_pcs_script.py
Created February 12, 2013 02:20
Utility to name Forte's pitch class sets. Generate a portable script from a TSV file of PCS data using Python's metaprogramming capabilities. Sample output of gen_pcs_script.py included. Sample usage: python gen_pcs_script.py pitch_classes.tsv; python pitch_class_set.py A C# B
#! /usr/bin/python
import csv
import inspect
__pcs_export = set()
def pcs_function(f):
__pcs_export.add(f)
@mackross
mackross / objc-core-animation-shake
Created February 3, 2012 03:50
Core Animation Shake
- (void)shakeAnimation:(CALayer*)layer
{
CGPoint pos = layer.position;
static int numberOfShakes = 3;
static CGFloat vigourOfShake = 0.055;
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef shakePath = CGPathCreateMutable();
CGPathMoveToPoint(shakePath, NULL, pos.x, pos.y);
int index;
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite