Because my hobby seems to be writing Option libraries in various languages, I’ve written another, in Python: option.py. Enjoy. Read more – ‘option.py’.
Quick note for fellow Lift developers: I was happily using a Menu.param when I decided to use a Menu.params instead (see the ScalaDocs) in the hopes of both more descriptive URLs and less to calculate on the actual page. While implementing it wasn’t too hard, my new URL pattern for the menu entry was a […] Read more – ‘Using Lift’s Menu.params’.
For iFebo I built a server last year to handle sending push messages to Urban Airship, which we use in front of the Apple Push Notification service due to its great scheduling features. To do this I needed a way to interact with the UA API and while it’s got lots of features it’s not […] Read more – ‘Sending iOS Push Messages with Urban Airship and BFUrbanAirship’.
Because hey, why not? In Python: >>> 1 in [1, 2, 3] True In Scala: class In(a: Any) { def in[T](s: Seq[T]) = s.contains(a) } implicit def any2In(a : Any) = new In(a) scala> "a" in List(1, 2, "a") res0: Boolean = true scala> "a" in List(1, 2, "b") res1: Boolean = false Read more – ‘Python-style in in Scala’.
Ruby code often has code with trailing conditionals, which can look pretty neat. person = Person.get(name) unless name.nil? (Note: I really don’t know Ruby, I just saw syntax like this and thought was cool.) So, of course I had to implement it in Scala: You get optional values: Pretty cool, no? I tried and failed […] Read more – ‘Ruby-style trailing conditionals in Scala’.
Because I’ve wasted too much time on Casbah tonight, I have to pass it on. Simply, not much is done for you automatically. Connect like this: val uri = MongoURI("mongodb://username:password@server:port/database") val mongo = MongoConnection(uri) val db = mongo(uri.database) db.authenticate(uri.username, uri.password.foldLeft("")(_ + _.toString)) val collection = db("something") If you call db.authenticate() a second time it will […] Read more – ‘Connecting to a Mongo database with Casbah’.