Skip to content

Instantly share code, notes, and snippets.

View eltimn's full-sized avatar
🌏

Tim Nelson eltimn

🌏
View GitHub Profile
trait GroupMenu extends SnippetHelpers {
def itemHtml: NodeSeq
def itemActiveHtml: NodeSeq
def outerHtml: NodeSeq
def render(in: NodeSeq): NodeSeq = {
for {
group <- S.attr("group") ?~ "Group not specified"
sitemap <- LiftRules.siteMap ?~ "Sitemap is empty"
@eltimn
eltimn / .gitconfig
Created October 4, 2012 14:31
My .gitconfig file
[user]
name = ********
email = ***********
[alias]
au = add -u
br = branch
ci = commit
cia = commit --amend
co = checkout
@eltimn
eltimn / gist:3379256
Created August 17, 2012 14:38
Get reference to an object via it's class name
// Say you have some case objects like this:
package code
sealed trait Concept
case object Address extends Concept
case object City extends Concept
// From these you can create an html select list:
<select name="concept">
@eltimn
eltimn / new-install.sh
Created May 9, 2012 14:24
New Install
#!/bin/sh
# Things to do after a fresh install
# Ubuntu 12.04 LTS
# Author : Tim Nelson <http://eltimn.com/>
# License : Apache 2.0
# update system
sudo apt-get update
sudo apt-get upgrade
@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._
@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 / 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 / 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._
/*
#!/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 / 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}