Skip to content

Instantly share code, notes, and snippets.

@benmmurphy
benmmurphy / gist:1189857
Created September 2, 2011 20:40
stratify js
function pause(t) {
waitfor() {
window.setTimeout(resume, t);
}
}
var object = {
pause_then_alert : function() {
pause(1000);
@benmmurphy
benmmurphy / gist:1191381
Created September 3, 2011 15:55
Future
import scala.util.continuations._
import scala.collection.mutable._
class Future {
def await : Unit @suspendable = {
/* .... */
shift { k : (Unit => Unit) =>
}
}
@benmmurphy
benmmurphy / gist:1191571
Created September 3, 2011 18:23
Suspendable Future Implementation for Scala
/* scalac -P:continuations:enable */
import scala.util.continuations._
import scala.collection.mutable._
class Future[A] private (ctx: => A @suspendable) {
private var res:Option[A] = None
def await() : A @suspendable = {
if (res.isEmpty) {
@benmmurphy
benmmurphy / gist:1306071
Created October 22, 2011 14:40
Eclipse Verify Error (20110916-0149)
package sslnpn;
import java.io.IOException;
import org.junit.Test;
public class StackMapTest {
private boolean check;
@benmmurphy
benmmurphy / gist:1519569
Created December 25, 2011 18:19
self replicating erlang program
-module(replicator).
-export([replicator/0]).
replicator() ->
Eval = fun(S, Env) ->
{ok, Scanned,_} = erl_scan:string(S),
{ok,Parsed} = erl_parse:parse_exprs(Scanned),
erl_eval:exprs(Parsed, Env)
end,
@benmmurphy
benmmurphy / gist:1914845
Created February 26, 2012 07:52
level06
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/wait.h>
#include <stdlib.h>
#define CAPACITY (65536)
#define PROGRAM "./level06"
@benmmurphy
benmmurphy / gist:3528321
Created August 30, 2012 13:16
High Ascii In a File
grep $'[\177-\377]' file
@benmmurphy
benmmurphy / riak_stats.sh
Created November 13, 2012 09:48
riak -> librato stats cron job
#!/bin/bash
# * * * * * root /path/to/riak_stats.sh
set -e
SOURCE=$(hostname)
LIBRATO_USERID=""
LIBRATO_TOKEN=""
PREFIX="test.riak"
@benmmurphy
benmmurphy / riak_graphite_stats.sh
Last active October 12, 2015 17:57
riak -> graphite stats cron job
#!/bin/bash
# * * * * * root /path/to/riak_graphite_stats.sh
set -e
SOURCE=$(hostname)
GRAPHITE_PORT=2003
GRAPHITE_SERVER="server"
PREFIX="riak_stats"
STATUS=$(/usr/sbin/riak-admin status)