Skip to content

Instantly share code, notes, and snippets.

@jsundram
jsundram / howtolog.md
Last active August 28, 2022 22:53
How to make a chamber music log (or any other kind of information) using google forms

How to Make a Chamber Music Log

  1. Go to Google Forms https://docs.google.com/forms/u/0/

  2. Create new Form

  3. Screenshot 2017-05-31 11 55 03
    1. Fill it out with the questions that you might like to have. Mine looks like this:
    2. Screenshot 2017-05-31 12 17 39
  4. Click Responses

@jsundram
jsundram / wigmore_isqc.md
Last active April 13, 2022 22:36
Overview of the Wigmore Hall International String Quartet Competition (2022)

2022 Wigmore Hall International String Quartet Competition

Last night, I noticed on the Wigmore Hall YouTube channel the results of an International String Quartet Competition. This was strange, because although I was familiar with the trienniel Banff Competition I was unaware of this competition, which predates it. The Competition started in 1979 in Portsmouth (the Takács Quartet won), and moved to London in 1988. It only arrived at Wigmore Hall in 2010. So perhaps the 3 rebrands made me less aware of it.

From the Competition's wikipedia page I learned that

twelve [quartets] are selected to take part in the competition.

@jsundram
jsundram / wordle_stats_viz.py
Last active October 6, 2023 19:39
letter statistics visualizations for wordle (using the short wordle wordlist)
from collections import Counter
from string import ascii_lowercase as ALPHABET
import json
import matplotlib.pyplot as plt
import numpy as np
"""
For https://www.powerlanguage.co.uk/wordle/.
Read more here: https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html
"""
@jsundram
jsundram / random.sh
Created April 4, 2021 22:01
get a few random words from the osx dictionary file
# https://stackoverflow.com/questions/9245638/select-random-lines-from-a-file
cat /usr/share/dict/words | sort -R | head -10 $lines
# faster
gshuf -n 10 /usr/share/dict/words
@jsundram
jsundram / hex_to_latex.py
Last active June 17, 2022 21:44
Convert a HEX color to LateX Color Spec. Useful for taking colors from any site and producing output suitable for e.g. http://latexcolor.com/
def hex_to_latex(c, name="name"):
""" Input: a hex color like "#B29155" ('#' is optional)
Output: \definecolor{name}{rgb}{0.70, 0.16, 0.57}
"""
if c.startswith("#"):
c = c[1:7]
r, g, b = [(int(c[ix:ix+2], base=16) / 255) for ix in range(0, 6, 2)]
return '\definecolor{%s}{rgb}{%1.2f, %1.2f, %1.2f}' % (name, r, g, b)
@jsundram
jsundram / slic.jl
Last active February 18, 2021 19:35
SuperPixel Segmentation in Julia
# src: https://github.com/johnnychen94/SuperPixels.jl/blob/analyze/src/analyze.jl
function SLIC(img::AbstractArray{<:Colorant, 2}; kwargs...)
return SegmentedImage(img, _slic(Lab.(img); kwargs...))
end
SLIC(img::AbstractArray{<:Number, 2}; kwargs...) = _slic(Gray.(img); kwargs...)
@jsundram
jsundram / julia-thoughts.md
Last active February 20, 2021 18:12
summarizing some of the surprises I encountered in programming Julia for the first time over about 3 months.

Initial impressions of Julia coming from Python (and C++, JavaScript ...)

Surprises / Gotchas

  • 1-based indexing?? in 2021? I thought this battle was over. Esp with C/Python FFI, it's a weird choice.
  • installing packages is weird. open up the repl, type ], and then "add X", or import Pkg; Pkg.add("X")?
  • Manifest.toml is cool but a bit non-obvious to figure out how to update it.
  • methods on objects vs methods that take objects. I get it, but less discoverable. e.g. haskey(mydict, "a") instead of has_key?
    • methodswith(Dict) is a nice workaround (but also isn't itself discoverable!)
  • methodswith doesn't return sorted results! You need sort(methodswith(Dict), by=m-&gt;m.name) or methodswith(Dict, Base) to exclude other mod. And this actually doesn't include values or keys unless you do methodswith(Dict, Base; supertypes=true) (thanks [discourse](https://discourse.julialang.org/t/can-methodswith-return-
from datetime import datetime
from dateutil import parser
import csv
import json
import requests
def id_for_page(page):
"""Uses the wikipedia api to find the wikidata id for a page"""
api = "https://en.wikipedia.org/w/api.php"