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 akka.stm._ | |
import scala.collection.immutable.ListMap | |
case class LRUCache[A, B](private val MAX_ENTRIES: Int) | |
{ | |
protected val cache = Ref(ListMap.empty[A, B]) | |
def getOrElse(key: A)(fn: => B): B = { | |
get(key).getOrElse { | |
val result = fn |
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
-module(objectid). | |
-author("[email protected]"). | |
-export([binary_to_hex/1]). | |
extract_binary_data(BsonObjectId) -> | |
case BsonObjectId of {Binary} -> Binary; Binary -> Binary end. | |
binary_to_hex(BsonObjectId) -> | |
Binary = extract_binary_data(BsonObjectId), | |
list_to_binary(lists:flatten([io_lib:format("~2.16.0b", [X]) || <<X:8>> <= Binary])). |
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 python2.6 | |
import abc | |
class Kind(object): | |
__metaclass__ = abc.ABCMeta | |
kindtypes = dict() | |
datatypes = list() |
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 com.olchovy.format | |
import scala.xml._ | |
import net.liftweb.json.JsonAST._ | |
trait Formatter[-A, B] { | |
def format(a: A): B | |
} | |
object Formatters { |
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
function Debug() { | |
var frame = window.open("", "Debugger", "location=no,scrollbars=yes,height=300,width=400"); | |
var console = frame.document.createElement("div"); | |
console.setAttribute("id", "console"); | |
console.style.margin = "auto"; | |
console.style.width = "350px"; | |
console.style.overflow = "auto"; | |
frame.document.body.appendChild(console); |