Skip to content

Instantly share code, notes, and snippets.

(* a simple echo server in ocaml
* -----------------------------
* uses a high level networking function, similar to SocketServer
* in python, called 'establish_server', see here:
* http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#VALestablish_server
*)
(*
our echo function
in -> out -> unit
@teeler
teeler / gist:961659
Created May 8, 2011 20:20
For Adam, like in the movies.
mkdir /tmp/poo
wget -q -O - http://some/mp3 | tee /tmp/poo | od
# In another shell,
mplayer - < /tmp/poo
@teeler
teeler / textify.js
Created May 24, 2011 20:43
Textify
// via http://textify.it/
/**
* @author Hakim El Hattab
*
* Recreates bitmap images using HTML text. Images are
* drawn onto a canvas element so that the pixels can
* be read. Letters, with colors matching the image pixels,
* are then placed at random locations on the screen.
*/
@teeler
teeler / d3-stream.html
Created September 6, 2011 16:12
d3 stream weirdness
<!DOCTYPE html>
<html>
<head>
<title>Streamgraph</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1"></script>
</head>
<body>
<div id="chart">
</div>
@teeler
teeler / stream.html
Created September 7, 2011 18:36
Stream demo
<!DOCTYPE html>
<html>
<head>
<title>Streamgraph</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.js?1.29.1"></script>
<script type="text/javascript" src="tech.js"></script>
<link type="text/css" rel="stylesheet" href="http://mbostock.github.com/d3/ex/button.css"/>
<link type="text/css" rel="stylesheet" href="http://mbostock.github.com/d3/ex/stream.css"/>
library(doRedis)
library(doRedis)
registerDoRedis()
@teeler
teeler / wtf.R
Created March 14, 2012 20:06
R WTF
# Ok, so appending items to lists.
# I'm fine with this.
f <- list()
f <- c(f, 1)
f <- c(f, 2)
f <- c(f, 3)
# Ok, lets try something fancier, lists of lists.
var moment = require('moment');
var request = require('request');
exports.formatDate = function(format, date) {
};
// Takes NDBC Buoy ID, and returns
// series of readings
var fetchBuoy = function(buoyId) {
request('http://www.ndbc.noaa.gov/data/5day2/' + buoyId + '_5day.txt', function(err, response, body){
// Takes NDBC Buoy ID, and returns
// series of readings
// Just to generate a URL.
var BuoyURL = function(buoyId) {
return 'http://www.ndbc.noaa.gov/data/5day2/' + buoyId + '_5day.txt';
};
exports.parseBuoyData = function(buoy) {