Skip to content

Instantly share code, notes, and snippets.

public class RedisQueue {
protected Log log = LogFactory.getLog(RedisQueue.class);
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost");
String queueName = "test";
boolean lifo = false;
//how long to keep keys around to verify uniqueness.
//default to 2 hours
@dustismo
dustismo / gist:1184051
Created August 31, 2011 16:54
javascript ISO date parser
/**
* Parses an iso date.
*
* works with most (all?) iso format variations
* 2011-04-25T20:59:59.999-07:00
* 2011-04-25T20:59:59+07:00
* 2011-04-25T20:59:59Z
*
*/
Trendrr.parseISODate = function(string) {
@dustismo
dustismo / gist:1215167
Created September 13, 2011 21:05
Convert Scribe oauth request to a HttpUriRequest
OAuthRequest oauthrequest = new OAuthRequest(Verb.GET, "https://api.twitter.com/1/account/verify_credentials.xml");
service.signRequest(accessToken, oauthrequest);
//now convert request to httpclient request.
DefaultHttpClient client = new DefaultHttpClient();
HttpUriRequest request = null;
if (oauthrequest.getVerb() == Verb.GET) {
@dustismo
dustismo / gist:2891354
Created June 7, 2012 20:28
Install ZeroMQ java on ubuntu
sudo add-apt-repository ppa:chris-lea/zeromq
sudo add-apt-repository ppa:chris-lea/libpgm
sudo apt-get update
sudo apt-get install libzmq-dev libtool autoconf automake dpkg-dev debhelper libpgm-dev
sudo wget https://github.com/zeromq/jzmq/tarball/master
sudo tar -xzf master
sudo rm master
sudo cd zeromq*
sudo automake --add-missing
sudo autoreconf
@dustismo
dustismo / gist:5986631
Created July 12, 2013 18:22
How to have a clean exit from golang
killchan := make(chan os.Signal, 2)
signal.Notify(killchan, os.Interrupt, syscall.SIGTERM)
// wait for kill signal
<- killchan
log.Println("Kill sig!")
//do clean up
//now exit
os.Exit(0)
@dustismo
dustismo / gist:6203329
Last active July 22, 2024 18:51
How to install leveldb on ubuntu
sudo apt-get install libsnappy-dev
wget https://leveldb.googlecode.com/files/leveldb-1.9.0.tar.gz
tar -xzf leveldb-1.9.0.tar.gz
cd leveldb-1.9.0
make
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include