Skip to content

Instantly share code, notes, and snippets.

(*
Generate SWF from a ActionScript bytecode file.
abc2swf filename.abc [width height]
build:
ocamlc -g -I ocaml -I ocaml/swflib ocaml/extLib.cma ocaml/swflib/swflib.cma -o abc2swf abc2swf.ml
*)
open Swf
@richq
richq / eclipse_cdt.py
Created October 16, 2009 18:33
Eclipse CDT 5.0 generator for Waf http://code.google.com/p/waf/
# Eclipse CDT 5.0 generator for Waf http://code.google.com/p/waf/
# New BSD License
import sys
import os
import Utils
import Logs
from Constants import APPNAME
from xml.dom.minidom import Document
import Options
(ns com.example.service
(:refer-clojure)
(:import javax.jws.WebMethod
javax.jws.WebParam
javax.jws.WebService))
(definterface FooBarInterface
(#^String frobbleBaz [#^String name
#^String address
@retronym
retronym / collection-unfold.scala
Created June 24, 2010 04:26
List.unfold(0){ a => if (a < 10) Some(a + 1, a.toString) else None}
import scala.collection.generic._
object RichTraversableCompanion {
implicit def pimp[CC[X] <: Traversable[X] with GenericTraversableTemplate[X, CC], T](comp: TraversableFactory[CC]) = new RichTraversableCompanion[CC](comp)
}
class RichTraversableCompanion[CC[X] <: Traversable[X] with GenericTraversableTemplate[X, CC]](comp: TraversableFactory[CC]) {
def unfold[A, B](seed: A)(f: A => Option[(A, B)]): CC[B] = {
val builder = comp.newBuilder[B]
@annotation.tailrec
@javouhey
javouhey / sbt on cygwin
Created November 29, 2010 12:10
Getting sbt to work in cygwin 1.77
dir=`dirname $0`
stty -icanon min 1 -echo > /dev/null 2>&1
java -Djline.terminal=jline.UnixTerminal -Xmx512M -jar `cygpath -w $dir`/sbt-launch-0.7.4.jar "$@"
stty icanon echo > /dev/null 2>&1
@viktorklang
viktorklang / UnnestedReceives.scala
Created January 26, 2011 17:16
Unnesting a Scala Actors nested receive example
/**
* 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 "$@"
@viktorklang
viktorklang / CQRS_ES_Actor.scala
Created February 1, 2011 15:05
CQRS and EventSourcing using Akka Actors
import scala.collection.mutable.ListBuffer
import akka.actor.{Actor,ActorRef}
import akka.actor.Actor._
import akka.routing.{ Listeners, Listen }
//Represents a domain event
trait Event
//A builder to create domain entities
trait EntityBuilder[Entity] {
@viktorklang
viktorklang / PostStart.scala
Created March 5, 2011 23:13
PostStart implementation for Akka
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
actor.become {
case "PostStart" => try { postStart } finally { actor.unbecome }
}
actor.self ! "PostStart"
}
}
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._