Skip to content

Instantly share code, notes, and snippets.

@gseitz
gseitz / REPL session
Created July 1, 2011 05:42
Create 1-line extractors for traits
scala> trait YouCantMatchMe
defined trait YouCantMatchMe
scala> object YesICan extends Traitor[YouCantMatchMe]
defined module YesICan
scala> def uncatchable_?(any: Any) = any match {
| case YesICan(uncatchable) => Some(uncatchable)
| case _ => None
| }
module TicTacToe
( Player
, Position
, Board
, InProgress
, Finished
, GameBoard
, Playable
, Completed
, move
@gseitz
gseitz / giter8.rb
Created November 18, 2010 22:11
Brew your own tasty giter8!
require 'formula'
class Giter8 <Formula
JAR = 'sbt-launch-0.7.4.jar'
url "http://simple-build-tool.googlecode.com/files/#{JAR}"
homepage 'http://github.com/n8han/giter8'
md5 '8903fb141037056a497925f3efdb9edf'
version '0.1.1'
def install
mkdir bestappever && cd bestappever
g8 gseitz/android-sbt-project
sbt update
sbt compile
// dependency: org.apache.httpcomponents %% httpclient % 4.0.1
class SSLTest {
import javax.net.ssl.SSLContext
import org.apache.http.conn.ssl.SSLSocketFactory
val ctx = SSLContext.getInstance("TLS")
ctx.init(null, null, null)
val sf = new SSLSocketFactory(ctx)
// A simple trait:
trait CascadingActions {
implicit def tToActioneerT[T](t: T) = Actioneer(t)
case class Actioneer[T](tee: T) {
def withAction(action: (T => Unit)): T =
withActions(action)
def withActions(actions: (T => Unit)*): T = {
#!/bin/sh -e
if [ ! $SBT_VERSION ]; then SBT_VERSION=0.7.4; fi
if [ ! $SBT_DIR ]; then SBT_DIR=$HOME/.sbt; fi
if [ ! $SBT_FILENAME ]; then SBT_FILENAME=sbt-launch-$SBT_VERSION.jar; fi
if [ ! $SBT_LOCATION ]; then SBT_LOCATION=$SBT_DIR/$SBT_FILENAME; fi
SBT_URL="http://simple-build-tool.googlecode.com/files/$SBT_FILENAME"
if [ ! -f $SBT_LOCATION ];