Skip to content

Instantly share code, notes, and snippets.

View jsvine's full-sized avatar

Jeremy Singer-Vine jsvine

View GitHub Profile
@jsvine
jsvine / draft.md
Created August 10, 2012 14:10
Brute-Forcing a Word Puzzle

All this week, I've been trying to chip away at Allen R. Morgan's "Twice Removed" puzzle on page 50 of the August 5, 2012 New York Times Magazine. The rules:

For each word below, add the same pair of letters *twice* 
to complete a longer word. For example, if you were given 
MOTE, you would add ON twice to make MONOTONE.

After a few days, I'd found just four of the 24 words. Pathetic. After moping for a bit, I tried brute-forcing the answers. The strategy was simple, but radically different from how you or I would try solving the puzzle by hand. The steps:

  1. Get a big list of English words.
@jsvine
jsvine / sms-backup-to-csv.rb
Last active January 6, 2024 21:25
A quick script to convert the XML from Android app "SMS Backup & Restore" into CSV.
#!/usr/bin/env ruby
# A quick script to convert the XML from Android app "SMS Backup & Restore" into CSV.
#
# Usage: $ ./sms-backup-to-csv.rb < PATH/TO/BACKUP/FILE.xml
require "nokogiri"
require "csv"
# Specify the backup file's attributes and data types.
@jsvine
jsvine / visidata-pipx-installation.md
Last active May 16, 2023 05:55
Installing VisiData via pipx

Installing VisiData via pipx

pipx is a command-line tool that allows you to run Python applications in isolated environments. It's a great way to make VisiData available across your system without worrying that its dependencies will conflict with other Python projects. This short guide will show you how.

Step 0: Uninstall global VisiData

If you have have previously VisiData installed globally, uninstall it by running pip3 uninstall visidata.

Otherwise, you can skip this step.

@jsvine
jsvine / SIPRI-arms-transfer.md
Created November 18, 2015 12:30
How to download SIPRI arms transfer data as a CSV file instead of a rich-text file.

The Stockholm International Peace Research Institute's Arms Transfers Database provides a tool to download the data. By default, that output is an .rtf rich-text file — not so easy to analyze with your favorite spreadsheet or statistics software. Luckily, getting a CSV of the data isn't very difficult. Here's how.

To get all transfers for 2014, by seller, run this command in your terminal:

curl http://armstrade.sipri.org/armstrade/html/export_trade_register.php --compressed \
    --data 'low_year=2014' \
    --data 'high_year=2014' \
    --data 'seller_country_code=' \
 --data 'buyer_country_code=' \
@jsvine
jsvine / installations.md
Last active May 10, 2021 13:43
First things to install on a new Mac OSX [WIP]
@jsvine
jsvine / draft.md
Created August 8, 2012 14:56
Why I love Tabletop.js but don't use it in production

Tabletop.js is a fantastic, open-source JavaScript library that lets developers easily integrate data from Google Spreadsheets into their online projects. I've used it, even contributed a minor feature, and love it for prototyping. Non-programmers love being able to update a project via Google Spreadsheets' hyper-intuitive interface.

That said, I'm extraordinarily wary of using Tabletop in production. Instead, at the Wall Street Journal, we use a bit of middleware to "prune" our Google Spreadsheets-based data and then cache it on our own servers. A few brief reasons:

@jsvine
jsvine / git-editing-offer.md
Created April 19, 2012 02:08
A Git-for-Prose Experiment

A Git-for-Prose Experiment

TL;DR: I'll edit (almost) whatever prose you throw at me, provided you agree to use git for the entire process.

If you're reading this, you're probably familiar with git. But if you're not: [git][git-wiki] is an amazingly nimble "distributed revision control" system. Or -- in plain English -- it's what might happen if track-changes, a time machine, and a collage artist had a beautiful baby.

Software development is git's nearly universal use-case, and with good reason. Its branching and merging features let developers easily collaborate and experiment with new, crazy features without having to worry about wrecking a project or taking it in the wrong direction.

But there is, I think, a huge and largely untapped potential in using git for prose. The same branching and merging features could encourage writers and editors to take risks with a piece's style or structure that might otherwise seem too daunting. At the very least, git provides a way to track changes to a docume

@jsvine
jsvine / draft.md
Created June 9, 2012 18:16
Versioned Writing

Versioned Writing — an experiment

Status: Very drafty.

Git for prose, Git for everything

Recently, I've become hooked on the idea of applying version-control software (and the concepts it enables) to writing. Git and GitHub have completely transformed, for the better, the way I write and think about software. I have a hunch they can something similar for writing.

Some form of versioning already exists, raggedly, in most prose-writing workflows. It's typically linear. For instance, we all have a folder somewhere that looks like this:

@jsvine
jsvine / download-craftcans.js
Created May 21, 2017 18:33
Downloading CraftCans.com's canned beer database as structured data
// Step 1: Go to http://craftcans.com/db.php?search=all&sort=beerid&ord=desc&view=text
// Step 2: Open your browser's developer console
// Step 3: Paste the code below into the console
(function () {
var getText = function (el) {
return el.textContent.trim().replace(/\n/g, " ");
};
// Get the last <table> on the page
@jsvine
jsvine / optm-report-to-tsv.js
Created February 10, 2016 12:43
Script to convert Organ Procurement and Transplantation Network website data reports into spreadsheet-friendly tab-separated values (TSV) files.
/* OPTM Report -> TSV
The script below takes reports generated by the Organ Procurement and Transplantation
Network website and converts them into spreadsheet-friendly tab-separated values (TSV) files.
Instructions:
1. Create an advanced data report at https://optn.transplant.hrsa.gov/converge/LatestData/advancedData.asp. In Step 4, keep the default options ("Counts" + "Portrait").
2. On the results page, open up your browser's console.