Skip to content

Instantly share code, notes, and snippets.

View vjache's full-sized avatar

Vyacheslav Vorobyov vjache

View GitHub Profile
@vjache
vjache / PipeForward.kt
Created November 18, 2016 15:11
Pipe forward operator
operator fun <T,T1> ((T) -> T1).unaryPlus(): (T.()->T1) {
val f = this
return {
f(this)
}
}
fun mkStr(t:Int) : String {
return ""
}
@vjache
vjache / codec.erl
Created November 24, 2015 21:27
Encode/Decode problem on Erlang.
-module(codec).
-export([encode/1, decode/1]).
encode(Ss) ->
encode(Ss, "").
encode([], Enc) ->
lists:reverse(Enc);
@vjache
vjache / FlumeAppendBatch
Created March 30, 2015 11:24
Batch append to Flume via Avro API.
appendBatch(SomeDir, Events) ->
ProtoFile = filename:join(SomeDir, "flume.avpr"),
{ok, P} = eavro_rpc_fsm:start_link(Host, Port, ProtoFile),
AvroEvents = encode_events_to_eavro_api_events(Events),
{ok, Result} = eavro_rpc_fsm:call(Conn, appendBatch, _Args = [ AvroEvents ]).
encode_events_to_eavro_api_events(Events) ->
[
[ [ {<<"timestamp">>,
@vjache
vjache / SRB
Last active August 29, 2015 14:07
Deadly simple Shared Ring Buffer in Erlang.
%% Shared Ring Buffer
-module(srb).
-export([new/2, push/2, pop/2, pop/1]).
-compile(export_all).
-record(counters,
{ clock :: non_neg_integer(),
max_size :: non_neg_integer() }).