Skip to content

Instantly share code, notes, and snippets.

View tjweir's full-sized avatar

Tyler Weir tjweir

View GitHub Profile
import net.liftweb.util.ActorPing
import net.liftweb.common.Logger
class Boot extends Logger {
def boot {
// where to search snippet
LiftRules.addToPackages("your.package")
...
val myActor = new MyActor
myActor ! Msg
package net.liftweb {
package mapper {
import net.liftweb.persistence.{MetaSimpleUser, SimpleUser}
import net.liftweb.mapper._
import net.liftweb.util.Helpers
trait MapperUser[T <: MapperUser[T]] extends SimpleUser[T] with LongKeyedMapper[T] with IdPK {
self: T =>
import se.scalablesolutions.akka.actor.Actor._
import se.scalablesolutions.akka.patterns.Patterns._
import se.scalablesolutions.akka.patterns.CyclicIterator
//Our message types
case object Ping
case object Pong
//Two actors, one named Pinger and one named Ponger
//The actor(pf) method creates an anonymous actor and starts it
// Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_20).
// Type in expressions to have them evaluated.
// Type :help for more information.
scala> import dispatch._
import dispatch._
scala> import oauth._
import oauth._
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
<forwarder>
<in>
<connect addr="tcp://127.0.0.1:5555"/>
</in>
<out>
<bind addr="tcp://127.0.0.1:5556"/>
</out>
</forwarder>
// generate ensime config
lazy val genEnsime = task (args => {
if (args.length == 1) {
genEnsimeConstructor(args(0).toString)
} else {
task { Some("Usage: gen-ensime <project package name>") }
}
}) describedAs("Generate a .ensime file for this project")
def genEnsimeConstructor(packageName: String) = task {
// generate ensime config
lazy val genEnsime = task (args => {
if (args.length == 1) {
genEnsimeConstructor(args(0).toString)
} else {
task { Some("Usage: gen-ensime <project package name>") }
}
}) describedAs("Generate a .ensime file for this project")
def genEnsimeConstructor(packageName: String) = task {
/**
* I had a question directed at me, on how to encode the following scenario in Akka Actors,
* as for Scala Actors one would simply nest the receives.
*
* Recuirements are as follows:
* The first thing the actor needs to do, is to subscribe to a channel of events,
* Then it must replay (process) all "old" events
* Then it has to wait for a GoAhead signal to begin processing the new events
* It mustn't "miss" events that happen between catching up with the old events and getting the GoAhead signal
*/
_SCRIPT_PATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
_SCRIPT_DIR=`dirname "${_SCRIPT_PATH}"}`
_EXTRADOC_HOME=${_SCRIPT_DIR}/..
export TOOL_CLASSPATH="${_EXTRADOC_HOME}/target/scala_2.8.0/classes:${_EXTRADOC_HOME}/src/main/resources"
export JAVA_OPTS="-Xms512M -Xmx2048M -Xss1M -XX:MaxPermSize=128M"
scala -classpath ${TOOL_CLASSPATH} com.novocode.extradoc.ExtraDoc "$@"