Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
@binarytemple
binarytemple / trying.to.foldl.mixed.list.to.string.md
Last active August 29, 2015 14:06
Erlang equivalent of Java toString method.

This works, simple fold left string accumulator

5: lists:foldl(fun(_X, Count) ->
                      lists:append(Count, _X)
               end,
               "",
               ["ac","cu","m","ul","at","e"])
-> "accumulate"
@binarytemple
binarytemple / gist:509e2d52d92d7ee5922f
Created September 24, 2014 12:36
List all riak buckets to a file
List all buckets to a file
```
file:write_file("/tmp/buckets.txt",
io_lib:format("~p.~n", [
[ riak_core_bucket:get_bucket(X) || X <- [riak_core_ring:get_buckets(element(2,riak_core_ring_manager:get_my_ring()))] ]
])
).
17> io_lib:write("1").
[91,["49"],93]
18>
18>
18> io_lib:write("1") ++ io_lib:write(2).
[91,["49"],93,50]
19> io_lib:write("1") ++ io_lib:write(2) ++ "".
[91,["49"],93,50]
echo "Data load start time: $(date +%s)"
for i in {1..100}
do
curl -XPOST http://localhost:10018/riak/some_bucket -d "$RANDOM" -H "X-Riak-Index-Timestamp_int: $(date +%s)" -H "Content-Type: text/plain"
sleep 0.5
done
echo "Data load end time: $(date +%s)"
echo "Running MapReduce"
curl -XPOST http://localhost:10018/mapred -H "Content-Type: application/json" -d '
@binarytemple
binarytemple / foldl and foldr - basic examples.markdown
Created September 29, 2014 20:29
foldl and foldr - basic examples
(dev1@127.0.0.1)45> lists:foldl(fun(A,B)-> Ret = A + B,  io:format("intermediate=~p~n",[Ret]),Ret  end, 0, [1,2,3]).
intermediate=1
intermediate=3
intermediate=6
6
(dev1@127.0.0.1)46&gt; lists:foldr(fun(A,B)-&gt; Ret = A + B, io:format("intermediate=~p~n",[Ret]),Ret end, 0, [1,2,3]).
@binarytemple
binarytemple / multi backend riak 2.0 config.txt
Last active August 29, 2015 14:07
multi backend riak 2.0 config and secondary indexing (2i)
storage_backend = multi
multi_backend.bitcask_multi.storage_backend = bitcask
multi_backend.bitcask_multi.bitcask.data_root = "./data/bitcask_multi"
multi_backend.leveldb_multi.storage_backend = leveldb
multi_backend.leveldb_multi.leveldb.data_root = "./data/leveldb_multi"
multi_backend.default = bitcask_multi
@binarytemple
binarytemple / Riak Replication MDC.markdown
Last active August 29, 2015 14:07
Riak Replication MDC
dev/dev3/bin/riak-admin cluster join dev1@127.0.0.1
dev/dev2/bin/riak-admin cluster join dev3@127.0.0.1
dev/dev1/bin/riak-admin cluster join dev2@127.0.0.1
dev/dev1/bin/riak-admin cluster join dev3@127.0.0.1
dev/dev3/bin/riak-admin cluster join dev2@127.0.0.1
dev/dev3/bin/riak-admin cluster plan
dev/dev3/bin/riak-admin cluster commit
dev/dev4/bin/riak-admin cluster join dev5@127.0.0.1
dev/dev6/bin/riak-admin cluster join dev4@127.0.0.1
@binarytemple
binarytemple / profiling.ansible.riak.module.markdown
Last active August 29, 2015 14:07
Profiling ansible riak module

Ansible Riak module modified with profiling (outputs info to /tmp dir):here

Results of testing it:here

Script to pull down /tmp dirs from Vagrant:here

Clear the old stats from the vagrant machines:here

Remove riak from the vagrant machines:here

sudo yum install R
./basho_bench ./examples/riakc_pb.devrel.config
sudo make results
sudo make results
ec2-metadata | grep public-hostname
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.