Skip to content

Instantly share code, notes, and snippets.

View lwrubel's full-sized avatar

Laura Wrubel lwrubel

View GitHub Profile
@lwrubel
lwrubel / captions-shift.py
Last active June 26, 2024 13:24
Shift timestamps for captions in VTT files. Usage: python3 captions-shift.py my_captions.vtt my_edited_captions.vtt -2.25
#!/usr/bin/env python3
import webvtt
from datetime import datetime, timedelta
import argparse
parser = argparse.ArgumentParser(description="Shift caption start \
and end times in a .vtt file")
parser.add_argument("inputfile", help="input filename, must be VTT format")
parser.add_argument("outputfile", help="output filename")
@lwrubel
lwrubel / mena-serials-before.csv
Created September 23, 2019 19:14
Messy serials data example
MMS ID Library Location Volume Issue number Year Month Barcode Note
99169315803604107 gelman grcmis 1 1 1989 Spring 32882022255379
99169315803604107 gelman grcmis 1 2 1989 Summer 32882022255387
99169315803604107 gelman grcmis 1 3 1989 Autumn 32882022255635
99169315803604107 gelman grcmis 1 4 1990 Winter 32882022255882
99169315803604107 gelman grcmis 2 1 1990 Spring 32882022256138
99169315803604107 gelman grcmis 2 2 1990 Summer 328820222563
99169315803604107 gelman grcmis 2 3 1990 Autumn 32882022256393
99169315803604107 gelman grcmis 2 4 1991 Winter 32882022256146
99169315803604107 gelman grcmis 3 1 1991 Spring 32882022255890
@lwrubel
lwrubel / csv-to-ris-format.py
Last active December 21, 2022 20:56
Convert csv exported from Google Sheets to RIS format. To use: python csv-to-ris-format.py infile.csv outfile.txt
#!/usr/bin/env python
# To use:
# python csv-to-ris-format.py csvfile.csv risoutput.txt
#
# Assumes you have removed the header row from the csv file,
# columns are in the same order as the labels list,
# and there are no other columns in the csv.
import csv
from sys import argv
@lwrubel
lwrubel / chronam-title-counts.rb
Created April 24, 2017 00:20
Sonic Pi code for a sonification of the numbers of titles in Chronicling America, year by year.
require 'csv'
data = CSV.parse(File.read("/Users/lwrubel/projects/chronam-exploration/final-counts.csv"), {:headers => false})
count = 1788
notes = scale(:g2, :major, num_octaves: 5)
separator = 0.2
# for each line of data, play a drum beat and appropriate pitch
data.each do |line|
puts line
@lwrubel
lwrubel / cycling-to-work.rb
Last active March 1, 2016 13:47
Cycling to work from Alexandria to Foggy Bottom, DC
# cycling to work, in a brisk cold wind
# csv file has a heartrate and altitude measurement taken each second
# piano is the heartrate, higher note is higher heartrate
# underlying synth is altitude, higher pitch is higher altitude
require 'csv'
data = CSV.parse(File.read("/Users/lwrubel/projects/datasonify/20160222-cycle-to-work.csv"))
# using pentatonic scale for heartrate
@lwrubel
lwrubel / launchpad-github.rb
Last active December 14, 2015 20:16
Sonic Pi code for reading Github commits to GW Libraries Launchpad repo
# files changed in github launchpad repo (https://github.com/gwu-libraries/launchpad)
# full sonic pi code at https://gist.github.com/lwrubel/5a621aa316741ad8d315
require 'csv'
data = CSV.parse(File.read("/Users/lwrubel/projects/stg-sound/launchpad-noDmrc.csv"), {:headers => false})
use_synth :subpulse
separator = 0.15
count = 0
@lwrubel
lwrubel / plain-bob-minor.rb
Created October 4, 2015 20:00
Plain Bob Minor (6 bells)
# Plain Bob Minor (6 bells)
use_synth :dull_bell
bells = [:A5, :G5, :F5, :E5, :D5, :C5]
define :round do |c|
4.times do |row|
puts "Round #{row}"
for i in 0..5
play bells[i], release: 2
@lwrubel
lwrubel / plain-hunt-on-4.rb
Last active October 4, 2015 19:58
Plain Hunt on 4 bells (minimus)
# Plain hunt minimus (on 4)
use_synth :dull_bell
minimus = [:F5, :E5, :D5, :C5]
define :round do |c|
4.times do |change|
puts "Change #{change}"
for i in 0..3
play c[i], release: 2
@lwrubel
lwrubel / checkouts.rb
Last active September 12, 2015 15:01
# plays one note for each day in a year of checkout data from the library
# recording at https://soundcloud.com/laurasaurus5/checkouts
require 'csv'
data = CSV.parse(File.read("/Users/lwrubel/projects/datasonify/gwtransactcounts.csv"), {:headers => true, :header_converters => :symbol})
# 7/1/2014 is a Tuesday and day 182 of the year
dailycount = 2
day = 182