Skip to content

Instantly share code, notes, and snippets.

@corajr
corajr / index.html
Created April 4, 2012 03:56
Message Forum Tree
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Node-Link Tree</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<link type="text/css" rel="stylesheet" href="tree.css"/>
</head>
<body>
<div id="buttons">
<button class="depth first active" onclick="update(false)">Depth</button>
@corajr
corajr / compare.py
Last active December 20, 2015 11:49
Genre classification test
#!/usr/bin/python
# -*- coding: utf-8 -*-
import csv
import os
from collections import defaultdict, Counter
comparisons = defaultdict(dict)
true_genres = {}
test_genres = {}
@corajr
corajr / gist:8888071
Created February 8, 2014 18:39
Hide link on MTurk
<!-- paste this at the top of your HIT's source -->
<script type="text/javascript">
function turkGetParam(name) {
name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
var regexS = "[?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) {
return "";
@corajr
corajr / myscript.js
Created February 27, 2014 00:54
Marianna Kreidler's "Jailbreak the Binary"
var searchFor = /\bshe\b|\bhis\b|\bher\b|\bhim\b|\bhe\b|\bms\b|\bmrs\b|\bmr\b|woman|\bman\b|women|\bmen\b|\bfemale|\bmale\b|\bmales\b|\bgirl\b|\bboy\b|\bgirls\b|\bboys\b|\bgirly\b|\bboyish\b|\bgirlhood\b|\bboyhood\b|\bgirlfriend|\bboyfriend|\bwife|\bhusband\b|\bwives\b|\bhusbands\b|daughter|\bson\b|\bsons\b|\bsister|\bbrother|\bmother|grandmother|godmother|stepmother|father|\baunt\b|\buncle\b|\baunts\b|\buncles\b|\bniece\b|\bnephew\b|\bnieces\b|\bnephews\b|\bherself\b|\bhimself\b|\blady|\bladies\b|\bgentlemen\b|\bgentleman\b|\bmom\b|\bdad\b|\bmoms\b|\bdads\b|mommy|daddy|mommies|daddies|ladiez|\bmenz\b|\bmanly\b|\bmanliness\b|\bmanhood\b|\bmankind\b|\bguy\b|\bguys\b|\bdude\b|\bdudes\b|\bdudely\b|\bmaternity\b|\bpaternity\b|\bmaternal\b|\bpaternal\b|\bmatroniz|\bpatroniz|\bmatronize|\bpatronize|klansman|airman|airmen|alderman|aldermen|anchorman|anchormen|assemblyman|assemblymen|bogeyman|bogeymen|bondsman|bondsmen|businessman|businessmen|cameraman|cameramen|caveman|cavemen|chairman|clergyman|congressman|congress
@corajr
corajr / Million Song Example.ipynb
Last active August 29, 2015 13:56
Million Song Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corajr
corajr / install-nix.sh
Created December 20, 2014 21:26
Install Nix on Mac OS X 10.10 (Yosemite)
# current as of 2014-12-20
# mostly derived from https://nixos.org/wiki/Nix_on_OS_X#Using_the_Testing_Branch
curl https://nixos.org/nix/install | sh
NIXDIR=~/nixtest # or wherever you like
mkdir -p $NIXDIR
cd $NIXDIR
git clone https://github.com/joelteon/nixpkgs.git # this is the yosemite branch
nix-channel --remove nixpkgs
cd ~/.nix-defexpr
@corajr
corajr / builder.sh
Created December 21, 2014 20:21
SecurityTool dummy package
source $stdenv/setup
mkdir -p $out/bin
cp /usr/bin/security $out/bin
@corajr
corajr / put_on_tv.sh
Last active August 29, 2015 14:13
Serve a movie file to the Raspberry Pi
put_on_tv() {
IP=$(ipconfig getifaddr en1)
PORT=$(($RANDOM%63000+2001))
FILENAME=$(basename "$*")
FILEEXT=${FILENAME##*.}
ln -s "$1" $TMPDIR/$PORT.$FILEEXT
(
cd $TMPDIR
python -m SimpleHTTPServer $PORT &
ssh -t livingroom_pi "omxplayer -o hdmi -r http://$IP:$PORT/$PORT.$FILEEXT"
@corajr
corajr / 1-preferences.png
Last active August 29, 2015 14:25
AAS21 Zotero Instructions
1-preferences.png
@corajr
corajr / diff.html
Last active August 29, 2015 14:28
Two ways to filter a list in Haskell
<p>What do two different ways of filtering a list compile to?</p>
<p>(Example: take a list of tuples (a,b), and return a list of a for every (a,b) where b > 1.)</p>
<table>
<tr>
<th>
`map fst . filter ((>1) . snd)`
</th>
<th>