Skip to content

Instantly share code, notes, and snippets.

View tbje's full-sized avatar

Trond Bjerkestrand tbje

View GitHub Profile
@tbje
tbje / Outilne.scala
Created December 11, 2012 13:00
Phone Mnemonics
package misc
class PhoneMnemonics(words: Set[String]) {
val codeToChars: Map[Char, String] =
Map(
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ"
)
import sbt._
import sbt.Keys._
import com.typesafe.sbtscalariform.ScalariformPlugin._
object Build extends Build {
lazy val scalatrain = Project(
"scalatrain",
file("."),
settings =
@tbje
tbje / TestData.scala
Created January 31, 2012 08:04
TestData
package org.scalatrain
object TestData {
val List(munich, nuremberg, essen, cologne) =
List("Munich", "Nuremberg", "Essen", "Cologne") map { Station(_) }
val (t722, t724) = ("722", "724")
val times: Map[String, Map[Station, Time]] = Map(
t722 -> Map(
@tbje
tbje / TestData.scala
Created December 16, 2011 09:05
Test data
/*
* Copyright 2011 Typesafe Inc.
*
* This work is based on the original contribution of WeigleWilczek.
*
* Unless otherwise agreed, training materials may only be used for
* educational and reference purposes by individual named participants
* in a training course offered by Typesafe or a Typesafe training partner.
* Unauthorized reproduction, redistribution, or use of this material is prohibited.
*/
@tbje
tbje / plugins.sbt
Created November 23, 2011 12:09
Different versions of sbt and global plugins
import sbt._
import Defaults._
libraryDependencies <++= (scalaVersion, sbtVersion) {
case (scalaVersion, sbtVersion @ "0.11.0") => Seq(
sbtPluginExtra("name.heikoseeberger.groll" % "groll" % "0.4.0-SNAPSHOT", sbtVersion, scalaVersion), // corresponds to addSbtPlugin("name.heikoseeberger.groll" % "groll" % "0.4.0-SNAPSHOT")
sbtPluginExtra("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0-SNAPSHOT", sbtVersion, scalaVersion)
)
case (scalaVersion, sbtVersion @ "0.11.1") => Seq(
@tbje
tbje / plugins.sbt
Created November 23, 2011 11:26
Different versions of sbt and global plugins
import sbt._
import Default._
libraryDependencies <++= (scalaVersion, sbtVersion) {
case (scalaVersion, sbtVersion @ "0.11.0") => Seq(
sbtPluginExtra("name.heikoseeberger.groll" % "groll" % "0.4.0-SNAPSHOT", sbtVersion, scalaVersion),
sbtPluginExtra("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0-SNAPSHOT", sbtVersion, scalaVersion)
)
case (scalaVersion, sbtVersion @ "0.11.1") => Seq(
@tbje
tbje / sbt
Created August 24, 2011 08:52
Plain sbt setup
java -Xmx512M -jar $SBT_LAUNCHER "$@"
http x((:/ ("www.mysite.com") / "upload") <<
("file", new java.io.File("""path\to\file\""")) as_str)
}
optional[String, Int](S.param("optional"), Helpers.asInt(_))
/* http://blog.trondbjerkestrand.no/post/1114624297/automated-kindle-epub-delivery */
import scala.xml._
import scala.xml.transform._
import scala.xml.factory.XMLLoader
import javax.xml.parsers.SAXParser
/* Avoid loading dtd for contents.xml */
object MyXML extends XMLLoader[Elem] {
override def parser: SAXParser = {