Skip to content

Instantly share code, notes, and snippets.

View jsvine's full-sized avatar

Jeremy Singer-Vine jsvine

View GitHub Profile
@jsvine
jsvine / visidata-pipx-installation.md
Last active May 28, 2024 07:18
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 / 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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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=' \

Keybase proof

I hereby claim:

  • I am jsvine on github.
  • I am jsvine (https://keybase.io/jsvine) on keybase.
  • I have a public key whose fingerprint is 8397 1E4B 55BD 5519 D5B8 7922 E6D8 761D 9F56 510A

To claim this, I am signing this object:

@jsvine
jsvine / installations.md
Last active May 10, 2021 13:43
First things to install on a new Mac OSX [WIP]

An Open-Source Thank You

In late October, the WSJ published Waste Lands, an interactive database I helped build and report. Waste Lands draws upon thousands of public records and other sources to trace the history of hundreds of factories and laboratories the government recruited to help develop nuclear weapons during the build-up to the Cold War.

Building the database took considerable time and effort. But it would have been immeasurably more difficult and time-consuming — if not nearly impossible — without the fistfuls of open-source code we were able to rely upon:

@jsvine
jsvine / exemplify.js
Created November 13, 2013 22:33
A bare-bones helper for creating simple demos/tutorials. See example usage here: http://www.jsvine.com/gmap-button/demo/
var exemplify = function (fn, code_el) {
fn.call(fn);
var str = fn.toString();
var lines = str.split("\n").slice(1, -1);
var start_index = lines[0].match(/[^\s].*$/).index;
var trimmed = lines.map(function (x) {
return x.slice(start_index);
}).join("\n");
code_el.innerHTML = trimmed;
};
@jsvine
jsvine / rolling-average.js
Last active December 27, 2015 05:09
Just a little helper function. Depends on, and hooks into, underscore.
(function () {
var root = this;
var sum = function (arr) {
return _.reduce(arr, function (m, x) {
return m + x;
});
};
// n: Size of the stack, i.e., how far to look back