Skip to content

Instantly share code, notes, and snippets.

View eltimn's full-sized avatar
🌏

Tim Nelson eltimn

🌏
View GitHub Profile
@eltimn
eltimn / H2 Console Servlet
Created August 12, 2009 18:58
Settings for using H2 console servlet in a Lift app
To use the H2 console servlet in your Lift app add the following to your web.xml
and Boot.scala files. Then you can access it via /console.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
@eltimn
eltimn / H2 DBVendor
Created August 12, 2009 19:16
H2 connection manager for Lift app
H2 has it's own connection pool manager that H2 claims [1] is faster than using
DriverManager.getConnection(). Here's how to configure it for use in a Lift app.
/**
* H2 db connection manager
*/
object H2DBVendor extends ConnectionManager {
// create the connection pool
private val cp = org.h2.jdbcx.JdbcConnectionPool.create(
@eltimn
eltimn / Boot.scala
Created May 7, 2010 14:40 — forked from tbje/Boot.scala
Scheduled Tasks via Actor
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
@eltimn
eltimn / gist:795373
Created January 25, 2011 18:41
Joda Period Field
import org.joda.time.{DateTime, DateTimeConstants, Period => JodaPeriod}
import org.joda.time.format.ISOPeriodFormat
object waiverSetting extends StringField(this, 32) {
override def optional_? = true
override def displayName = "Waiver Period"
val periodFormatter = ISOPeriodFormat.standard
override def defaultValue = periodFormatter.print(new JodaPeriod)
def period: JodaPeriod = periodFormatter.parsePeriod(value)
def setFromForm(d: Int, h: Int, m: Int) = setBox(Full(
@eltimn
eltimn / PasswordField
Created February 8, 2011 13:33
Lift-Record Password Field
import java.util.regex._
import scala.xml._
import org.mindrot.jbcrypt.BCrypt
import net.liftweb._
import common._
import http.S
import http.js._
import json.JsonAST.{JNothing, JNull, JString, JValue}
#!/usr/bin/python3.1
# This is script that extracts the trees of two commits to temporary
# directories and then runs meld on both directories, so you can compare
# them using meld's nice recursive browsing interface.
#
# This is for an answer to this question:
# http://stackoverflow.com/questions/2006032/view-differences-of-branches-with-meld
from subprocess import call, Popen, PIPE, check_call
@eltimn
eltimn / JavaScript.scala
Created July 9, 2011 15:27
Lift snippet for serving versioned javascript files.
import scala.collection.mutable.{HashMap, SynchronizedMap}
import scala.xml._
import net.liftweb._
import common._
import http._
import util.Props
import util.Helpers._
/*
@eltimn
eltimn / Boot.scala
Created December 5, 2011 17:23
Mixing HTML5 and XML support in Lift
class Boot extends Loggable {
def boot {
// set the default htmlProperties
LiftRules.htmlProperties.default.set((r: Req) => new XHtmlInHtml5OutProperties(r.userAgent))
// set htmlProperties based on uri
LiftRules.earlyInStateful.append(HtmlPropertiesManager.testUri)
}
}
@eltimn
eltimn / PayPalInfoField.scala
Created April 23, 2012 18:49
Save PayPayInfo in Lift-MongoDB
import scala.xml.NodeSeq
import net.liftweb._
import common._
import json._
import json.ext.{EnumSerializer, JsonBoxSerializer}
import mongodb.JObjectParser
import mongodb.record.BsonRecord
import mongodb.record.field.MongoFieldFlavor
import record.{Field, FieldHelpers, MandatoryTypedField}
@eltimn
eltimn / PaypalTransaction.scala
Created April 23, 2012 19:04
Lift-MongoDB PayPalTransaction
import java.math.MathContext
import net.liftweb.record.field._
import net.liftweb._
import common._
import json._
import json.ext.{EnumSerializer, JsonBoxSerializer}
import mongodb.record._
import mongodb.record.field._
import paypal._