Skip to content

Instantly share code, notes, and snippets.

@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
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: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)
@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: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:4149773
Created November 26, 2012 18:26
bundle exec rake results
basho-ninja:api-server dkerrigan$ bundle exec rake
/Users/dkerrigan/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -I"lib:lib:test" -I"/Users/dkerrigan/.rvm/gems/ruby-1.9.3-p194@api_server/gems/rake-0.9.2/lib" "/Users/dkerrigan/.rvm/gems/ruby-1.9.3-p194@api_server/gems/rake-0.9.2/lib/rake/rake_test_loader.rb" "test/**/test_*.rb"
/Users/dkerrigan/.rvm/gems/ruby-1.9.3-p194@api_server/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require': iconv will be deprecated in the future, use String#encode instead.
:public is no longer used to avoid overloading Module#public, use :public_folder instead
from /Users/dkerrigan/.rvm/gems/ruby-1.9.3-p194@api_server/gems/cans-0.2.2/lib/cans/application.rb:4:in `<class:Application>'
* DEFERRED: for ownerships with an existing ownership specific id with a provider token the /v3/ownership/:id/subscription endpoint should return metadata about existing subscriptions on GET.
* DEFERRED: for ownerships with an existing ownership specific id with a provider
@drewkerrigan
drewkerrigan / gist:4171112
Created November 29, 2012 18:56
splatted report endpoint
get "/admin/reports/*_metrics.csv" do |operation|
endpoint = Att::API::Internal::Metrics.new(Server.setting(:api_uri), @app, @type)
report = "Date of Report,"
report += "Developer Registration Date,"
report += "Developer Id,"
report += "Developer Email,"
report += "Developer Organization,"
report += "Developer CTN,"
report += "AT&T Wireless Customer,"
@drewkerrigan
drewkerrigan / gist:4197417
Created December 3, 2012 19:43
usage metrics notes
basho-ninja:mhealth dkerrigan$ RACK_ENV=local ; ./console
1.9.3p194 :001 > a = Application.find("api-tester-client")
=> <Application:api-tester-client flags={} created_at=2012-11-30 16:39:40 UTC app_type="client" app_status="prod" scope_permissions="public" connected_apps=0 total_users=0 has_icon=false name="api-tester-client" display_name="API Tester Client" developer_id="FEwZgNI4VTJSIZxSas0QpOCCXjn" description="Qui corporis labore enim voluptatem non numquam ducimus maiores." compliance="fda" url_callback="http://localhost" default_access_type="read" consumer_id="VuLWp8shXiLxh7Tn7hSf" consumer_secret="046IpUI5KhZ2m1QQllWrx9AbrVIhtXVGQyEM18Ec" updated_at=2012-11-30 16:39:40 UTC url_website=nil organization=nil url_support=nil url_subscription=nil>
1.9.3p194 :002 > a.metrics_totals
=> {:storage_used=>6266.0, :api_usage=>14919.0, :api_calls=>40, :third_party_api_calls=>4714.0}
1.9.3p194 :003 > a.metrics_details("20121115","20121215")
=> {:storage_used=>{"20121115"=>0.0, "20121116"=>0.0, "20121117"=>0.0,
@drewkerrigan
drewkerrigan / gist:4199310
Created December 4, 2012 00:18
multi node riak 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:4218222
Created December 5, 2012 18:31
php multi-get mapred
require("riak-php-client/riak.php");
$client = new RiakClient('127.0.0.1', 8098);
$mr = new RiakMapReduce($client);
$keys = array("TFrWAVz8RRVEEqCH3nS27O4InLB","FEwZgNI4VTJSIZxSas0QpOCCXjn","EkSkmblyIAT5VL7xYpScP2GP71G");
foreach ($keys as $key) {
$mr->add("local_ns~users", $key);
}
$mr->map("Riak.mapValues");