Skip to content

Instantly share code, notes, and snippets.

@d6y
d6y / log.txt
Created October 19, 2011 17:20
Packaging twitter util log
# I'm using Java 1.6 on Mac 10.7.2
# The sbt7 command is a shell script to start sbt 0.7 defined as:
~$ more /opt/sbt7/sbt
java -XX:MaxPermSize=612m -Xmx912M $JAVA_OPTS $WITH_REBEL -jar `dirname $0`/sbt-launch.jar "$@"
~$ echo $JAVA_OPTS
-Dfile.encoding=utf8
@d6y
d6y / gist:1309016
Created October 24, 2011 13:23
Unsubscribe redo
object Unsubscribe {
/* A menu for Lift's Sitemap which maps /unsubscribe/{uuid} to two
functions: 1) given a uuid, lookup a Subscription instance
2) given a Subscription instance, create the link address... */
val menu = Menu.param[Subscription]("Unsubscribed", "Unsubscribed",
uuid => Subscription.find(By(Subscription.uuid, uuid)),
s => s.uuid ) / "unsubscribed" >> Hidden
/* The Loc(ation) part of the menu is what we're going to work with... */
@d6y
d6y / gist:1366622
Created November 15, 2011 10:04
lifty 1.7 log attempt 1
~$ vi ~/.sbt/plugins/build.sbt
~$ cat ~/.sbt/plugins/build.sbt
addSbtPlugin("org.lifty" % "lifty" % "1.7")
~$ cd tmp
tmp$ mkdir lt
tmp$ cd lt/
lt$ sbt11
#############################################################
@d6y
d6y / gist:1481964
Created December 15, 2011 17:25
Lift bookmarklet
// In our case, we have /bookmarklet/{uuid}?title={page title}&url={page url}
// In Boot:
LiftRules.statelessDispatchTable.prepend(Bookmarklet.dispatch)
// The bookmarklet itself....
object Bookmarklet extends Loggable {
def dispatch: LiftRules.DispatchPF = {
@d6y
d6y / App.scala
Created January 19, 2012 10:31
Snipet for reading version.txt
package org.example.project.snippet
import scala.xml._
import net.liftweb.util.Helpers._
/* Access to the build number (e.g., supplied by Hudson/Jenkins)
Example usage:
<lift:App.version> Project:<v:project/> Build:<v:number/> </lift:App.version>
@d6y
d6y / gist:2044351
Created March 15, 2012 14:04
cigar
import org.specs2.runner._
import org.specs2.mutable._
import org.junit.runner._
import com.codecommit.antixml._
@RunWith(classOf[JUnitRunner])
class NoCigar extends Specification {
@d6y
d6y / gist:2906122
Created June 10, 2012 15:08
Example of conditionally enabling analytics
import bootstrap.liftmodules.GoogleAnalytics
import GoogleAnalytics.dsl._
GoogleAnalytics.init {
only when S.cookieValue("cookie_consent").isDefined
}
@d6y
d6y / gist:2906148
Created June 10, 2012 15:14
Analytics notification
GoogleAnalytics.alertUser ( only when S.cookieValue("cookie_consent").isEmpty ) {
JsAlert("We set Cookies")
}
@d6y
d6y / gist:2906159
Created June 10, 2012 15:18
Example cookie notification
import bootstrap.liftmodules.GoogleAnalytics
import GoogleAnalytics.dsl._
// Always track
GoogleAnalytics.init
// Provide a one-time banner, based on the absence of a cookie:
GoogleAnalytics.alertUser( only when( S.cookieValue("ckns_policy").isEmpty ) {
import net.liftweb.http.js._
import JE._
@d6y
d6y / dull.java
Created July 8, 2012 18:12
Dull data access
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
ContactEntry entry = resultFeed.getEntries().get(i);
if (entry.hasName()) {
Name name = entry.getName();
if (name.hasFullName()) {
...