Skip to content

Instantly share code, notes, and snippets.

@jsundram
jsundram / make_map.py
Created January 27, 2019 04:32
ingest some addresses from a csv, geocode them and make a map.
import csv
import io
import json
import os
import re
import time
from itertools import groupby
import folium
import geocoder
@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),
from bs4 import BeautifulSoup
import csv
import json
import re
import random
import requests
import time
import urllib
BASE = 'http://web.mit.edu/bin/cgicso?query'
@jsundram
jsundram / README.md
Last active May 2, 2017 00:37
get the most important links tweeted during #openvisconf 2017
<html><head><meta charset="utf-8" /></head><body><script type="text/javascript">/**
* plotly.js v1.20.5
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
* Licensed under the MIT license
*/
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){var r=e[o][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){"use strict";var n=t("../src/lib"),i={"X,X div":"font-family:'Open
@jsundram
jsundram / get_lat_lon_exif_pil.py
Last active January 19, 2017 06:16 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
import PIL.Image
from PIL.ExifTags import TAGS, GPSTAGS
from operator import mul
def rekey(d, source):
"""Re-keys a dictionary d to use keynames from source mapping."""
return {encoding.get(k, k):v for (k, v) in d.iteritems()} if d else {}
def get_exif(image):
seconds_per_year = 365*24*3600
new_year = time.mktime(time.strptime("01/01/2017 0:0:0", "%m/%d/%Y %H:%M:%S"))
print "wishing everyone a happy %.1f through %.1f" % (new_year, new_year + seconds_per_year)
@jsundram
jsundram / subscription_opportunities.py
Last active September 23, 2016 16:16
Get top presenters from Boston Musical Intelligencer to figure out what series there may be to subscribe to.
from collections import Counter
import bs4
import requests
p = requests.get('http://www.classical-scene.com/calendar/')
s = bs4.BeautifulSoup(p.content, "lxml")
presenters = s.select('.presenter > a')
c = Counter(p.text for p in performers)
# At least 4 concerts to be considered for a series subscription.
@jsundram
jsundram / processing-docs.sh
Created September 3, 2016 15:47
trying to get processingjs docs ready for offline consumption
git clone https://github.com/processing-js/processing-js.github.io.git
cd processing-js.github.io/
sudo gem install jekyll
sudo gem install bundler
sudo gem install github-pages
jekyll build
cd _site
python -m SimpleHTTPServer
# in browser: http://0.0.0.0:8000/reference/
@jsundram
jsundram / render_all_blend_modes.pyde
Last active April 2, 2016 23:31
Test out each of the blend modes; need to run 3x, one for each render mode.
# Code for https://github.com/processing/processing/issues/4376
# See processing/core/src/processing/core/PConstants.java for render/blend mode constants.
labels = 'REPLACE, BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN'.split(', ')
blend_modes = [REPLACE, BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN]
blend_mode_names = dict(zip(blend_modes, labels))
render_modes = [JAVA2D, P2D, P3D]
render_mode = render_modes[0]
def setup():
size(300, 1000, render_mode)