Skip to content

Instantly share code, notes, and snippets.

@benstopford
benstopford / SynthIn90Mins.java
Created April 19, 2014 18:32
Java Team's "Synth" from West London Hack Night's "Hack, Code, Build, Make". I say synth in the broadest possible sense. It's a program that makes strange noises
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Collections;
@benstopford
benstopford / PofPrimerGist
Created April 12, 2014 11:36
Example of Pof Internals
package com.benstopford.coherence.bootstrap.morecomplex;
import com.tangosol.io.ReadBuffer;
import com.tangosol.io.pof.*;
import com.tangosol.util.Binary;
import com.tangosol.util.ExternalizableHelper;
import java.io.IOException;
public class PofPrimerGist {
@benstopford
benstopford / gist:9619299
Created March 18, 2014 12:42
Small class to test GC performance
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Benjamin Stopford - 11/09/13
*/
@benstopford
benstopford / PerformanceTimer.java
Last active August 29, 2015 13:56
Very simple performance timing class. This differs from Apache StopWatch in that it includes print formatting and a builder pattern. Good for quick and dirty performance checks.
package com.benstopford.coherence.bootstrap.structures.framework;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static java.util.concurrent.TimeUnit.*;
public class PerformanceTimer {
@benstopford
benstopford / SpotifyBoxpacking.java
Created February 15, 2014 15:21
Hacknight code for creating a spotify playlist for a search term with a desired length (boxpacking algorithm)
package boxpacking;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@benstopford
benstopford / poker-scoring-clojure
Last active December 29, 2015 11:59
Scoring a poker hand in Clojure
(require '[clojure.test :refer :all ])
;flush
(defn flush?
[hand]
(= 1 (count
(distinct
(map first hand)))))
;straight