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
a, b = 0, 1 | |
while still_has_lock(): | |
time.sleep(a + b) | |
a, b = b, a+b | |
# Fibonacci WTF ! |
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
# Install with: | |
# bash < <(curl -L https://raw.github.com/gist/1333785) | |
# | |
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug | |
echo "Installing ruby-debug with ruby-1.9.3-p125 ..." | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem | |
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem |
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
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 2K bytes over 1 Gbps network 20,000 ns | |
Read 1 MB sequentially from memory 250,000 ns | |
Round trip within same datacenter 500,000 ns | |
Disk seek 10,000,000 ns |
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
java.lang.NullPointerException | |
at play.core.server.netty.RequestBodyHandler$$anonfun$1.apply(RequestBodyHandler.scala:45) | |
at play.core.server.netty.RequestBodyHandler$$anonfun$1.apply(RequestBodyHandler.scala:43) | |
at scala.concurrent.stm.ccstm.InTxnImpl.runBlock(InTxnImpl.scala:538) | |
at scala.concurrent.stm.ccstm.InTxnImpl.topLevelAttempt(InTxnImpl.scala:494) | |
at scala.concurrent.stm.ccstm.InTxnImpl.topLevelAtomicImpl(InTxnImpl.scala:365) | |
at scala.concurrent.stm.ccstm.InTxnImpl.atomic(InTxnImpl.scala:244) | |
at scala.concurrent.stm.ccstm.CCSTMExecutor.apply(CCSTMExecutor.scala:24) | |
at play.core.server.netty.RequestBodyHandler$class.pushChunk$1(RequestBodyHandler.scala:43) | |
at play.core.server.netty.RequestBodyHandler$$anon$1.messageReceived(RequestBodyHandler.scala:89) |
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 play.api.mvc._ | |
trait CorsSupport { self: Controller => | |
def CorsAction(cb: => Result): Action[AnyContent] = | |
Action(cb.withHeaders(actionCorsHeaders: _*)) | |
def CorsAction(cb: Request[AnyContent] => Result): Action[AnyContent] = | |
Action { request => | |
cb(request).withHeaders(actionCorsHeaders: _*) |
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 bash | |
# Install script adapted from: | |
# https://gist.github.com/dwayne/2983873 | |
NODE_DIR="$HOME/.nodejs" | |
echo 'export PATH=$HOME/$NODE_DIR/bin:$PATH' >> ~/.bashrc | |
echo 'export NODE_PATH=$HOME/$NODE_DIR/lib/node_modules' >> ~/.bashrc | |
source ~/.bashrc |
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 object extensions { | |
import play.api.mvc._ | |
implicit class ResultExtensions(val result: PlainResult) | |
extends AnyVal { | |
def withLangCookie(lang: Lang)(implicit app: Application): PlainResult = | |
result.withCookies(Cookie(Play.langCookieName, lang.code, httpOnly = 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
// Helper for keeping track of the active project bindings | |
// (because we don't want to hard-code those inside singleton objects) | |
object Environment { | |
def currentBindings = | |
ref.get match { | |
case null => | |
throw new NullPointerException("No BindingModule currently registered (app not running?)") | |
case value => | |
value |
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 scalaz.concurrent.Task | |
def benchmark[T](repeat: Int)(callback: => T): Unit = { | |
var lastResult: Any = null | |
var total = Duration.Zero | |
for (i <- 0 until repeat) { | |
val time = System.nanoTime() | |
val result = callback | |
val measured = (System.nanoTime() - time).nanos |
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 fsm | |
import scala.annotation.implicitNotFound | |
import scala.util.control._ | |
import RefContext._ | |
import Ref._ | |
/** | |
* Ref is a scoped type-safe mutable reference. | |
* |