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 'redis' | |
| require 'digest/sha1' | |
| class RedisKey | |
| def initialize | |
| @redis = Redis.new | |
| end | |
| def surrogate_key(dimension, data) | |
| nk = Digest::SHA1.hexdigest(data) |
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 'redis' | |
| require 'mongo' | |
| require 'benchmark' | |
| class MongoVsRedis | |
| ITERATIONS = 100_000 | |
| MONGO_CRITERIA = {"_id"=>BSON::ObjectId.from_string("4d2fa98a858d68644662156d")} | |
| REDIS_CRITERIA = "benchmark_test" | |
| def initialize |
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 util = require('util'), | |
| spawn = require('child_process').spawn, | |
| expresso = 'expresso', | |
| async = require('async'); | |
| async.parallel({ | |
| "My Test" : function(cb){ runTest('./test/my_test.js', "My Test", cb) }, | |
| "My Other Test" : function(cb){ runTest('./test/my_other_tests', "My Other Test", cb) }, | |
| },function(errors, results){ | |
| util.print("Tests:\n"); |
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]}) |
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
| 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
| #!/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
| #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 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
| 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'); |
OlderNewer