This file contains hidden or 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
| object scala { | |
| val version = "SCALA_VERSION$" | |
| } | |
| val xml = <dependencies> | |
| <dependency> | |
| <groupId>org.scalanlp</groupId> | |
| <artifactId>scalala_${scala.version}</artifactId> | |
| <version>0.3.1</version> | |
| </dependency> |
This file contains hidden or 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 the magic libraries | |
| import scala.xml._ | |
| import scala.xml.transform._ | |
| // Source xml. In Scala, xml is literal. | |
| val xml = | |
| <user> | |
| <email>joe@example.com</email> |
This file contains hidden or 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.io._ | |
| import scala.util.parsing.json._ | |
| object Sca2Main { | |
| def main(args: Array[String]){ | |
| val url = "http://search.twitter.com/search.json?q=umitanuki" | |
| val parsed = JSON.parseRaw(Source.fromURL(url).getLines.mkString) | |
| parsed match{ | |
| case Some(x:JSONObject) => println("object") | |
| case Some(y:JSONArray) => println("array") |
This file contains hidden or 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 go | |
| import java.util.concurrent.{ | |
| BlockingQueue => JBlockingQueue, | |
| ArrayBlockingQueue => JArrayBlockingQueue | |
| } | |
| object Channel { | |
| def empty[A]: Channel[A] = new BlockingChannel() | |
| def make[A]: Channel[A] = make(1) |
This file contains hidden or 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
| //My take on: http://solog.co/47/10-scala-one-liners-to-impress-your-friends/ | |
| //1. Multiple Each Item in a List by 2 | |
| //(1 to 10) map { _ * 2 } | |
| (1 to 10) map (2*) | |
| //2. Sum a List of Numbers | |
| //(1 to 1000).reduceLeft( _ + _ ) | |
| (1 to 1000).sum |
This file contains hidden or 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
| // See this mailing list thread for context: | |
| // https://groups.google.com/d/topic/scala-language/ImqJuGylyi8/discussion | |
| case class Companion[-C, T](t : T) | |
| trait Publish[C, T] { self : T => | |
| implicit val companion = Companion[C, T](this) | |
| } | |
| trait StaticKey { |
This file contains hidden or 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
| /* | |
| Copyright 2012-2021 Viktor Klang | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
| /** | |
| * Handles the comet event stream. | |
| */ | |
| def cometStream = Action { | |
| AsyncResult { | |
| implicit val timeout = Timeout(5.seconds) | |
| val actor=Akka.system.actorOf(Props[EventListener]) | |
| // Actor is listening for event on the eventStream | |
| Akka.system.eventStream.subscribe(actor,classOf[ChangeEvent]) | |
| // For each event, stream the data to client |
This file contains hidden or 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 akka.actor.Actor | |
| import akka.actor.ActorSystem | |
| import akka.agent.Agent | |
| import com.typesafe.config.ConfigFactory | |
| import akka.event.Logging | |
| import akka.actor.Props | |
| import kafka.utils.Utils | |
| import java.nio.ByteBuffer |
OlderNewer