Skip to content

Instantly share code, notes, and snippets.

var customerAggregations = provider.AggregationSet<Customer>();
customerAggregations.Apply(x =>x.RecordShell.Age + 3,
"AgeInThreeYears");
@banker
banker / mongoc
Created January 6, 2012 22:17 — forked from anonymous/mongoc
MongoDB connection via C driver
#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;
@banker
banker / einval.rb
Created August 16, 2011 21:23 — forked from cgriego/einval.rb
MacBook Pro Early 2011, Lion, REE 2011.03, Mongo, forking #=> Errno::EINVAL
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'mongo'
@conn = Mongo::Connection.new
@db = @conn['supply_chain_development']
puts @db['properties'].find.to_a.size
/*
* Title: tutorial.c
* Author: Christopher Triolo
* Build & Run:
* $ gcc -Isrc --std=c99 tutorial.c /path/to/mongo-c-driver/src/*.c -I /path/to/mongo-c-driver/src/ -o tutorial
* $ ./tutorial
* connection succeeded
* ...
* connection closed
*/
{"rp":
{"AdSpot": [
{"1": {"a": "b"}},
{"2": {"a": "b"}},
{"3": {"a": "b"}}]
}
}
db.collection.find({"rp.AdSpot": {$in: [{"1": {"a": "b"}}, {"2": {"a": "b"}]}})
@banker
banker / mini.rb
Created February 19, 2010 23:00 — forked from defunkt/mini.rb
##
# shoulda-mini
# based on test/spec/mini 5
# http://gist.github.com/307649
# chris@ozmm.org
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
@banker
banker / Rails MongoMapper Template.rb
Created October 27, 2009 01:41 — forked from bscofield/gist:181842
A Rails Template for using MongoMapper
# 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"