Skip to content

Instantly share code, notes, and snippets.

View s2tephen's full-sized avatar

Stephen Suen s2tephen

View GitHub Profile
@s2tephen
s2tephen / scrape.py
Created May 18, 2014 20:56
Cross-referencing MS clinical trials as listed on https://neuinfo.org and medical papers on http://www.ncbi.nlm.nih.gov/pubmed
import os, csv, urllib2, re, mechanize
from BeautifulSoup import BeautifulSoup
# initialize variables
rows = [];
INPUT_FILE = 'combined.csv'
OUTPUT_FILE = 'new.csv'
# get all clinical trial ids, store rows for later
if os.path.isfile(INPUT_FILE):
@s2tephen
s2tephen / autogenius
Created August 9, 2014 20:22
Autoplay/loop RapGenius album streams e.g. http://genius.com/albums/Watsky/All-you-can-do
$.each(mejs.players, function(i, p) {
p.media.onended = function() {
mejs.players[(i == mejs.players.length - 1 ? 0 : i + 1)].play()
}
});
@s2tephen
s2tephen / binnify.js
Created April 21, 2016 16:27
Turn an array of integers (1, 2, 3, 4, 7, 9, 10) into a string of bins (1-4, 7, 9-10)
var binnify = function(arr) {
var output = [];
var bin_string = (arr) => (arr.length == 1) ? `${arr[0]}` : `${arr[0]}-${arr[arr.length - 1]}`;
var bin_start = 0;
for (var i = 1; i < arr.length; i++) {
if (arr[i] != arr[i - 1] + 1) {
output.push(bin_string(arr.slice(bin_start, i)));
bin_start = i;
}
}
@s2tephen
s2tephen / cyclinglink.md
Last active November 14, 2016 03:26
cyclinglink for Twine 2 (Harlowe)
@s2tephen
s2tephen / file1.md
Created August 22, 2017 22:03
Multiple file test

Hello world!