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
trait Bar { def bar(msg:String):Unit } | |
trait Qux extends Bar { | |
abstract override def bar(msg:String="Qux Says Hello") = { | |
super.bar(msg) | |
println("qux: " + msg) | |
} | |
} | |
class Foo extends Bar { |
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
def exp[T](t: => T) = | |
(scala.util.control.Exception.allCatch either t).right | |
def readJson(dataField:Option[String],json:JsValue):Either[Throwable,JsValue] = { | |
for ( | |
contents <- exp( json.asJsObject.getFields("rsp")(0) ); | |
stat <- exp( contents.asJsObject.getFields("stat")(0).convertTo[String] ); | |
jsonObject <- exp ( | |
dataField match { | |
case Some(field) => contents.asJsObject.getFields(field)(0) |
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
// https://github.com/lopex/multibot/blob/master/src/main/scala/org/multibot/Multibot.scala | |
// line 87 | |
val scalaInt = scala.collection.mutable.Map[String, IMain]() | |
def scalaInterpreter(channel: String)(f: (IMain, ByteArrayOutputStream) => Unit) = this.synchronized { | |
val si = scalaInt.getOrElseUpdate(channel, { | |
val settings = new scala.tools.nsc.Settings(null) | |
settings.usejavacp.value = true | |
settings.deprecation.value = true | |
val si = new IMain(settings) { override def parentClassLoader = Thread.currentThread.getContextClassLoader } |
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
dabblego | |
point is to 0 as map is to 1 | |
point: A => F[A] | |
map: (A => B) => F[A] => F[B] | |
lift2: (A => B => C) => F[A] => F[B] => F[C] | |
point=lift0 | |
01:23 | |
map=lift1 |
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
val a = fromEither(listing).toValidationNEL | |
val retr = { x:VideoListing => fromEither(lister.retrieveReport(x)).toValidationNEL } | |
val res0 = for ( | |
l <- a; | |
rep <- retr(l) | |
) yield { rep } | |
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
case class Music(id:ID, title:String, isrc:String) | |
case class Compilation(id:ID=None, title:String, musics: List[Music], author:User /* TODO Either[DJ,Programmer]? */) | |
case class User(id:ID=None, name:String, email:String, password:String) | |
object Musics extends Table[Music]("music") { | |
def id = this.autoIncPk("id") | |
def title = this.string("title") | |
def isrc = this.string("isrc") |
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
object Function1Stuff { | |
def flatMap[T, A, B]: Function1[T, A] => (A => Function1[T, B]) => Function1[T, B] = | |
sys.error("todo") | |
} |
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
val query = Query(Users) drop 10 take 10 | |
query.selectStatement | |
//> query : scala.slick.lifted.Query[querying.samples.model.Users.type,queryin | |
//| g.samples.model.User] = scala.slick.lifted.WrappingQuery@10f102d3 | |
//> res0: String = select x2.x3, x2.x4, x2.x5, x2.x6, x2.x7 from (select x8."id | |
//| " as x3, x8."name" as x4, x8."email" as x5, x8."password" as x6, x8."roleId | |
//| " as x7 from "user" x8 limit 10 offset 10) x2 |
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
def equalBy[B: BaseTypeMapper] | |
(proj:Entities.type => Column[B])(str:B):Query[Entities.type,Entity] = { | |
Query(Entities) where { x => proj(x) === str} | |
} | |
val q = Entities.equalBy({ _.name })("5") | |
//> q : scala.slick.lifted.Query[test.whereCreator.Entities.type,test.whereCrea | |
//| tor.Entity] = scala.slick.lifted.WrappingQuery@6401d98a | |
q.selectStatement |
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
def index = nonCustomerAction { implicit u => implicit r => | |
Logger.info("into index") | |
Ok(html.subscriptions(db withSession { Subscriptions.all.list })) | |
} |
OlderNewer