Skip to content

Instantly share code, notes, and snippets.

package com.banksimple.testing.util
import akka.actor._
class ReplayActor extends Actor {
var lastSeen: List[Any] = List()
override def receive: Receive = {
case 'dump => { self.reply(lastSeen) ; lastSeen = List() }
case a => lastSeen = a :: lastSeen
}
}
@mads-hartmann
mads-hartmann / bundles.sh
Created December 7, 2010 16:04
This is how I manage my textmate bundles.
#
# This script will install the following Textmate bundles
#
# Languages
# - c https://github.com/textmate/c.tmbundle
# - coffeescript https://github.com/jashkenas/coffee-script-tmbundle
# - context free https://github.com/textmate/context-free.tmbundle
# - erlang https://github.com/textmate/erlang.tmbundle
# - haskell https://github.com/textmate/haskell.tmbundle.git
# - html https://github.com/textmate/html.tmbundle
//Usage:
//override def pomPostProcess(node: Node): Node = mcPom(moduleConfigurations)(super.pomPostProcess(node))
trait McPom { self: DefaultProject =>
import scala.xml._
def mcPom(mcs: Set[ModuleConfiguration])(node: Node): Node = {
//make sure we have a trailing slash so we deduplicate URLs properly
def cleanUrl(url: String) = url match {
case null => ""
@oxbowlakes
oxbowlakes / range.scala
Created December 6, 2010 22:28
Range class for ranges [a, b], (a, b), (a, b], [a, b) where (a and b) may be unbounded
package test
import scalaz._
import Scalaz._
import test.IRange.Increment
sealed trait Limit[+Z] {
def open : Boolean
def bound : Option[Z]
final def closed = !open
@wrwills
wrwills / LensTest.scala
Created November 30, 2010 13:47
playing with some of the ideas from the Haskell fclabels library using the new Lens functionality in scalaz
import scalaz._
/**
* playing with some of the ideas from the Haskell fclabels library
* using the new Lens functionality in scalaz
*
* http://hackage.haskell.org/package/fclabels
*/
object LensTest {
scala> val l = List(1,2,3)
l: List[Int] = List(1, 2, 3)
// pattern matching
scala> l match {
| case s if s.forall(even(_)) => Some(l)
| case _ => None
| }
res37: Option[List[Int]] = None
@softprops
softprops / cookies.js
Created November 22, 2010 22:55
mini js cookie interface
var Cookies = function() {
return {
set: function (name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
} else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
},
// for comprehension
scala> for {
| l <- List(2,5,10)
| m <- List(8,10,11)
| } yield l * m
res17: List[Int] = List(16, 20, 22, 40, 50, 55, 80, 100, 110)
// map a pure function into applicatives
scala> List(8,10,11) <*> (List(2,5,10) map (((_: Int) * (_: Int)).curried))
res18: List[Int] = List(16, 20, 22, 40, 50, 55, 80, 100, 110)
@softprops
softprops / browser
Created November 9, 2010 04:14 — forked from defunkt/browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo "<h1>hi mom!</h1>" | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@softprops
softprops / murder.sh
Created November 3, 2010 05:39 — forked from defunkt/murder.sh
# sh function to murder all running processes matching a pattern
# thanks 3n: http://twitter.com/3n/status/19113206105
murder () {
ps | grep $1 | grep -v grep | awk '{print $1}' | xargs kill -9
}