Skip to content

Instantly share code, notes, and snippets.

View jebu's full-sized avatar

Jebu Ittiachen jebu

View GitHub Profile
@jebu
jebu / zmq_streamer.erl
Created December 1, 2011 06:38
ZMQ Streamer
-module(zmq_streamer).
-behaviour(gen_fsm).
-export([start_link/3, start_link/4]).
%% gen_fsm callbacks
-export([init/1, handle_event/3, handle_sync_event/4, handle_info/3,
terminate/3, code_change/4]).
-export([get_count/1, stop/1]).
-record(state, {zmq_context=undefined, pull_socket=undefined, xrep_socket=undefined, next_cons_identity, count=0}).
-define(SERVER, ?MODULE).
handle_event({set_alarm, {process_memory_high_watermark, Pid}}, State) ->
error_logger:info_msg("*** Process high mark reached ~p ~n", [Pid]),
error_logger:info_msg("*** Backtrace - ~p ~n ", [erlang:process_info(Pid, backtrace)]),
error_logger:info_msg("*** Process info ~p ~n", [erlang:process_info(Pid)]),
{ok, State};
handle_call({lookup_popular_replies, TweetId, AuthorId}, _From, #state{client=Client} = State) ->
% reduce fun to get valid tweet keys in tweet response bucket phase 3
Fun = make_local_fun("fun(O, _) ->
lists:foldl(fun
([LinkedTweet = <<Id:128>>, <<Val:128>>, <<\"reply\">>], Acc) ->
[{{<<\"tweet_responses_bucket\">>, LinkedTweet}, {Id, Val}} | Acc];
({{<<\"tweet_responses_bucket\">>, _}, _} = PreviousPass, Acc) ->
[PreviousPass | Acc];
(_, Acc) ->
Acc
from httplib import HTTP
import location
latitude = 0
longitude = 0
def doLookup(cellId, lac, host = "www.google.com", port = 80):
from string import replace
from struct import unpack
page = "/glm/mmap"
-module(simhash).
-define(HASH_RANGE, 1 bsl 128).
-define(HASH_ACCU, 12).
-define(HASH_WIDTH, 128).
-export([hash_file/1]).
hash_file(File) ->
{ok, Binary} = file:read_file(File),
Tokens = re:split(Binary, "\\W"),
-module(twitter_stream).
-author('jebu@jebu.net').
%%
%% Copyright (c) 2009, Jebu Ittiachen
%% All rights reserved.
%%
%% Redistribution and use in source and binary forms, with or without modification, are
%% permitted provided that the following conditions are met:
%%
%% 1. Redistributions of source code must retain the above copyright notice, this list of