This gist has been upgraded to a blog post here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
resize_rootfs: false | |
disk_setup: | |
/dev/sda: | |
table_type: 'mbr' | |
layout: | |
- 25 | |
- 75 | |
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Transformer[P, Q] { | |
protected def transform(x: P): Q | |
def apply(x: P): Q = transform(x) | |
} | |
object Int2StringTransformer extends Transformer[Int, String] { | |
def transform(x: Int): String = x.toString | |
} | |
object List2SetTransformer extends Transformer[List[_], Set[_]] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object TypeclasseDemo { | |
// The parts of the type class pattern are: | |
// | |
// 1. the "type class" itself -- a trait with a single type parameter; | |
// | |
// 2. type class "instances" for each type we care about, | |
// each marked with the `implicit` keyword; | |
// | |
// 3. an "interface" to the type class -- one or more methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# /etc/init.d/kafka: start the kafka daemon. | |
# chkconfig: - 80 20 | |
# description: kafka | |
KAFKA_HOME=/usr/share/kafka | |
KAFKA_USER=root | |
KAFKA_SCRIPT=$KAFKA_HOME/bin/kafka-server-start.sh | |
KAFKA_CONFIG=$KAFKA_HOME/config/server.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.language.higherKinds // lol | |
trait Functor[F[_]] { | |
def fmap[A, B](f: A => B): F[A] => F[B] | |
} | |
trait Apply[F[_]] { | |
def ap[A, B](f: F[A => B]): F[A] => F[B] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Artifactory start script for supervisord | |
# Derived from http://serverfault.com/questions/425132/controlling-tomcat-with-supervisor | |
ARTHOME=$HOME/artifactory-3.3.1 | |
function shutdown() { | |
echo "$(date): Shutting down Artifactory" | |
$ARTHOME/bin/artifactory.sh stop | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Please comment in case of typos or bugs | |
import scala.slick.driver.H2Driver._ | |
val db = Database.for...(...) | |
case class Record( ... ) | |
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){ | |
... | |
def * = ... <> (Record.tupled,Record.unapply) | |
// place additional methods here which return values of type Column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import shapeless._ ; import SingletonTypes._ ; import Record._ | |
import shapeless._ | |
import SingletonTypes._ | |
import Record._ | |
scala> :paste |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Goal: Use Scalding to datamine the 2010 US Census data (kindly provided by @ElonAzoulay & @hmason), to find | |
Where do the WEALTHY WELL EDUCATED ELITE live ? | |
WEALTHY == house value quarter million, household income 150k | |
WELL EDUCATED == sort by edu, edu = (10 * Phd + 5 * MS + 1 * BS) score | |
*/ | |
import com.twitter.scalding._ | |
import cascading.tuple.Fields | |
import cascading.tap.SinkMode |
NewerOlder