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._ | |
/* | |
* Simple test of the MongoDB Aggregation Framework via Casbah | |
* | |
* [Note: only works on MongoDB 2.1+] | |
* | |
* The "students" collection consists of student test score records that [simplified] look like this: | |
* | |
{ |
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 dispatch._ | |
import dispatch.liftjson.Js._ | |
import net.liftweb.json.JsonAST.JString | |
final val APIKEY = "XXXXXXXXX" // get a free key at http://www.wunderground.com/weather/api/ | |
def getTemp(city: String, state: String) = { | |
val http = new Http | |
val url = :/("api.wunderground.com") / "api" / APIKEY / "geolookup" / "conditions" / "q" / state / (city + ".json") | |
http(url ># { json => |
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
(* | |
Works in Evernote v.3.3.0. | |
(Note: I've read of people having problems with | |
AppleScript with the AppStore version of Evernote. | |
If you're having trouble, you might want to sync, | |
then delete the appstore version and download the | |
mac app directly from Evernote.) | |
Based on: |
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> import com.mongodb.casbah._ | |
import com.mongodb.casbah._ | |
scala> val dbl = MongoDBList() | |
16:23:48.222 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Registering Scala Conversions. | |
16:23:48.225 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Deserializers for Scala Conversions registering | |
16:23:48.226 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Serializers for Scala Conversions registering | |
16:23:48.227 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Setting up OptionSerializer | |
16:23:48.232 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Setting up ScalaJCollectionSerializer | |
16:23:48.238 [Thread-35] DEBUG c.m.c.c.c.s.package$RegisterConversionHelpers$ - Setting up ScalaRegexSerializers |
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> import util.Random | |
import util.Random | |
scala> (1 to 1000) map (i => (new Random(i)).nextInt(2)) | |
res25: scala.collection.immutable.IndexedSeq[Int] = Vector(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... | |
scala> (1 to 1000) map (i => (new Random(i)).nextInt(4)) | |
res26: scala.collection.immutable.IndexedSeq[Int] = Vector |
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
package at.atsoft.util | |
import com.ning.http.client.RequestBuilder | |
import com.ning.http.client.Request | |
import com.ning.http.client.FluentCaseInsensitiveStringsMap | |
import java.util.ArrayList | |
import com.ning.http.client.Cookie | |
import java.io.InputStream | |
import com.ning.http.client.Request.EntityWriter | |
import com.ning.http.client.BodyGenerator |
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 scala.concurrent._ | |
import scala.util.{ Success, Failure } | |
import ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
trait Calculator { | |
def hardToCalculate1: Int | |
def hardToCalculate2: Int | |
def hardToCalculate3: Int |
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
// This is the query to find all of a user's | |
// non-academy courses. In other words... | |
// I want to list all of this user's courses, | |
// but exclude courses associated with | |
// academies in which this user is a member. | |
val user:User = ... | |
val excludeTheseAcademies = (for { | |
au <- AcadUser if au.userId === user.id |
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 test = testcollections.testcoll | |
test: com.mongodb.casbah.MongoCollection = testtest | |
scala> import com.mongodb.casbah.Imports._ | |
import com.mongodb.casbah.Imports._ | |
scala> test.save(MongoDBObject("list" -> List("one", "two", "three"))) // save a list to mongodb | |
res1: com.mongodb.WriteResult = N/A | |
scala> val o = test.findOne.get // get back the thing we just saved |
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
package sample.cluster.simple | |
import com.typesafe.config.ConfigFactory | |
import akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor._ | |
import akka.contrib.pattern.ClusterSingletonManager | |
import akka.contrib.pattern.ClusterSingletonProxy | |
class MyClusterActor extends Actor { |
OlderNewer