Skip to content

Instantly share code, notes, and snippets.

View blinkov's full-sized avatar

Ivan Blinkov blinkov

View GitHub Profile
@blinkov
blinkov / tpl_bench.erl
Created March 23, 2012 12:08
Mustache.erl vs Walrus benchmark
-module(tpl_bench).
-export([run/0]).
%% Mustache.erl: https://github.com/mojombo/mustache.erl
%% Walrus: https://github.com/devinus/walrus
%%
%% Sample results:
%%
%% Mustache ---
%% Total time: 5.2954s
%% Mean render time: 0.5295ms
@blinkov
blinkov / riak_solr_client.erl
Created April 3, 2012 12:44
Riak Solr Client
-module(riak_solr_client).
-author("Ivan Blinkov <ivan@blinkov.ru>").
%% WARNING: Not yet tested in production, use with care.
%%
%% This module provides access to sort and limit/offset features of Riak
%% accessible only via Solr interface.
%%
%% Supposed to be used with conjunction with:
%% https://github.com/basho/riak-erlang-client
@blinkov
blinkov / jquery.favicon.js
Created April 6, 2012 15:22
jQuery Favicon Plugin
/**
* jQuery Favicon plugin
* http://hellowebapps.com/products/jquery-favicon/
*
* Copyright (c) 2010 Volodymyr Iatsyshyn (viatsyshyn@hellowebapps.com)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*
@blinkov
blinkov / uppercase_precommit_hook.erl
Created April 19, 2012 18:30
Uppercase Precommit Hook
-module(uppercase_precommit_hook).
-export([uppercase_key/1, uppercase_value/1]).
uppercase_key(Object) ->
riak_object:new(riak_object:bucket(Object),
string:to_upper(riak_object:key(Object)),
riak_object:get_value(Object),
riak_object:get_metadata(Object)
).
@blinkov
blinkov / event_server.erl
Created October 28, 2012 15:07
RabbitMQ Erlang Example
-module(event_server).
-behaviour(gen_server).
-author("Ivan Blinkov <ivan@blinkov.ru>").
%% --------------------------------------------------------------------
%%
%% Basically it just implements a publish/subscribe pattern for SockJS
%% using a single fanout RabbitMQ exchange as a message bus.
%%
%% Eventually got it all replaced with https://github.com/blinkov/sockjs-pubsub
@blinkov
blinkov / riak.erl
Created November 12, 2012 20:34
Riak Increment Example
-module(riak).
-author("Ivan Blinkov <ivan@blinkov.ru>").
-export([incr/2]).
-define(COUNTERS_BUCKET,<<"counters">>).
incr(Pid, Key) ->
{ok, Object} = riakc_pb_socket:put(Pid,
riakc_obj:new(?COUNTERS_BUCKET, Key, <<>>),
@blinkov
blinkov / riak.erl
Created November 12, 2012 20:49
Erlang Multiget Example
-module(riak).
-author("Ivan Blinkov <ivan@blinkov.ru>").
-export([multiget/3]).
multiget(Pid, Bucket, Keys) ->
case riakc_pb_socket:mapred(Pid,
[{Bucket, Key} || Key <- Keys],
[
{reduce,