Skip to content

Instantly share code, notes, and snippets.

@jsundram
jsundram / image_average.py
Created June 11, 2013 18:12
Takes a folder full of images and computes their average and median. Assumes they all have the same dimensions. Makes no attempt at alignment.
from glob import glob
import numpy as np
import os
import sys
# You'll need scikit-image and PIL installed to use this
try:
import skimage.io
except ImportError:
sys.exit("please 'pip install scikit-image' to use this script")
@jsundram
jsundram / get_checkins.py
Last active February 19, 2024 00:30
Get my Swarm checkins from Foursquare
import requests
from datetime import datetime
import json
"""
Instructions:
1. go to https://swarmapp.com/history
2. open developer tools in browser, and navigate to the "network" tab.
3. filter for fetch/XHR
4. select a month in the dropdown
@jsundram
jsundram / Haydn-020_4-wp4tet.md
Last active January 16, 2024 20:03
Haydn: String Quartet in D, Op 20 Nr. 4 Program Notes from Willow Pond String Quartet 1996 concert (from https://www.bobrej.com/picnic/1996.htm)

Haydn: String Quartet in D, Op 20 Nr. 4

  1. Allegro di molto
  2. Un poco Adagio affettuoso (Theme with variations)
  3. Menuetto: Allegretto all zingarese
  4. Finale. Presto scherzando

haydn - wpq

Of humble origins, Franz Joseph Haydn was born in the village of Rohrau, near Vienna, on March 31, 1732. When eight years old he was accepted into the choir school of Saint Stephen's Cathedral in Vienna, where he received his only formal education. Dismissed from the choir at the age of seventeen, when his voice broke, he spent the next several years as a struggling freelance musician. He studied on his own the standard textbooks on counterpoint and took occasional lessons from the noted Italian singing master and composer Nicola Porpora. In 1755 Haydn was engaged briefly by Baron Karl Josef von Fürnberg, for whom he apparently composed his first string quartets. Haydn's marriage in 1760 to Maria Anna Keller proved to be unhappy.

@jsundram
jsundram / Haydn-076_2-wp4tet.md
Created January 16, 2024 20:03
Haydn: String Quartet in d, Op 76 Nr. 2 Program Notes from Willow Pond String Quartet 1997 concert (from https://www.bobrej.com/picnic/1997.htm)

Haydn: String Quartet in d, Op 76 Nr. 2 "Quinten"

  1. Allegro
  2. Andante o più tosto Allegretto
  3. Menuetto
  4. Finale. Vivace assai

haydn - wpq

Of humble origins, Franz Joseph Haydn was born in Rohrau, near Vienna, on 31 March 1732. When eight years old he was accepted into the choir school of Saint Stephen's Cathedral in Vienna, where he received his only formal education. Dismissed from the choir at the age of seventeen, when his voice broke, he spent the next several years as a struggling freelance musician. In 1755 Haydn was engaged briefly by Baron Karl Josef von Fürnberg, for whom he apparently composed his first string quartets. Haydn's marriage in 1760 to Maria Anna Keller proved to be unhappy. The turning point in Haydn's fortunes came in 1761, when he was appointed assistant music director to Prince Pál Antal Esterházy; a year later he became full director. As Kapellmeister, Haydn served under the patronage of thre

@jsundram
jsundram / github-pandoc.css
Last active January 13, 2024 20:49 — forked from dashed/github-pandoc.css
Forked copy, incorporating changes suggested on the comment thread from @timfoster and @nightroman (`55em` vs `44em` and `overflow-x: scroll;`). Use as follows: `pandoc -s -f gfm -t html5 -o readme.html README.md -c github-pandoc.css`
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@jsundram
jsundram / connections.py
Created November 17, 2023 20:23
Use word embeddings to generate better guesses at NYT Connections. TODO: come up with an algorithm to actually solve connections... https://www.nytimes.com/games/connections
from collections import defaultdict
from scipy import spatial
from sklearn.manifold import TSNE
from sklearn.cluster import SpectralClustering, KMeans
import functools
import heapq
import matplotlib.pyplot as plt
import numpy as np
import os
@jsundram
jsundram / boxed.py
Last active November 16, 2023 22:10
Solve the NY Times' Letter Boxed game in 2 guesses (modified version of KV's code/algorithm)
from time import time
import re
import sys
def get_words(filename='words.txt'):
# https://raw.githubusercontent.com/dwyl/english-words/master/words.txt
with open(filename) as f:
return [line.strip() for line in f]

MDB Excavation

MDB is a Microsoft Access Database file. We'd like to look inside of it, but we have a Mac and no MS Office license.

export.py is a program that can do each of the following:

  1. Put each table into its own .csv file to look at.
  2. Put each table in the data into an excel / google sheets doc for easy viewing/browsing
  3. Create a sqlite db which is similarly portable but accessible via a variety of common tools
@jsundram
jsundram / linker.py
Last active November 5, 2023 22:49
Given a cantata number, spit out some useful links, and copy them to a paste-able format suitable for, e.g. quip.
#!/usr/bin/env python3
import sys
def main(bwv):
bwv0 = '%03d' % int(bwv)
links = {
# label: (url template, raw?)
bwv: ('http://www.bach-cantatas.com/BWV{slug}.htm', True),
'allofbach permalink': ('https://www.bachvereniging.nl/en/bwv/bwv-{slug}', True),