Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
drewkerrigan / gist:4122487
Created November 21, 2012 01:28
Developers Without Phone Snippet
no_email_count = 0
puts "email,full_name"
Developer.bucket.get_index('$bucket', '_').each do |devid|
u = Developer.find(devid).identity
if !u.mobile_number
puts u.email + "," + u.full_name
no_email_count+=1
end
@drewkerrigan
drewkerrigan / gist:4089178
Created November 16, 2012 17:22
Turn demo_service.rb into a web server
# Static files
get '/:file.:ext' do
case :ext
when "css"
content_type 'text/css'
when "js"
content_type 'text/javascript'
when "html"
content_type 'text/html'
@drewkerrigan
drewkerrigan / gist:3932331
Created October 22, 2012 16:18
Rolling Average Tweaks
############## test_example.rb # Changed 5.times to 1.times and back
# start some external clients to add values to the Riak server
# 5.times do |t|
1.times do |t|
pids << fork {
`bundle exec rake example:create_data_points ROW=#{t} CLIENT=local#{t}`
}
end
pids.each do |pid|
Process.waitpid(pid)
1. What's the best way to declare dependencies for erlang? I would have thought using rebar's transitive dependency management would be the way to go... put external dependencies in rebar.config, run 'rebar get-deps && rebar compile' and you're off to the races. But this thread indicates that this could break apps with shared dependencies. If both apps A and B depend on C, and C hoarks, then both apps A and B die, too.
http://stackoverflow.com/questions/11141198/when-to-use-erlang-applicationstart-or-included-applications-and-a-supervisor
2. Assuming that this thread was incorrect, and that rebar dependencies are the way to go, I'm having a teensy problem. I was following Dizzy's 2011 presentation (http://vimeo.com/22700527) and thought, sweet, I'll create a sample app and have it depend on ibrowse (very cool app).
REPRO:
1. make basic app
@drewkerrigan
drewkerrigan / gist:3230007
Created August 1, 2012 19:38
Azure Install Notes
############### Testing Node install.sh
cd
sudo apt-get install git make build-essential libncurses5-dev openssl libssl-dev
git clone git://github.com/basho/basho_bench.git
cd basho_bench
cp examples/riakc_pb.config azure_riakc_pb.config
cd
############### Node 1-N install.sh
cd
@drewkerrigan
drewkerrigan / gist:3092101
Created July 11, 2012 18:11
Azure Riak Setup
Steps to Setup riak / erlang on Ubuntu (Azure):
# Prerequisites
sudo apt-get install git make build-essential libncurses5-dev openssl libssl-dev
# Installing Erlang
wget http://erlang.org/download/otp_src_R14B03.tar.gz
tar zxvf otp_src_R14B03.tar.gz
cd otp_src_R14B03
./configure && make && sudo make install
@drewkerrigan
drewkerrigan / gist:2996398
Created June 26, 2012 15:20
Cassandra CQL Basho Bench Primer
============================= To Clear DB =============================
root@s02:~# ./cqlsh.sh
Connected to basho at localhost:9160.
[cqlsh 2.2.0 | Cassandra 1.1.1 | CQL spec 2.0.0 | Thrift protocol 19.32.0]
Use HELP for help.
cqlsh> use DEMO;
cqlsh:DEMO> truncate test;
cqlsh:DEMO> exit
============================= To Run Insert ===========================
root@s01:~/basho_bench# ./basho_bench softlayer_s07_cassandra_test.config
INFO: Est. data size: 46.57 GB
INFO: Using target s02:9160 for worker 1
INFO: Starting max worker: <0.56.0>
=ERROR REPORT==== 13-Jun-2012::16:10:42 ===
** Generic server <0.57.0> terminating
** Last message in was {call,insert,
["Keyspace1","2260050",
{columnPath,"Standard1",undefined,"col1"},
@drewkerrigan
drewkerrigan / gist:2876196
Created June 5, 2012 16:51
Swift Usage Examples
Execute the following command and make a note of X-Auth-Token. You will need this token to use in all subsequent commands.
curl -v -H 'X-Storage-User: system:root' -H 'X-Storage-Pass: testpass' http://10.80.83.68:8077/auth/v1.0
In the following command examples we are using 'AUTH_tk65840af9f6f74d1aaefac978cb8f0899' as the X-Auth-Token. Replace this with the appropriate token you obtained in the above step.
To create a container:
curl -X PUT -H 'X-Auth-Token: AUTH_tk65840af9f6f74d1aaefac978cb8f0899' http://10.80.83.68:8077/v1/AUTH_system/mycontainer
To list all containers in current account:
root@s01:~/basho_bash_bench/results# ls -al | grep 6-04
drwxr-xr-x 27 root root 4096 2012-06-04 11:08 .
drwxr-xr-x 9 root root 4096 2012-06-04 10:58 ..
drwxr-xr-x 3 root root 4096 2012-06-04 11:08 cs-2-mb-15-min-1-wr-create
root@s01:~/basho_bash_bench/results# cd cs-2-mb-15-min-1-wr-create
root@s01:~/basho_bash_bench/results/cs-2-mb-15-min-1-wr-create# ls -al
total 28
drwxr-xr-x 3 root root 4096 2012-06-04 11:08 .
drwxr-xr-x 27 root root 4096 2012-06-04 11:08 ..
drwxr-xr-x 2 root root 4096 2012-06-04 11:08 backup