Skip to content

Instantly share code, notes, and snippets.

@BowlingX
BowlingX / gist:2633780
Created May 8, 2012 09:08
Atmosphere with Scalatra and Apache Shiro
get("/status") {
val currentUser = SecurityUtils.getSubject();
// Save current User to request, because this request will be suspended and forked in another thread.
// See: http://jfarcand.wordpress.com/2011/07/13/quick-tip-using-apache-shiro-with-your-atmospheres-websocketcomet-app/
request.setAttribute("subject", currentUser);
import org.atmosphere.cpr.HeaderConfig._
contentType = ContentType.JSON
val m: Meteor = Meteor.build(request)
m.addListener(new EventsLogger())
// Create or retrieve Broadcaster for current User
@BowlingX
BowlingX / gist:2075392
Created March 18, 2012 15:30
How to run code from yourLibrary in sbt with a task
/*File Runner:scala*/
package com.myCompany
object Runner extends App {
val myArgument = args(0)
/*Do whatever you want :)*/
}
@BowlingX
BowlingX / gist:2070600
Created March 18, 2012 11:15
SBT Reflective load a Class on fullClasspath
/* File: Build.scala in ~/project */
/*...Build Definition...*/
/* This Task should load a Class on my Project*/
val taskKey = TaskKey[Unit]("task-name", "task-description")
val myTask = taskKey <<= (fullClasspath in Runtime, scalaInstance) map { (cp, si) =>
Cookies:
http://192.168.2.111:8080/login/test/blub?locale=de -> cookie path is /login/test
http://192.168.2.111:8080/login/test -> cookie path is /login
http://192.168.2.111:8080/login -> cookie path is /
@BowlingX
BowlingX / gist:1647010
Created January 20, 2012 11:49
Accept Language locale extraction
package org.scalatra.i18n
import org.scalatra.{CookieSupport, ScalatraKernel}
import java.util.Locale
import org.scalatra.i18n.Messages
object I18nSupport {
def localeKey = "locale"
@BowlingX
BowlingX / gist:1471538
Created December 13, 2011 10:18
Mapping and Settings Geonames
{
state: open
settings: {
index.analysis.filter.name_ngrams.side: front
index.analysis.filter.name_ngrams.type: edgeNGram
index.analysis.analyzer.partial.tokenizer: standard
index.store: memory
index.number_of_replicas: 1
index.analysis.analyzer.partial.filter.3: name_ngrams
index.analysis.analyzer.partial_non_ascii.filter.2: name_ngrams
@BowlingX
BowlingX / gist:1452046
Created December 9, 2011 15:46
Geonames.org Meta for elastic search
{
state: open
settings: {
index.analysis.filter.name_ngrams.side: front
index.analysis.filter.name_ngrams.type: edgeNGram
index.analysis.analyzer.full_name.type: custom
index.analysis.filter.name_ngrams.max_gram: 40
index.analysis.analyzer.full_name.tokenizer: standard
index.analysis.analyzer.partial_name.filter.3: name_ngrams
index.analysis.filter.name_ngrams.min_gram: 2