Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bwmcadams's full-sized avatar

Brendan McAdams bwmcadams

View GitHub Profile
#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])
# note that I see *EXACT* same results as the original post with the original code.
# The fix below makes that not happen anymore (use snapshot mode)
# mongo.jar on my machine is the shipped version of 2.7.0, so same exact Java Driver of original test
# ( I was lead on the 2.7.0 release and did the build/release )
b-mac mongodb/mongo-java-driver ‹master*› » scala -cp mongo.jar Repro.scala
Inserting canary...
Inserting test data...
Paging through records...
Spotted the canary!
Updating canary object...
@bwmcadams
bwmcadams / document.scala
Created March 3, 2016 18:49 — forked from mpilquist/document.scala
Example of using scodec to decode a document of fields
package foo
import scodec.bits._
import scodec._
import scodec.codecs._
case class Document(fields: Vector[(String, Field)])
sealed trait Field
case class IntField(value: Int) extends Field