Skip to content

Instantly share code, notes, and snippets.

@elliottcordo
elliottcordo / intro_to_redis
Created August 26, 2014 15:32
Intro to Redis
127.0.0.1:6379> sadd rl1 matt
127.0.0.1:6379> sadd rl1 ben
127.0.0.1:6379> sadd rl1 judy
127.0.0.1:6379> smembers rl1
1) "judy"
2) "ben"
3) "matt"
@elliottcordo
elliottcordo / gist:59d3c90b158331fe6ed7
Created August 13, 2014 20:21
python-redshift-pandas-statistics
import sys
import logging
import psycopg2
import pandas as pd
import pandas.io.sql as sqlio
import ConfigParser
import argparse
import statistics
from pandas import pivot_table, crosstab
from datetime import datetime
@elliottcordo
elliottcordo / redis-timeseries-zet
Created August 8, 2014 11:59
storing and working with timeseries in a redis zset
127.0.0.1:6379> zadd mts-123456 20140302 5.6
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140301 7
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140304 3
(integer) 1
127.0.0.1:6379> zadd mts-123456 20140303 2.7
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE mts-123456 20140301 20140302
1) "7"
@elliottcordo
elliottcordo / gist:9bfd44c67863d5cfb250
Last active August 29, 2015 14:03
neo4j rest client example
##http://neo4j-rest-client.readthedocs.org/en/latest/info.html
import string
from neo4jrestclient.client import GraphDatabase
gdb = GraphDatabase("http://localhost:7474/db/data/")
items = open("/Users/elliottcordo/Downloads/ml-100k/u.item")
for row in items:
row = filter(lambda x: x in string.printable, row) #there are special characters that will screw things up
@elliottcordo
elliottcordo / mahout_to_redis.pig
Last active August 29, 2015 13:57
output transform
--item sim
REGISTER '/home/hduser/libs/pig-redis.jar';
raw = LOAD '/user/movie_lens_rec_item_similarity'
USING PigStorage('\t') as (item1:chararray, item2:chararray, rating:chararray);
exp_tuple = FOREACH raw GENERATE item1, TOTUPLE(item2, rating);
STORE exp_tuple INTO 'dummy' USING com.hackdiary.pig.RedisStorer('zset','192.168.56.1');