Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephen Suen s2tephen

View GitHub Profile
@s2tephen
s2tephen / file1.md
Created Aug 22, 2017
Multiple file test
View file1.md

Hello world!

@s2tephen
s2tephen / cyclinglink.md
Last active Nov 14, 2016
cyclinglink for Twine 2 (Harlowe)
View cyclinglink.md
@s2tephen
s2tephen / binnify.js
Created Apr 21, 2016
Turn an array of integers (1, 2, 3, 4, 7, 9, 10) into a string of bins (1-4, 7, 9-10)
View binnify.js
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;
}
}
View autogenius
$.each(mejs.players, function(i, p) {
p.media.onended = function() {
mejs.players[(i == mejs.players.length - 1 ? 0 : i + 1)].play()
}
});
@s2tephen
s2tephen / scrape.py
Created May 18, 2014
Cross-referencing MS clinical trials as listed on https://neuinfo.org and medical papers on http://www.ncbi.nlm.nih.gov/pubmed
View scrape.py
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):