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
alias rebash="source ~/.bashrc" | |
function ff { | |
grep -H -R -o -n -I "$*" * | |
} | |
function ffi { | |
grep -H -R -o -n -i -I "$*" * | |
} |
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
brew install growlnotify | |
cat >> ~/.bashrc <<EOF | |
#flatMapThatShit reminder | |
if [ -f /tmp/flatMapThatShit ]; then | |
kill \`cat /tmp/flatMapThatShit\` | |
fi | |
while true; do if [[ \$RANDOM%12 -eq 0 ]]; then growlnotify -a TextEdit "Is that scala?" -m "flatMap that shit"; fi; sleep 300; done & |
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
package demo | |
trait Bar | |
abstract class Foo[T] {} | |
object Foo { | |
implicit def FooFromBar[T <: Bar : Manifest]: Foo[T] = new Foo[T] { } | |
def apply[T : Foo] = implicitly[Foo[T]] | |
def baz[T : Foo](arg: T): Unit = { println("ha!")} | |
} |
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
trait Finder[RecordType] { | |
def findAll(ids: Seq[Long]): Seq[RecordType] = Nil | |
def find(id: Long): Option[RecordType] = None | |
} | |
abstract class Bar { def id: Long } ; object Bar extends Finder[Bar] | |
abstract class Baz { def id: Long } ; object Baz extends Finder[Baz] | |
abstract class Foo { | |
def id: Long | |
def barId: Long // this could be here as a MongoForeignObjectId thanks to a Bar.FK trait too | |
def bazId: Long |
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
<!doctype html> | |
<html> | |
<head> | |
<title></title> | |
<style> | |
body { | |
background: white; | |
text-align: center; | |
padding: 20px; | |
font-family: Georgia, serif; |
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: define one method which can be given arguments of different types (i.e. without a common supertype) | |
// lift (diaf) uses setFromAny(arg: Any) and a match, but in doing so loses typesafety. | |
case class Foo(i: Int) | |
case class Bar(v: String) | |
case class Baz(d: Boolean) | |
val foo = Foo(1) | |
val bar = Bar("1") | |
val baz = Baz(false) |
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
#!/usr/bin/env python | |
import sys, os, json | |
from rdioapi import Rdio | |
from collections import defaultdict | |
config_path = os.path.expanduser('~/.rdio-tool.json') | |
if os.path.exists(config_path): | |
config = json.load(file(config_path)) | |
else: |
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
package demo | |
package ids { | |
import record.Id | |
object FooId extends Id[Int] | |
object BarId extends Id[Int] | |
object BazId extends Id[String] | |
} | |
package foomodel { |
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 CachedWS { | |
def apply[T](key: String)(f: => Promise[Option[T]])(implicit m: scala.reflect.ClassManifest[T]): Promise[Option[T]] = | |
Cache.getAs[T](key).map(t => Promise.pure(Some(t))).getOrElse{f.map(_.map{ t => Cache.set(key, t); t})} | |
} |
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
package controllers | |
import play.api._ | |
import play.api.mvc._ | |
import play.api.libs.oauth._ | |
import play.api.libs.ws.WS | |
object Application extends Controller { | |
object MyApi { |
OlderNewer