Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
class Node {
public:
int value;
Node* left;
Node* right;
Node() {
left = NULL;
require 'net/http'
require 'uri'
require 'json'
languages = ["java", "c++", "c", "perl", "ruby", "python", "javascript", "html", "css",
"scala", "xml", "xslt", "xquery", "php", "actionscript", "flash", "flex",
"vbscript", "applescript", "erlang", "objective-c", "smalltalk", "haskell",
"c#", "boo", "f#", "go", "processing", "arduino", "pd", "qc", "vimscript",
"as3", "assembly", "sh", "obj-c", "sql", "coldfusion", "lex", "yacc",
"scheme", "lisp", "bourne", "awk", "tcl", "d", "ocaml", "elisp", "clojure",
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.io.Closeable;
/**
* @author Toby
*/
public abstract class ThreadPipeIterator<T> implements Iterator<T>, Closeable {
@toluju
toluju / gist:561592
Created September 1, 2010 23:51
Generic Exceptions suck
public interface Request<R, E extends Exception> {
public R process() throws E;
}
public class Processor {
public <R, E extends Exception> R process(Request<R, E> request) throws E {
E lastException = null;
for (int x = 0; x < retries; ++x {
try {
return request.process();
@toluju
toluju / delicious2google.rb
Created December 17, 2010 01:02
Delicious is shutting down, so here's a script to load the exported delicious bookmarks into Google Bookmarks.
require 'net/http'
require 'uri'
require 'cgi'
text = "<html><head><title>Delicious2Google</title></head><body>" +
"<h1>Upload</h1>" +
"<form action='https://www.google.com/bookmarks/mark?op=upload&zx=#{rand(65535)}' method='POST'>" +
"<input type='submit'/><input type='hidden' id='data'></form>" +
"<textarea id='xml' style='display:none'>\n<bookmarks>"
@toluju
toluju / barbershop.scala
Created January 18, 2011 20:40
A better scala barbershop simulator.
import scala.actors.Actor
import scala.actors.Actor._
import scala.util.Random
import scala.collection.{immutable, mutable}
val rand = new Random()
case class Customer(id: Int) {
var shorn:Boolean = false
}