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
// obj ::= "{" [members] "}". | |
// arr ::= "[" [values] "]". | |
// value ::= obj | arr | stringLiteral | floatingPointNumber | "null" | "true" | "false". | |
// values ::= value { "," value }. | |
// members ::= member { "," member }. | |
// member ::= stringLiteral ":" value. | |
object Main { | |
import util.parsing.combinator._ |
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 LogParser { | |
import java.net._ | |
import org.joda.time.DateTime | |
import org.joda.time.format.DateTimeFormat | |
case class Access( | |
ipAddress: InetAddress, | |
ident: String, | |
user: String, |
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
scalaVersion := "2.9.1" | |
resolvers ++= Seq( | |
"jboss.org" at "http://repository.jboss.org/nexus/content/groups/public/" | |
) | |
libraryDependencies ++= Seq( | |
"org.jboss.netty" % "netty" % "3.2.7.Final" | |
) |
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
val model = new FileDataModel(new File("data/ml-100k/ua.base")) |
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
lazy val slopeOne = new RecommenderBuilder { | |
def buildRecommender(model: DataModel) = new SlopeOneRecommender(model) | |
} |
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
scala> val a = (1 to 100).grouped(10).map(_.iterator) | |
a: Iterator[Iterator[Int]] = non-empty iterator | |
scala> val b = Stream.continually{ print("#"); a.next }.take(10) | |
#b: scala.collection.immutable.Stream[Iterator[Int]] = Stream(non-empty iterator, ?) | |
scala> val c = b.iterator.flatten | |
c: Iterator[Int] = non-empty iterator | |
scala> c.foreach(print) |
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
while (true) { | |
readLine | |
println("start") | |
val start = System.currentTimeMillis | |
readLine | |
val end = System.currentTimeMillis | |
println("end") | |
println("%.1f".format( (end - start).toDouble / 1000)) | |
} |
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 Levenshtein { | |
def calc(a: String, b: String): Int = { | |
val d = Array.ofDim[Int](a.size + 1, b.size + 1) | |
// initialization | |
for (i <- 0 to a.size) d(i)(0) = i | |
for (j <- 0 to b.size) d(0)(j) = j | |
for ( | |
i <- 1 to a.size; |
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 com.fourseasonszoo.niboshi | |
import com.sun.syndication.io._ | |
import com.sun.syndication.feed.synd._ | |
import scala.collection.JavaConverters._ | |
import org.scala_tools.time.Imports._ | |
import scalax.io._ | |
import java.io.StringWriter | |
object Main extends App { |
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.sys.process._ | |
for (pom <- ("find . -name pom.xml" !!) split "\n") { | |
"mvn -f " + pom + " clean" run | |
} |