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
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
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
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
// 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
public class UserAgent { | |
private nl.bitwalker.useragentutils.UserAgent ua; | |
private UserAgent(nl.bitwalker.useragentutils.UserAgent ua) { | |
this.ua = ua; | |
} | |
public boolean isFirefox7Plus() { | |
if (ua.getBrowser().getGroup() == Browser.FIREFOX) { |
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.util.parsing.combinator._ | |
/** | |
* <hosts> ::= { <line> } | |
* <line> ::= <entry> | [ <comment> ] <eol> | |
* <entry> ::= <ip-address> <hostnames> [ <comment> ] <eol> | |
* <ip-address> ::= <ipv4-address> | <ipv6-address> | |
* <ipv4-address> ::= "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}" | |
* <ipv6-address> ::= ... | |
* <hostnames> ::= <hostname> { <hostname> } |
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 s99 | |
object P46 { | |
def and(a: Boolean, b: Boolean): Boolean = a && b | |
def or(a: Boolean, b: Boolean): Boolean = a || b | |
def nand(a: Boolean, b: Boolean): Boolean = ! and(a, b) | |
def xor(a: Boolean, b: Boolean): Boolean = or(a, b) && !and(a, b) | |
def nor(a: Boolean, b: Boolean): Boolean = ! or(a, b) | |
def impl(a: Boolean, b: Boolean): Boolean = a | |
def equ(a: Boolean, b: Boolean): Boolean = a == b |
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
// simple query | |
db.inTransaction { q => | |
q.select("select * from emp") { row => | |
User(row.id, row.name) | |
} | |
} | |
// many to one | |
dbinTransaction { | |
q => for(p <- q.select("select * from emp limit 3") { r => |
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
def flatMapSublists[A,B](ls: List[A])(f: (List[A]) => List[B]): List[B] = { | |
def sublists[A](ls: List[A]): List[List[A]] = { | |
ls match { | |
case Nil => List(List()) | |
case x :: xs => ls :: sublists(xs) | |
} | |
} | |
sublists(ls).flatMap(f) | |
} |