Skip to content

Instantly share code, notes, and snippets.

View jeppenejsum's full-sized avatar

Jeppe Nejsum Madsen jeppenejsum

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jeppenejsum on github.
  • I am nejsum (https://keybase.io/nejsum) on keybase.
  • I have a public key ASB6obXfp5wSoBmgdbO6Mf4fwhCEqRRYhqW84agBYaws9go

To claim this, I am signing this object:

@jeppenejsum
jeppenejsum / CookieVerifier.scala
Created March 14, 2013 11:41
Check if cookies are enabled
package fleetzone
package http
import net.liftweb.http._
import net.liftweb.http.provider._
import net.liftweb.sitemap._
import net.liftweb.common._
import net.liftweb.util._
@jeppenejsum
jeppenejsum / Anorm.scala
Created June 5, 2012 16:47
Slow Anorm parser
private def parser: RowParser[VehicleListItem] = {
long("org_unit_id")~str("vin")~(str("license_plate") ?)~(str("driver") ?)~(str("leasing_company") ?)~(date("contract_start")?)~(int("contract_duration")?) map {
case ou~vin~licensePlate~driver~lc~contractStart~duration =>
VehicleListItem(java.util.UUID.randomUUID, VIN(vin), OrgUnitId(ou), licensePlate.getOrElse(""), driver.getOrElse(""), lc.getOrElse(""),contractStart.map(LocalDate.fromDateFields(_)), duration.getOrElse(0))
}
}
private def specParser: RowParser[VehicleListSpec] = {
str("vehicle_type")~str("brand")~str("model")~str("variant")~(str("body_type")?) map {
case vt~b~m~variant~bt => VehicleListSpec(vt,b,m,variant,bt.getOrElse(""))
@jeppenejsum
jeppenejsum / gist:1139035
Created August 11, 2011 06:46
Rails FK hack in JRuby
module ::ArJdbc
module PostgreSQL
module Column
print "In module"
def disable_referential_integrity(&block)
print "disable jdbc"
transaction {
begin
execute "SET CONSTRAINTS ALL DEFERRED"
yield
def itemListActionsTemplate : NodeSeq = <xml:group>
<a crud:edit_href="" title={S.??("edit")} class="ss_sprite ss_pencil" ></a>
<a crud:delete_href="" title={S.??("delete")} class="ss_sprite ss_delete"></a>
</xml:group>
def itemListActions(item: CrudType, in:NodeSeq):NodeSeq = {
bind("crud", in,
AttrBindParam("edit_href", Text(editItemPathString+"/"+ (obscurePrimaryKey(item))),"href"),
AttrBindParam("view_href", Text(viewPathString+"/"+(obscurePrimaryKey(item))),"href"),
AttrBindParam("delete_href", Text(deletePathString+"/"+ (obscurePrimaryKey(item))),"href")
trait PaymentComponent {
val paymentService: PaymentService
trait PaymentService {def pay(what: String) }
}
trait PaypalPaymentService extends PaymentComponent {
override val paymentService:PaymentService = new PaypalImpl
class PaypalImpl extends PaymentService {
def pay(what: String) = println("Paypal payment for "+what)
}