This file contains hidden or 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 ZzubZzif { | |
val fizzbuzz: PartialFunction[Int, String] = { | |
case x if x % 15 == 0 => "fizzbuzz" | |
case x if x % 5 == 0 => "buzz" | |
case x if x % 3 == 0 => "fizz" | |
} | |
// I'm actually embarrassed that this is the best I can do | |
def zzubzzif(seq: Seq[String]): Seq[Int] = { | |
val fizzbuzzIndexed = new PartialFunction[(Int, Int), (String, Int)] { |
This file contains hidden or 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
val fib: Stream[BigInt] = { | |
def nextFib(a: BigInt, b: BigInt): Stream[BigInt] = { | |
Stream.cons(a + b, nextFib(b, a + b)) | |
} | |
Stream.cons(0, Stream.cons(1, nextFib(0, 1))) | |
} |
This file contains hidden or 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
/** tap implementation for C++11 */ | |
template<typename T, typename F> | |
T tap(T &&obj, F const &fn) { | |
fn(obj); | |
return obj; | |
} | |
// usage | |
tap(new User(params), [](User *u) { | |
if (u->isValid()) { |
This file contains hidden or 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
// You've gotta start somewhere | |
import akka.dispatch.Future | |
implicit val system = akka.actor.ActorSystem("MySystem") | |
// lame | |
val WHY_YOU_TAKE_SO_LONG: Seq[Kitten] = | |
grep(theWorld, kittens) | |
// awesome | |
val allKittens: Future[Seq[Kitten]] = |
This file contains hidden or 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
getSomething(function(thing) { | |
doSomethingWithIt(thing, function(somethingElse) { | |
evenSomethingElse(somethingElse, function(inTooDeep) { | |
// result A | |
}) | |
}) | |
doSomethingElseWithIt(thing, function(somethingElse) { | |
// result B | |
}) | |
whenBothAreDone(thing, A, B) // magic! |
This file contains hidden or 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
scala> object ImaFunction { | |
| def apply() { println("I am a function") } | |
| } | |
defined module ImaFunction | |
scala> case class Sois(name: String) { | |
| def apply() { printf("%s is also a function", name) } | |
| } | |
defined class Sois |
This file contains hidden or 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
/* | |
* Asterisk -- An open source telephony toolkit. | |
* | |
* Copyright (C) 2012, Digium, Inc. | |
* | |
* David M. Lee, II <[email protected]> | |
* | |
* See http://www.asterisk.org for more information about | |
* the Asterisk project. Please do not directly contact | |
* any of the maintainers of this project for assistance; |
This file contains hidden or 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
/* | |
* Asterisk -- An open source telephony toolkit. | |
* | |
* Copyright (C) 2012, Digium, Inc. | |
* | |
* David M. Lee, II <[email protected]> | |
* | |
* See http://www.asterisk.org for more information about | |
* the Asterisk project. Please do not directly contact | |
* any of the maintainers of this project for assistance; |
This file contains hidden or 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 | |
TOPDIR=. | |
if test $1 && test -d $1; then | |
TOPDIR=$1 | |
shift | |
fi | |
TOPDIR=$(cd ${TOPDIR} && pwd) |
This file contains hidden or 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
This is an attempt to fix some linking problems compiling Digium's fork of PJSIP on OS X. | |
diff --git a/build/rules.mak b/build/rules.mak | |
index dc74f52..d5006c7 100644 | |
--- a/build/rules.mak | |
+++ b/build/rules.mak | |
@@ -14,6 +14,8 @@ SONAME = $($(APP)_SONAME) | |
ifeq ($(SHLIB_SUFFIX),so) | |
SHLIB_OPT := -shared -Wl,-soname,$(SONAME) |