Skip to content

Instantly share code, notes, and snippets.

@jsundram
jsundram / merge_pdfs.py
Created June 12, 2013 05:37
Takes a list of pdf filenames and and output filename and merges all the input filenames into one pdf (in the order they were specified).
from glob import glob
import os
from pyPdf import PdfFileWriter, PdfFileReader
def merge_pdfs(pdfs, output_file, delete_originals=True):
""" Takes a list of pdf filenames and and output filename
and merges all the input filenames into one pdf (in
the order they were specified
"""
merged = PdfFileWriter()
@jsundram
jsundram / _.md
Created June 30, 2013 03:25
timbre.js pendulums
@jsundram
jsundram / markdownify_links.py
Created July 6, 2013 21:08
Pull the links out of a google doc and format them for use in Markdown. Works on a file that google docs has exported to html.
@jsundram
jsundram / BoxyLady2_pp.py
Last active December 19, 2015 16:18
Implementation of BoxyLady2 aimed at pyprocessing
"""https://code.google.com/p/pyprocessing/wiki/QuickReference#Pyprocessing_Documentation"""
from pyprocessing import *
from random import randint as random
MAXS = 40
MINS = 1
pic = None
grow = False
box_size = MAXS
@jsundram
jsundram / README.md
Last active December 19, 2015 19:09
Colorbrewer colors for use in python. Copied from https://gist.github.com/mbostock/5577023

Utilities for accessing and working with colorbrewer colors in Python. Data copied from mbostock's block #5577023

@jsundram
jsundram / README.md
Last active June 16, 2016 14:40
Install AggDraw for OSX 10.7+.
@jsundram
jsundram / haydn.py
Created July 21, 2013 23:44
get haydn quartets from music21
import music21
haydn = music21.corpus.getWorkList('haydn')
haydn = [h for h in haydn if 'essenFolksong' not in h and 'symphony' not in h]
prefix, _ = haydn[0].split('haydn/')
prefix += 'haydn/'
# now we have a list of all the quartets
haydn_quartets = [h.replace(prefix, '') for h in haydn]
@jsundram
jsundram / pngs_to_video.py
Created July 23, 2013 07:28
Create an mp4 from the files in the input directory given. If there aren't a ton, make an animated gif. Assumes ImageMagick (for animated gif) or mjpegtools and ffmpeg for H264-encoded mp4.
from glob import glob
import sys
from tempfile import NamedTemporaryFile
png_dir = sys.argv[1]
wildcard = os.path.join(png_dir, '*.png')
n = len(glob(wildcard))
if n < 100:
# for short files, animated gifs are preferable
import music21
import os
from collections import defaultdict
HAYDN = music21.corpus.getWork('haydn')
def title(h):
path, mvt = os.path.split(h)
mvt, ext = os.path.splitext(mvt)
qrt = os.path.basename(path)
@jsundram
jsundram / index.html
Last active December 23, 2015 20:29
time-series breakdown
<!DOCTYPE html>
<html lang="en">
<head>
<title>dc.js multi-line chart attempt</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/dc.css"/>
<link rel="stylesheet" type="text/css" href="http://nickqizhu.github.io/dc.js/css/bootstrap.min.css"/>