I hereby claim:
- I am banker on github.
- I am hwaet (https://keybase.io/hwaet) on keybase.
- I have a public key ASAz4KeG_T7Aeq6EJ727hEqaMlBSGzGBzx1iwJEONZLoQwo
To claim this, I am signing this object:
| import com.mongodb.Mongo; | |
| import com.mongodb.DB; | |
| import com.mongodb.DBCollection; | |
| import com.mongodb.BasicDBObject; | |
| import com.mongodb.DBObject; | |
| import com.mongodb.DBCursor; | |
| import com.mongodb.WriteConcern; | |
| public class Test { |
| var customerAggregations = provider.AggregationSet<Customer>(); | |
| customerAggregations.Apply(x =>x.RecordShell.Age + 3, | |
| "AgeInThreeYears"); |
| public static String script = "" + | |
| "local key = KEYS[1]" + | |
| "local field = ARGV[1]" + | |
| "local value = ARGV[2]" + | |
| "local op = ARGV[3]" + | |
| "local current = redis.call('hget', key, field)" + | |
| "if (current == null) then " + | |
| " redis.call('hset', key, field, value)" + | |
| "elseif op == '>' then" + | |
| " if tonumber(value) > tonumber(current) then" + |
I hereby claim:
To claim this, I am signing this object:
| # mongo_template.rb | |
| # fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
| # | |
| # To use: | |
| # rails project_name -m http://gist.github.com/gists/219223.txt | |
| # remove unneeded defaults | |
| run "rm public/index.html" | |
| run "rm public/images/rails.png" | |
| run "rm public/javascripts/controls.js" |
| # with multiple collections + commands for renaming back the collections | |
| require 'mongo' | |
| # Stop writing to your database. | |
| # Then, for each collection: | |
| # Specify the DB and COLLECTION you want to convert. | |
| # Will insert all modified documents into a new collection | |
| # called 'new_' + old_collection_name. | |
| # Then you can delete the old collection and rename the new one |
| x = 10000.times.to_a | |
| a,b,c = x.dup, x.dup, x.dup | |
| Benchmark.measure { 1000.times { out = []; out += a; out += b; out +=c; out.uniq! } } | |
| Benchmark.measure { 1000.times { out = Set.new; out += a; out += b; out +=c; } } | |
| Benchmark.measure { 1000.times { out = {}; a.each {|e| out[e] ||= 1}; b.each {|e| out[e] ||= 1}; c.each {|e| out[e] ||= 1}; } } |
| > db.f.save({u: 1, v: 2}) | |
| > db.f.save({u: 2, v: 2}) | |
| > db.f.save({u: 1, v: 5}) | |
| > db.f.save({u: 2, v: 10}) | |
| > m = function() { emit(this.u, this.v) } | |
| function () { | |
| emit(this.u, this.v); | |
| } | |
| > r = function(k, vs) { r = 0; vs.forEach(function(v) { r += v; }); return r; } | |
| function (k, vs) { |
| #include <stdio.h> | |
| #include "mongo.h" | |
| int main() { | |
| mongo conn[1]; | |
| int status = mongo_connect( conn, "127.0.0.1", 27017 ); | |
| if( status != MONGO_OK ) { | |
| switch ( conn->err ) { | |
| case MONGO_CONN_SUCCESS: printf( "connection succeeded\n" ); break; |