Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am gmuller on github.
  • I am gmuller (https://keybase.io/gmuller) on keybase.
  • I have a public key ASAQ5tHQ-Uelb49_By3T66258Flj_gCU6fjkKB2dAQ3skwo

To claim this, I am signing this object:

location_code
route_code
route_seq
address
city
state
zip
location_dir
meter_code
meter_type_code
@gmuller
gmuller / gist:3772860
Created September 23, 2012 19:59
Clojure Sleeping Barber Solution
(defn new-q [size] (java.util.concurrent.LinkedBlockingQueue. size))
(defn offer!
"adds x to the back of queue q"
[q x] (.offer q x) q)
(defn take!
"takes from the front of queue q. blocks if q is empty"
[q] (.take q))
@gmuller
gmuller / SieveOfEratosthenes.java
Created June 15, 2012 00:45 — forked from gresrun/redisBitSetTests.java
Going back and forth between BitSet and redis bit sets in Java
import java.util.BitSet;
import redis.clients.jedis.Jedis;
public class SieveOfEratosthenes {
private static String sieveSetKeyCorrected = "correct_sieve";
private static String sieveSetKeyDefaultJava = "wrong_sieve";
private static String spoolSieve = "sieve_set_bits";
@gmuller
gmuller / redisBitSetTests.java
Created May 20, 2012 16:31
An attempt to understand byte and bit ordering in redis bitsets
import java.util.BitSet;
import redis.clients.jedis.Jedis;
public class SieveOfEratosthenes {
/**
* @param args
*/
public static void main(final String[] args) {
@gmuller
gmuller / SieveOfEratosthenes.java
Created April 23, 2012 01:06
Simple prime number generator in java
import java.util.BitSet;
public class SieveOfEratosthenes {
/**
* @param args
*/
public static void main(final String[] args) {
final int length = 2000000;
final BitSet sieve = new BitSet(length);
@gmuller
gmuller / primeFactors.js
Created March 31, 2012 13:27
node script to get prime factors of a number. Used to solve project euler problem #3
#!/usr/local/bin/node
/*
* Simple Node Script to prime factors of a number
*/
var argv = process.argv;
if (argv.length != 3) {
console.log("Please enter a number to factor");
process.exit(1);
@gmuller
gmuller / getValueAtLocation.rb
Created October 4, 2011 03:06
Another solution for the algorithm problem
def getValue(x, y)
return 1 if x == y
return 0 if x < 0 || y < 0 || y > x
return getValue(x-1, y-1) + getValue(x-1, y)
end
@gmuller
gmuller / algorithmsolution.rb
Created September 29, 2011 15:48
Simple recursive function for an algorithm question I had.
def getValueByLocation(x, y)
if x < 0 || y < 0
return nil
end
if x == y || y == 0
return 1
end
getValue(x - 1, y - 1) + getValue(x - 1, y)
end
@gmuller
gmuller / midi2freq.c
Created March 3, 2011 15:15
C Code snippet to generate midi to freq, and vice versa
#include <stdio.h>
#include <math.h>
int main(){
double semitone_ratio, c0, c5, frequency, fracmidi;
int midinote = 73;
semitone_ratio = pow(2, 1/12.0);
c5 = 220.0 * pow(semitone_ratio, 3);
c0 = c5 * pow(0.5, 5);