Skip to content

Instantly share code, notes, and snippets.

@cpatni
cpatni / RateLimit.java
Created March 23, 2011 08:17
Rate Limiting Algorithm
import java.util.concurrent.TimeUnit;
/**
* This is licensed under AGPL 3.0. http://www.gnu.org/licenses/agpl-3.0.html
* @author Chandra Patni
*/
public class RateLimit {
int rate;
String unit;
TimeUnit limit;
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
@cpatni
cpatni / BitSetBenchmark.java
Created November 26, 2011 08:56
Caliper Benchmarks for Analytics using Bitmaps
package blog;
import com.google.caliper.SimpleBenchmark;
import java.util.BitSet;
public class BitSetBenchmark extends SimpleBenchmark{
private BitSet bitSet;
@Override
protected void setUp() {
@cpatni
cpatni / gist:2845109
Created May 31, 2012 18:04
Consistent Hashing bounds
#servers %keys moved to a new bucket
2 48.64999
3 36.77834
4 23.90582
5 19.63112
6 16.63258
7 14.65024
8 11.11595
9 10.38118
10 8.94454