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
import java.util.regex._ | |
import scala.xml._ | |
import org.mindrot.jbcrypt.BCrypt | |
import net.liftweb._ | |
import common._ | |
import http.S | |
import http.js._ | |
import json.JsonAST.{JNothing, JNull, JString, JValue} |
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
// ########################################################### | |
// | |
// Demonstrates how to supervise an Akka consumer actor. | |
// | |
// The consumer consumes messages from a file endpoint: | |
// - successful message processing by the consumer will | |
// positively acknowledge the message receipt, causing | |
// the file endpoint to delete the file. | |
// - an exception during message processing will cause a | |
// supervisor to restart the consumer. Before restart, |
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
import akka.amqp.AMQP._ | |
import akka.amqp._ | |
import akka.actor._ | |
import java.util.concurrent.{TimeUnit, CountDownLatch} | |
import util.Random | |
object LoadBalancingDemo { | |
def main(args: Array[String]) { |
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
require 'rubygems' | |
require 'json' | |
require 'redis' | |
class RedisComments | |
def initialize(redis,namespace,sort_proc=nil) | |
@r = redis | |
@namespace = namespace | |
@sort_proc = sort_proc | |
end |
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
case class Config(name: String="none") | |
def methodNeedingAConfig(implicit config: Config = Config()) = config.name | |
// by default there is no config | |
methodNeedingAConfig === "none" | |
// just add one in the current scope | |
implicit val myConfig = Config("some") |
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
Show hidden characters
{ | |
"cmd": ["sbt-no-color compile"], | |
"file_regex": "^\\[error\\] ([.a-zA-Z0-9/-]+[.]scala):([0-9]+):", | |
"selector": "source.scala", | |
"working_dir": "${project_path:${folder}}", | |
"shell": "true" | |
} |
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
/** | |
* Part Zero : 10:15 Saturday Night | |
* | |
* (In which we will see how to let the type system help you handle failure)... | |
* | |
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0) | |
*/ | |
import scalaz._ | |
import Scalaz._ |
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
<html> | |
<head></head> | |
<body> | |
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoYAAABdCAYAAAA47Ke8AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAIABJREFUeF7tnQlgU1XWx1+2ZmvTpm2S7vu+Q8GybwIiihvijOM26jg68o3bqOPMqLgrbozO6IjruA+KCCgICLKVRaBAoXTfk6bZk6ZpsyfffelCWpo0aV7apD1v5pkm79xzz/3dm/bPfe+eS3rmk08Y0eRENodpZzNC6aFhLAabQWeyOehnJpPBZjEZoRjBB2W4v0s+GDBweeGSiMhExuihs0uj8yBeD0w8acrQED0M2JVjFBNBYY1cwyXh9dXmjzrdk+i/6o+KndvjY3fgbPpcEBColy68NB+hvz1ovAsTD0q6+Wo4RT628Wzvdz7wOlCX83u7Ff/U8R/M6XOruzLOtm59OzXOpR2q2tW1vs/7YhsWn6syDuNBf3Z0DAPc/57q4nOLy7oGwkAFR+RK7f8ceXDPzikmJ1/D67Vjg6GgS9SRfV5S3uxs56rt/VX1+7QPKTOE89B2UC/6c1NmSDvsNKd4TI6uGTL2Bo3t7pgNbQd61+cjZGgZu9F12+1DbUcdH67HzeBAHNHHkP4YNvaG+xywZbi3G9IHAz7sdpbT5z2IqvN7B2XH9eF12myuvxu2sIucbU4xOf+M+4zov2az2UaMDbcZfm34e6u17/eLxWIZ4sP5vcmUMXhNnze0r0uHfsfc//7oH2S+/S4e9lsE3gIBIAAEgAAQAAJAAAgELwEQhiP0nfXMWW7wdilEDgSAABAAAkAACACBsREAYTiMG8lmIxlee+2GseGEUkAACAABIAAEgAAQCF4CIAyd+s7W1sbq/t3Nf7Q21M8O3i6FyIEAEAACQAAIAAEgMDYC6BlgOHBB2Lthw+WWipNLSSYTmwRIgAAQAAJAAAgAASAwBQlMWWFIMptJv |
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
((ns excel.core | |
(:import [org.apache.poi.hssf.usermodel HSSFWorkbook HSSFSheet HSSFRow | |
HSSFRichTextString HSSFFont HSSFDataFormat | |
HSSFCellStyle HSSFCell]) | |
(:import [java.io FileOutputStream FileInputStream IOException]) | |
#_(:import [org.apache.poi.ss.util CellRangeAdrress])) | |
(defn make-excel [file-name] | |
(let [wb (HSSFWorkbook.) |
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
trait Enum { //DIY enum type | |
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
type EnumVal <: Value //This is a type that needs to be found in the implementing class | |
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
val oldVec = get |