Skip to content

Instantly share code, notes, and snippets.

class QuickSort {
private int[] numbers;
public static void main(String[] args) {
int[] numbers = {2, 8, 7, 1, 3, 5, 6, 4};
QuickSort q = new QuickSort();
q.sort(numbers);
for (int i : numbers) {
@oscardelben
oscardelben / MergeSort.java
Created May 11, 2014 19:21
MergeSort.java
public class MergeSort {
public static void main(String[] args) {
int[] numbers = {4, 6, 2, 25234, 34, 5};
MergeSort m = new MergeSort(numbers);
m.sort();
for (int i = 0; i < numbers.length; i++) {
System.out.print(numbers[i] + " ");
}
}

ruby-1.9.3-p392 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p392 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

@oscardelben
oscardelben / missionaries.go
Created May 5, 2013 18:12
Some fun implementing a graph search algorithm
package main
import (
"fmt"
)
/*
Problem formulation
initial state: 3 missionaries and 3 cannibals on one side
@oscardelben
oscardelben / server.go
Created May 1, 2013 01:27
The coupons RPC server
package main
import (
"fmt"
"log"
"net"
"net/http"
"net/rpc"
)
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
// Goal: What should this print?
#define FILE_NAME "foo"
void checkFD(int fd);
package main
import (
"fmt"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
@oscardelben
oscardelben / gist:4720399
Created February 6, 2013 04:48
Rack::MD5
require 'digest/md5'
module Rack
# Adds the Content-MD5 entity header which provides a MD5 digest of
# the entity body for integrity check.
class MD5
def initialize app
@app = app
end
require 'rake/testtask'
require 'rake/clean'
# rule to build the extension: this says
# that the extension should be rebuilt
# after any change to the files in ext
file "lib/http-parser/ruby_http_parser.so" =>
Dir.glob("ext/ruby_http_parser/*{.rb,.c}") do
Dir.chdir("ext/ruby_http_parser") do
# this does essentially the same thing
@oscardelben
oscardelben / send_benchamrk.rb
Created December 29, 2012 20:01
Another useless benchmark
require 'benchmark'
puts "*** without send ***"
puts RubyVM::InstructionSequence.compile('"foo" * 3').disasm
puts
puts( Benchmark.measure do
10_000_000.times do
"foo"
end