Skip to content

Instantly share code, notes, and snippets.

View tbje's full-sized avatar

Trond Bjerkestrand tbje

View GitHub Profile
import net.liftweb.util.ActorPing
import net.liftweb.common.Logger
class Boot extends Logger {
def boot {
// where to search snippet
LiftRules.addToPackages("your.package")
...
val myActor = new MyActor
myActor ! Msg
<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- enable scalatest -->
<plugin>
import scala.xml._
def googleLocalisation(adr: String) : Option[(Double, Double)] = {
val url = "http://maps.google.com/maps/api/geocode/xml?sensor=false&address="
val xml = XML.load(url+adr)
if ((xml \ "status" text) == "OK") {
val lat = ((xml \ "result" \ "geometry" \ "location" \ "lat") text).toDouble
val lng = ((xml \ "result" \ "geometry" \ "location" \ "lng") text).toDouble
Some((lat, lng))
} else {
class MyProject(info: ProjectInfo) extends DefaultWebProject(info){
<!-- Your dependencies here -->
val jetty7WebApp = "org.eclipse.jetty" % "jetty-webapp" % "7.0.2.RC0" % "test"
val jetty7Server = "org.eclipse.jetty" % "jetty-server" % "7.0.2.RC0" % "test"
val jetty7Plus = "org.eclipse.jetty" % "jetty-plus" % "7.0.2.RC0" % "test"
<!-- Path to jetty-env.xml -->
override def jettyEnvXml = Some(
(sourcePath / "main" / "jetty" / "jetty-env.xml").asFile
)
<Get name="sessionHandler">
<Get name="sessionManager">
<Set name="refreshCookieAge">120</Set>
<Set name="maxCookieAge">1200</Set>
</Get>
</Get>
/* 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 = {
optional[String, Int](S.param("optional"), Helpers.asInt(_))
http x((:/ ("www.mysite.com") / "upload") <<
("file", new java.io.File("""path\to\file\""")) as_str)
}
@tbje
tbje / sbt
Created August 24, 2011 08:52
Plain sbt setup
java -Xmx512M -jar $SBT_LAUNCHER "$@"
@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(