Skip to content

Instantly share code, notes, and snippets.

@BowlingX
BowlingX / gist:3933478
Created October 22, 2012 19:16
Scala Hazelcast Session Store
package com.bowlingx.model
import net.liftweb.mongodb.record.{MongoMetaRecord, MongoRecord}
import net.liftweb.mongodb.record.field.StringPk
import com.hazelcast.core.MapStore
import java.util
import com.bowlingx.util.Logging
import net.liftweb.record.field.{StringField, DateTimeField, BinaryField}
import java.io._
import util.Calendar
@BowlingX
BowlingX / gist:3933516
Created October 22, 2012 19:24
Hazelcast Map Configuration
<!-- Session Storage: -->
<map name="shiro-activeSessionCache">
<backup-count>1</backup-count>
<!-- Delete Sessions after one Hour if no access -->
<!-- https://groups.google.com/forum/?fromgroups=#!topic/hazelcast/iScOrTaSJbA -->
<max-idle-seconds>3600</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<map-store enabled="true">
<!--
Name of the class implementing MapLoader and/or MapStore.
@BowlingX
BowlingX / gist:3951597
Created October 25, 2012 09:23
Init Script for Java Application
#! /bin/sh
### BEGIN INIT INFO
# Provides: YourApp
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: YourShortDescription
# Description: YourDescription
### END INIT INFO
@BowlingX
BowlingX / gist:3951607
Created October 25, 2012 09:24
Bash Jar File Runner with log rotation
#!/bin/bash
set -e
XNAME="YourApp"
SCALATRA_ENV="production"
TMP_DIR="tmp/$XNAME/"
JAVA_OPTIONS=(-Xmx3024M -XX:MaxPermSize=512M)
LOGDIR="/usr/share/YourApp/logs/$XNAME"
PORT="9090"
JAVA_OPTIONS=("${JAVA_OPTIONS[@]}" "-Djava.io.tmpdir=$TMP_DIR")
JAVA_OPTIONS=("${JAVA_OPTIONS[@]}" "-Dorg.scalatra.environment=$SCALATRA_ENV")
@BowlingX
BowlingX / gist:3951613
Created October 25, 2012 09:26
Sample Scala Main with embedded Jetty
package com.bowlingx.run
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import com.bowlingx.util.Logging
/**
* This describes our Main Entry point to launch YourApp
* Launches an embedded Jetty Server
@BowlingX
BowlingX / gist:3958151
Created October 26, 2012 10:47
Flash Map with request Support
trait MyFlashMapSupport extends Handler {
this: CoreDsl with DynamicScope with SessionSupport =>
import FlashMapSupport._
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse) {
withRequest(req) {
val f = getFlash(req)
val isOutermost = !req.contains(lockKey)
if (isOutermost) {
@BowlingX
BowlingX / gist:4124688
Created November 21, 2012 12:45
assembly.sbt
import AssemblyKeys._
assemblySettings
mainClass in assembly := Some("com.yourCompany.YourMainClass")
@BowlingX
BowlingX / build.sbt
Created November 21, 2012 13:22 — forked from meniku/build.sbt
project/plugins.sbt
========================================================
libraryDependencies <+= sbtVersion(v => v match {
case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
})
@BowlingX
BowlingX / gist:4125027
Created November 21, 2012 14:13
Simple Jetty Launcher
package com.yourcompany
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
/**
* This describes our Main Entry point to launch YourApp
* Launches an embedded Jetty Server
*/
@BowlingX
BowlingX / gist:4125278
Created November 21, 2012 15:02
remove about
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList("javax", "servlet", xs @ _*) => (xs map {_.toLowerCase}) match {
case ("about.html" :: Nil) => MergeStrategy.discard
case _ => MergeStrategy.deduplicate
}
case x => old(x)
}
}