This file contains 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
[error] /Users/bwmcadams/code/mongodb/casbah/casbah-query/src/test/scala/DSLCoreOperatorsSpec.scala:1271: type mismatch; | |
[error] found : ((some other)$anon(in value <local DSLCoreOperatorsSpec>) forSome { type (some other)$anon(in value <local DSLCoreOperatorsSpec>) <: java.lang.Object with com.mongodb.casbah.commons.MongoDBObject{def $maxDistance[T](radius: T)(implicit evidence$15: Numeric[T]): (some other)$anon(in value <local DSLCoreOperatorsSpec>)} }) | |
[error] required: $anon(in value <local DSLCoreOperatorsSpec>) where type $anon(in value <local DSLCoreOperatorsSpec>) <: java.lang.Object with com.mongodb.casbah.commons.MongoDBObject{def $maxDistance[T](radius: T)(implicit evidence$15: Numeric[T]): $anon(in value <local DSLCoreOperatorsSpec>)} | |
[error] near must notBeNull | |
[error] ^ | |
((some other)$anon(in value <local DSLCoreOperatorsSpec>) forSome { type (some other)$anon(in value <local DSLCoreOperatorsSpec>) <: java.lang.Object with com.mongodb.casbah.commons.MongoDBObject{def $maxDista |
This file contains 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 com.mongodb.casbah.Imports._ | |
val conn = MongoConnection() | |
val db = conn("test") | |
val coll = db("foo") | |
for (x <- coll.find(MongoDBObject("_id" -> new ObjectId("4cd2d357c575954934c5a975")), | |
MongoDBObject("x" -> 1))) println(x) |
This file contains 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
implicit def pimpMyMap(underlying: Map[_,_]) = new { | |
/** Lazy utility method to allow typing without conflicting with Map's required get() method and causing ambiguity */ | |
def getAs[A <: Any : Manifest](key: Any): Option[A] = { | |
require(manifest[A] != manifest[scala.Nothing], | |
"Type inference failed; getAs[A]() requires an explicit type argument " + | |
"(e.g. mapObject.getAs[<ReturnType>](somegetAKey) ) to function correctly.") | |
underlying.get(key) match { | |
case null => None |
This file contains 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
class CallableMap extends scala.collection.mutable.HashMap[String, Any] with Dynamic { | |
def invokeDynamic(name: String)(args: Any*) = { | |
println("Invoke Dynamic: (name = %s)(args: %s)".format(name, args)) | |
get(name) | |
} | |
def typed[T]: T = { | |
asInstanceOf[T] | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.mongodb.mongod</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/mongodb/bin/mongod</string> | |
<string>run</string> |
This file contains 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
#ruby | |
[1,2,3,4].select{ |x| x.even? } | |
#python | |
[x for x in [1,2,3,4] if not x%2] | |
#or, more norvingly | |
filter(lambda x: not x%2, [1,2,3,4]) | |
#clojure | |
(filter #(even? % ) [1 2 3 4]) |
This file contains 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/python | |
# Connects to localhost, 27017 by default | |
import sys | |
import pymongo | |
import time | |
if len(sys.argv) < 2: | |
print >> sys.stderr, "Usage: ./tail_profile.py <dbName> [hostname] [port]" | |
sys.exit(-1) |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.mongodb.mongod</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/mongodb/bin/mongod</string> | |
<string>run</string> |
This file contains 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
scala> val x: PartialFunction[String, Unit] = { case "foo" => println("Foo") } | |
x: PartialFunction[String,Unit] = <function1> | |
scala> x("foo") | |
Foo | |
scala> x("bar") | |
scala.MatchError: bar | |
scala> val y: PartialFunction[String, Unit] = { case "bar" => println("Bar") } |
This file contains 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 com.mongodb.casbah.Imports._ | |
import com.mongodb.casbah.dynamic._ | |
val d = DynamicDBObject("_id" -> new ObjectId, "name" -> "Brendan McAdams", | |
"address" -> MongoDBObject("street" -> "134 5th Ave Fl 3", | |
"city" -> "New York", | |
"state" -> "NY", | |
"zip" -> 10011), | |
"email" -> "brendan@10gen.com") |