Skip to content

Instantly share code, notes, and snippets.

View samuraisam's full-sized avatar

Samuel Sutch samuraisam

View GitHub Profile
@samuraisam
samuraisam / do_once_decorator.py
Created June 13, 2012 00:24
A decorator that allows you to execute a function exactly once upon the first execution of the wrapped function
import uuid
import functools
def do_once(once_f, *once_f_a, **once_f_kw):
"""
A decorator that executes `once_f(*once_f_a, **once_f_kw)` exactly once upon
the first execution of the decorated function. `once_f` may be a string in
which case it will be used to getattr() from the class.
`once_f` may be any callable. If the wrapped function is a classmethod
@samuraisam
samuraisam / example.clj
Created July 5, 2012 03:05
Signs objects (strings or whatever) into url-safe strings that can be used as CSRF tokens or whatnot
(ns myns [:use lazy.utils.signing :as signing])
(signing/with-keypair-filename "private.pem"
(signing/dumps {:my "hash" :of "any size"}))
@samuraisam
samuraisam / helloselect.go
Created July 29, 2012 00:20
trying out the select functionality of go
/*
* Intent - in paralell, download a series of urls
* - timeout after 1 sec if the download has not completed
* - allow for failures, and move on (similar to timeout)
* - collect the stringified response from the fetched url
*/
package main
import (
vagrant@precise64:~$ cat /tmp/vagrant-chef-1/chef-stacktrace.out
Generated at Tue Jul 31 02:26:40 +0000 2012
NoMethodError: undefined method `[]' for nil:NilClass
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/ohai_plugin.rb:22:in `from_file'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/opt/vagrant_ruby/lib/ruby/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/default.rb:21:in `from_file'
live migrating a 3-node cluster (RF=2) to a new 3-node cluster (RF=2)
NOTE! If you are starting a cluster using the DSC AMI - wipe the data directories of all the nodes and restart them before starting this process.
1. configure the first node of the new cluster to tok=170141183460469231731687303715884105728, autobootstrap=yes; start it
2. wait 2 mins
3. configure the 2nd and 3rd nodes of the new cluster to tok=$oldClusterNode[N].Tok - 1, autobootstrap=yes, waiting 2 mins between each
4. point clients at the new cluster nodes
5. decommission the old cluster nodes, 1 at a time, starting with the first node
6. move node 1 token from 170141183460469231731687303715884105728 to 0
OLD CLUSTER AFTER RESTART OF 0:
Address DC Rack Status State Load Owns Token
98762195403485621985010037012424498538
10.4.62.215 datacenter1 rack1 Up Normal 1.54 GB 41.95% 0
10.72.226.33 datacenter1 rack1 Up Normal 1.66 GB 33.33% 56703851999289891297969860682700010126
10.254.183.47 datacenter1 rack1 Up Normal 1.15 GB 24.72% 98762195403485621985010037012424498538
nodetool ring from node 1 of the new cluster:
Address DC Rack Status State Load Owns Token
170141183460469231731687303715884105728
10.4.62.215 UNKNOWN-DC UNKNOWN-RACKUp Normal 1.54 GB 0.00% 0
10.72.226.33 UNKNOWN-DC UNKNOWN-RACKUp Normal 1.66 GB 33.33% 56703851999289891297969860682700010126
10.254.183.47 UNKNOWN-DC UNKNOWN-RACKUp Normal 1.15 GB 24.72% 98762195403485621985010037012424498538
10.4.58.173 us-east 1c Up Normal 11.12 KB 41.95% 170141183460469231731687303715884105728
Address DC Rack Status State Load Effective-Ownership Token
170141183460469231731687303715884105728
10.4.62.215 datacenter1 rack1 Up Normal 1.54 GB 41.95% 0
10.72.226.33 datacenter1 rack1 Up Normal 1.66 GB 33.33% 56703851999289891297969860682700010126
10.254.183.47 datacenter1 rack1 Up Normal 1.15 GB 58.05% 98762195403485621985010037012424498538
10.4.58.173 datacenter1 rack1 Down Normal 11.12 KB 66.67% 170141183460469231731687303715884105728
Address DC Rack Status State Load Effective-Ownership Token
98762195403485621985010037012424498538
10.4.62.215 datacenter1 rack1 Up Normal 2.06 GB 66.67% 0
10.72.226.33 datacenter1 rack1 Up Normal 1.66 GB 75.28% 56703851999289891297969860682700010126
10.254.183.47 datacenter1 rack1 Up Normal 1.18 GB 58.05% 98762195403485621985010037012424498538
INFO [main] 2012-08-01 00:47:39,578 AbstractCassandraDaemon.java (line 121) JVM vendor/version: Java HotSpot(TM) Client VM/1.6.0_26
INFO [main] 2012-08-01 00:47:39,582 AbstractCassandraDaemon.java (line 122) Heap size: 862978048/864026624
INFO [main] 2012-08-01 00:47:39,583 AbstractCassandraDaemon.java (line 123) Classpath: /usr/share/cassandra/lib/antlr-3.2.jar:/usr/share/cassandra/lib/avro-1.4.0-fixes.jar:/usr/share/cassandra/lib/avro-1.4.0-sources-fixes.jar:/usr/share/cassandra/lib/commons-cli-1.1.jar:/usr/share/cassandra/lib/commons-codec-1.2.jar:/usr/share/cassandra/lib/commons-lang-2.4.jar:/usr/share/cassandra/lib/compress-lzf-0.8.4.jar:/usr/share/cassandra/lib/concurrentlinkedhashmap-lru-1.3.jar:/usr/share/cassandra/lib/guava-r08.jar:/usr/share/cassandra/lib/high-scale-lib-1.1.2.jar:/usr/share/cassandra/lib/jackson-core-asl-1.9.2.jar:/usr/share/cassandra/lib/jackson-mapper-asl-1.9.2.jar:/usr/share/cassandra/lib/jamm-0.2.5.jar:/usr/share/cassandra/lib/jline-0.9.94.jar:/usr/share/cassandra/lib/json-si