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 render = {<a onclick={Alert(Call(myFunction, 4, 5))}>Click me</a>} |
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 listFromDb : Box[List[String]]= ... should collect data from db, but throws exception ... | |
def render = { | |
listFromDb match { | |
case None => <p>No items.</p> | |
case Some(items) => | |
bind( | |
"myComet", defaultXml, | |
"content" -> transforListToXhtml(list)) |
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
/* http://tbje.blogspot.com/2010/04/random-unique-hash-in-scala.html */ | |
import scala.util.Random | |
def uniqueRandomKey(chars: String, length: Int, uniqueFunc: String=>Boolean) : String = { | |
val newKey = (1 to length).map(x => chars(Random.nextInt(chars.length))).mkString | |
if (uniqueFunc(newKey)) newKey else uniqueRandomKey(chars, length, uniqueFunc) | |
} | |
val chars = ('a' to 'z') ++ ('A' to 'Z') ++ ('1' to '9') | |
val key = uniqueRandomKey(chars.toString, 22, (x:String)=>!keyExists?(x)) |
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
import net.liftweb.http._ | |
import net.liftweb.http.SHtml._ | |
import net.liftweb.util._ | |
import net.liftweb.util.Helpers._ | |
import net.liftweb.common._ | |
import java.net.{HttpURLConnection, MalformedURLException, URL, URLEncoder} | |
import java.io.{BufferedReader, InputStreamReader, IOException, OutputStreamWriter} | |
import scala.xml._ |
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
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 |
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
<!-- disable surefire --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<configuration> | |
<skipTests>true</skipTests> | |
</configuration> | |
</plugin> | |
<!-- enable scalatest --> | |
<plugin> |
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
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 { |
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
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 | |
) |
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
<Get name="sessionHandler"> | |
<Get name="sessionManager"> | |
<Set name="refreshCookieAge">120</Set> | |
<Set name="maxCookieAge">1200</Set> | |
</Get> | |
</Get> |
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
/* 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 = { |
OlderNewer