Skip to content

Instantly share code, notes, and snippets.

View dougkeen's full-sized avatar

Doug Keen dougkeen

View GitHub Profile
#!/usr/local/bin/python
import sys
import zlib
import random
import time
import itertools
def sizeof_fmt(num, suffix='B'):
for unit in ['','K','M','G','T','P','E','Z']:
@dougkeen
dougkeen / AdvantageConnectionPool.java
Created October 23, 2012 19:47
AOP connection stuff
package com.agora.advantage;
import org.apache.commons.pool.PoolableObjectFactory;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.advantagecs.connection.WebServerConnection;
@dougkeen
dougkeen / Observable.java
Created September 19, 2012 20:41
Generic observable pattern
package com.dougkeen.util;
import java.util.WeakHashMap;
import org.apache.commons.lang3.ObjectUtils;
public class Observable<T> {
private T value;
private WeakHashMap<Observer<T>, Boolean> listeners = new WeakHashMap<Observer<T>, Boolean>();