Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benjic
benjic / biz.go
Last active September 9, 2015 04:40
A simple implementation of the Adapter Pattern.
package widgets
import "fmt"
// A IBiz is any type that implements the Baz function
type IBiz interface {
Baz()
}
// A Biz is our non client supported type
public class List {
private static final int INITIAL_ARRAY_SIZE = 6;
private static final char NULL_CHAR = '\u0000';
private char[] mBackingStore;
private int mLength;
public List() {
mBackingStore = new char[INITIAL_ARRAY_SIZE];
mLength = 0;
@benjic
benjic / ThreadQueue.java
Created June 24, 2015 02:39
A hookey process queue with max wait time and retry.
import java.util.Queue;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
public class ThreadQueue {
public static final int SECONDS = 1000;
private Queue<Runnable> mProcessQueue;
package bitstring
//GistID: c9e651c9b075fc96e966
// An asynchronous permutation Iterator for bitstrings
// So you want all the permuations of 3 bits choose 2 at a time? Well just
// create this async iterator which produces these bitstrings as there integer
// equivlent.
//
// bspIterator(3,2)
@benjic
benjic / bit_string_iterator.go
Last active August 29, 2015 14:19
Provides a concurrent safe iterator for generating bitstring combinations of given length.
package hamming
// An asynchronous permutation Iterator for bitstrings
// So you want all the permuations of 3 bits choose 2 at a time? Well just
// create this async iterator which produces these bitstrings as there integer
// equivlent.
//
// bspIterator(3,2)
// 011 = 3
// 101 = 5
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}
PASS
BenchmarkConvertA 300000 5625 ns/op
BenchmarkConvertB 300000 5756 ns/op
ok _/home/benjica/exercism/go/raindrops 3.532s
package raindrops
import "fmt"
func Convert(num int) string {
return ConvertCompare(num, "A")
}
func ConvertCompare(num int, compare string) string {