This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ks in SYSTEM_MANAGER.list_keyspaces(): | |
describe_keyspace(ks) | |
for cf in SYSTEM_MANAGER.get_keyspace_column_families(ks): | |
describe_column_family(ks, cf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pycassa.pool import ConnectionPool | |
from pycassa.columnfamily import ColumnFamily | |
from pycassa.cassandra.ttypes import ConsistencyLevel, NotFoundException | |
HOSTS = ['localhost'] | |
pool = ConnectionPool('my_keyspace', HOSTS) | |
my_cf = ColumnFamily(pool, 'my_cf') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple Linear Probabilistic Counters | |
Credit for idea goes to: | |
http://highscalability.com/blog/2012/4/5/big-data-counting-how-to-count-a-billion-distinct-objects-us.html | |
http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/ | |
Installation: | |
pip install smhasher | |
pip install bitarray |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var noop = function(){}; | |
var obj = { | |
'1':function(){ console.log(1) }, | |
'10':function(){ console.log(10) }, | |
'100':function(){ console.log(100) }, | |
'1000':function(){ console.log(1000) }, | |
'10000':function(){ console.log(10000) } | |
}; | |
console.time('checking'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'right_aws' | |
EC2_PRIVATE_KEY = ENV['EC2_PRIVATE_KEY'] | |
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY'] | |
AWS_SECRET_KEY = ENV['AWS_SECRET_KEY'] | |
def group | |
@group ||= ARGV[0] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#foobar | |
# Send the passive service check back to Nagios | |
logger.debug("Constructing the Nagios result string") | |
nag_message = config.get('nagios','message') | |
nag_status = 0 | |
logger.info("Passive check result sent to Nagios") | |
except Exception, e: | |
nag_status = 2 | |
nag_message = "%s" % (e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var stdin = process.stdin, | |
fields = process.argv.slice(2), | |
buf = []; | |
if (fields.length === 0){ | |
console.error('Usage: jgrep "some.fields in.json" < STDIN'); | |
process.exit(1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 0, n = 100000000, t = 0; | |
console.time('i++'); | |
for (; i < n; i++){ | |
t += 1; | |
} | |
console.timeEnd('i++'); | |
//i++: 147ms | |
i = 0; t = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongo' | |
foo = ['this', 'that'] | |
bar = [:this, :that] | |
a = {:foo => ['this', 'that']} | |
b = {:foo => [:this, :that]} | |
bson_a = BSON.serialize(a).to_s | |
#=> "'\x00\x00\x00\x04foo\x00\x1D\x00\x00\x00\x020\x00\x05\x00\x00\x00this\x00\x021\x00\x05\x00\x00\x00that\x00\x00\x00" | |
bson_b = BSON.serialize(b).to_s | |
#=> "'\x00\x00\x00\x04foo\x00\x1D\x00\x00\x00\x0E0\x00\x05\x00\x00\x00this\x00\x0E1\x00\x05\x00\x00\x00that\x00\x00\x00" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongo' | |
@db = Mongo::Connection.new['test'] | |
@symbol_coll = @db['bson_symbols'] | |
@string_coll = @db['bson_string'] | |
[@symbol_coll, @string_coll].each{|c| c.remove } | |
3.times do |i| | |
@symbol_coll.insert({'foo' => [:a, :b, :c, :d]}) |