Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
🎴

Jordan Orelli jordanorelli

🎴
View GitHub Profile
@jordanorelli
jordanorelli / wc.go
Created November 26, 2011 21:48
exercise 43
package main
import (
"go-tour.googlecode.com/hg/wc"
"strings"
)
func WordCount(s string) map[string]int {
fields := strings.Fields(s)
counts := make(map[string]int)
@jordanorelli
jordanorelli / wiki.go
Created December 3, 2011 23:11
the Go wiki codelab.
package main
import (
"regexp"
"http"
"io/ioutil"
"os"
"template"
)
@jordanorelli
jordanorelli / homework.py
Created December 8, 2011 23:21
some homework assignment for some freshman kid on reddit.
# Given a list of numbers, write in increasing order all the integers you can
# obtain using each number once and any combination of addition,
# multiplication, division, and subtraction.
from itertools import permutations, product
from operator import add, mul, div, sub
solutions = set()
funcs = [add, mul, div, sub]
seeds = [22,71,13,1]
def polish(tokens):
@jordanorelli
jordanorelli / puke.go
Created December 9, 2011 05:08
make Go puke
package main
import (
"fmt"
"time"
"runtime"
)
func tick() {
for {
@jordanorelli
jordanorelli / injection.html
Created December 23, 2011 01:01
I N J E C T I O N
<h1 id="injection" style="opacity: 0.0; text-align: center; width: 120%;">INJECTION</h1>
<script>(function(){
var $injection = $("#injection");
var $parent = $injection.parent().parent();
$parent.children(".message-username").css({opacity: 0.0});
var baseDuration = 2000.0;
$injection.animate({"letter-spacing": 50.0, opacity: 1.0}, baseDuration, "linear");
$injection.animate({"letter-spacing": 100.0, opacity: 0.0}, baseDuration, "linear", function() {
$parent.remove();
});
@jordanorelli
jordanorelli / ghost_circle.html
Created December 23, 2011 03:23
a circle appears and disappears
<script src="static/js/raphael-min.js"></script>
<span id="injection" style="display:none;">&nbsp;</span>
<script>(function() {
var $injection = $("#injection");
var $messageBody = $injection.parent(); // selects the <span> element that the message is written into.
var $username = $messageBody.siblings(".message-username");
$username.html("&nbsp;");
$injection.remove();
var containerId = 'a' + Math.random().toString(36).substring(2);
@jordanorelli
jordanorelli / casper.html
Created December 23, 2011 05:21
casper floats across the screen
<script src="static/js/raphael-min.js"></script>
<span id="injection" style="display:none;">&nbsp;</span>
<script>(function() {
$("#injection").parent().parent().remove();
var paper = new Raphael("content", "100%", "100%");
$(paper.canvas).css({
position: "absolute",
left: 0,
top: 0,
@jordanorelli
jordanorelli / index.html
Created January 1, 2012 18:10
websockets in Go.
<html>
<head>
<title>websockets</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>$(function() {
var conn;
conn = new WebSocket("ws://localhost:8000/echo");
conn.onopen = function(event) {
console.log("WebSocket Connected", event);
};
@jordanorelli
jordanorelli / bass_tuner.ck
Created January 5, 2012 05:35
bass tuner in ChucK
[30.868, 41.204, 55, 73.416, 97.99, 130.813] @=> float pitches[];
SinOsc o => dac;
0.02 => o.gain; // you... will probably want to adjust this depending on your setup.
Hid hi;
HidMsg msg;
1 => int octave;
0 => int device;
2 => int currentFreq;
pitches[currentFreq] => o.freq;
@jordanorelli
jordanorelli / recurly_raw.py
Created January 6, 2012 19:11
recurly API test tool
#!/usr/bin/env python
import requests
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--data', type=argparse.FileType('r'))
parser.add_argument('-X', '--method', default='GET', nargs='?')
parser.add_argument('url')
args = parser.parse_args()