Skip to content

Instantly share code, notes, and snippets.

View eltimn's full-sized avatar
🌏

Tim Nelson eltimn

🌏
View GitHub Profile
@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 / 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 / .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
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 / KoForm.scala
Created December 12, 2012 23:48
This is an example of using knockout.js with Lift to create a form. It allows you to utilize all of knockout's form capabilities combined with Lift's built-in ajax callbacks. AnonFunc is used to create a JavaScript function that is passed to the view model and called when the form is submitted.
package code.snippet
import net.liftweb._
import http.js._
import http.js.JE._
import http.js.JsCmds._
import http.json._
import util.Helpers._
object KoForm {
@eltimn
eltimn / MarkdownTypedField.scala
Last active December 15, 2015 16:59
A lift Record Field for storing and converting Markdown. Uses Actuarius - https://github.com/chenkelmann/actuarius
package code.model
import scala.xml._
import net.liftweb.util._
import net.liftweb.common._
import net.liftweb.http.S
import net.liftweb.record._
import net.liftweb.record.field._
import S._
@eltimn
eltimn / Build.scala
Last active December 22, 2015 12:49
SBT build with deploy.
import sbt._
import sbt.Keys._
object MyBuild extends Build {
import Dependencies._
import BuildSettings._
lazy val main = Project("root", file("."))
.settings(mainWebSettings: _*)
.settings(
@eltimn
eltimn / gist:9232958
Created February 26, 2014 16:24
GIT: ignoring changes in tracked files
There may be times when you want to edit some variables in for example a database connection file, to run an application right from within your GIT repo. Of course you don’t wont those changes to be commited, so you add the file the .gitignore.
However adding tracked files to .gitignore won’t work because GIT will still track the changes and commit the file if you use the -a parameter.
Fortunately GIT has a very easy solution for this, just run the following command on the file or path you want to ignore the changes of:
git update-index --assume-unchanged <file>
If you wanna start tracking changes again run the following command:
git update-index --no-assume-unchanged <file>
You can find more info about this in the git manual.
@eltimn
eltimn / 0_reuse_code.js
Created June 1, 2014 10:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eltimn
eltimn / gist:c5a5827dc589d20d3681
Created November 5, 2014 10:53
Lift Mongo Enum List Field Example
object enumFieldArray extends MongoListField[SomeEntity, Enum](this) {
val enum = SomeEnum
override def asDBObject: DBObject = {
val dbl = new BasicDBList
value.foreach { f => dbl.add(f.toString) }
dbl
}
override def setFromDBObject(dbo: DBObject): Box[MyType] = {