Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
drewkerrigan / README.md
Created December 10, 2013 21:45
Riak CRDT Demo

Erlang

Install Erlang R16B02 using kerl

curl -O https://raw.github.com/spawngrid/kerl/master/kerl; chmod a+x kerl

Create ~/.kerlrc

basho-samurai:riak andrewkerrigan$ dd if=/dev/zero of=/tmp/output bs=25k count=1k
1024+0 records in
1024+0 records out
26214400 bytes transferred in 0.043722 secs (599567916 bytes/sec)
basho-samurai:riak andrewkerrigan$ for i in {1..10}; do time curl -X PUT localhost:8098/riak/foo/a --data-binary @/tmp/output > foo; done
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 25.0M 0 0 100 25.0M 0 54.7M --:--:-- --:--:-- --:--:-- 54.8M
real 0m0.479s
@drewkerrigan
drewkerrigan / README.md
Last active December 30, 2015 07:19
Install Erlang R16B02 using Kerl

You can install different Erlang versions in a simple manner with the kerl script. This is probably the easiest way to install Erlang from source on a system, and typically only requires a few commands to do so. Install kerl by running the following command:

curl -O https://raw.github.com/spawngrid/kerl/master/kerl; chmod a+x kerl

To compile Erlang as 64-bit on Mac OS X, you need to instruct kerl to pass the correct flags to the configure command. The easiest way to do this is by creating a ~/.kerlrc file with the following contents:

KERL_CONFIGURE_OPTIONS="--disable-hipe --enable-smp-support --enable-threads
@drewkerrigan
drewkerrigan / .emacs
Created December 3, 2013 15:49
Emacs custom functions and config.
;;;; .emacs Customizations, Functions, and Packages
;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;; Packages and Initialization
;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(require 'package)
;; Add the original Emacs Lisp Package Archive
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
@drewkerrigan
drewkerrigan / .emacs
Last active December 29, 2015 08:29
Aquamacs / Terminal .emacs for Mac OS X
;;;; .emacs Customizations, Functions, and Packages
;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;; Packages and Initialization
;;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;;; Color Theme (http://download.savannah.gnu.org/releases/color-theme/)
(add-to-list 'load-path "~/.emacs.d/packages/color-theme/")
(require 'color-theme)
(color-theme-initialize)
@drewkerrigan
drewkerrigan / README.md
Last active December 27, 2015 05:19
Converts JSON of a specific format to CSV

####Converts JSON of the format

[
  {
    "target": "target1", 
    "datapoints": [
      [val1,timestamp1],
       ...
 [valN,timestampN]]
@drewkerrigan
drewkerrigan / INSTALL.md
Last active December 24, 2015 15:29
Installing Riak 2.0pre2 from source

Download and build

wget https://github.com/basho/riak/archive/riak-2.0.0pre2.tar.gz
tar -zxvf riak-2.0.0pre2.tar.gz
cd riak-riak-2.0.0pre2
make rel
cd rel/riak
gimme_a_client_from(Context) when Context#ctx.client == undefined ->
{ok, Client} = riakc_pb_socket:start_link(?RIAK_NAME, ?RIAK_PB_PORT)},
Context#ctx{client = Client};
gimme_a_client_from(Context) -> Context.
@drewkerrigan
drewkerrigan / zombie.rb
Created September 5, 2013 00:40
fetch keys and get objects with pagination
def fetch_with_pagination(keys, start = 1, count = 50)
zombies = []
keys = [] unless keys
result_count = 1
keys.each_with_index do |zombie_key, i|
break if result_count > count
next if (i + 1) < start
data = @client['zombies'].get(zombie_key).data
@drewkerrigan
drewkerrigan / server.rb
Created September 5, 2013 00:37
query endpoints
get '/query/zip3/:zip' do
zip = params[:zip]
zip3 = zip[0, 3]
zips = zip3_idx.get_index(zip3)
results = zips.members.to_a
if zip.length > 3
results = results.select { |item| item.start_with? zip }