Skip to content

Instantly share code, notes, and snippets.

@loucash
loucash / scrooge-coin-main.java
Created February 19, 2018 14:42 — forked from mentlsve/scrooge-coin-main.java
Coursera - Programming Assignment: Scrooge Coin - Simple Main Class
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.math.BigInteger;
import java.security.*;
public class Main {
public static void main(String[] args) throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
// Crypto setup
@loucash
loucash / netutil.erl
Created January 4, 2017 15:11 — forked from jcomellas/netutil.erl
Functions to obtain IP addresses from subnets in Erlang.
-module(netutil).
-author('Juan Jose Comellas <juanjo@comellas.org>').
%% API
-export([get_local_ip_from_subnet/1, get_ip_from_subnet/2,
cidr_network/1, cidr_netmask/1]).
%% @type ipv4() = {integer(), integer(), integer(), integer()}
@loucash
loucash / keybase.md
Created November 2, 2016 22:20
keybase.md

Keybase proof

I hereby claim:

  • I am loucash on github.
  • I am loucash (https://keybase.io/loucash) on keybase.
  • I have a public key ASDa-yFinQBgkV6HvNNjkKmZpTPTkPYXoE96_WrO-LbBeQo

To claim this, I am signing this object:

@loucash
loucash / API.md
Created December 15, 2015 15:24 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@loucash
loucash / test.erl
Last active October 27, 2015 13:04
-module(test).
-export([test/0]).
-define(BUCKET, <<"foo">>).
test() ->
Key = rand_binary(10),
Idx = rand_int(10),
test(Key, Idx).
@loucash
loucash / gist:dbb9222d01e127362172
Created October 16, 2015 09:18 — forked from russelldb/gist:7596268
riak-erlang-client counter usage
1> {ok, Pid} = riakc_pb_socket:start_link("localhost", 8087).
{ok,<0.35.0>}
2> riakc_pb_socket:set_bucket(Pid, <<"foo">>, [{allow_mult, true}]).
ok
3> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, 1).
ok
4> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, 3).
ok
5> riakc_pb_socket:counter_incr(Pid, <<"foo">>, <<"bar">>, -2).
ok
@loucash
loucash / gist:610d71f28550271bb4f0
Last active August 29, 2015 14:17
riak_core_vnode tick test
$ git diff
diff --git a/test/mock_vnode.erl b/test/mock_vnode.erl
index 44dbe6a..d5c66e2 100644
--- a/test/mock_vnode.erl
+++ b/test/mock_vnode.erl
@@ -42,6 +42,7 @@
-export([init/1,
handle_command/3,
terminate/2,
+ handle_tick/1,
@loucash
loucash / perf.erl
Last active August 29, 2015 14:10
dispcount hash vs round_robin
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname perf -pa ebin -pa test
-define(RESOURCES, 100).
-define(RUNS, 10000).
-define(DELAY, 200).
-define(ETS, test).
main(_) ->
@loucash
loucash / perf.erl
Created November 25, 2014 15:57
erlang:phash2 vs ets:update_counter
$  ./perf.erl
Result shows how long did it take to run 10000 times
Hash, 1 process: 19960ms
Hash, 10 processes: 78088ms
Hash, 100 processes: 1135032ms
Ets, 1 process: 19220ms
Ets, 10 processes: 92567ms
Ets, 100 processes: 1152708ms