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 ruby | |
require "rest-client" | |
require "ostruct" | |
require "json" | |
require "yaml" | |
require "cgi" | |
begin | |
require "ruby-debug" | |
rescue LoadError |
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
private def normalize(name: String) = Normalizer.normalize(name, Normalizer.Form.NFC).trim.toLowerCase. | |
replaceAll("""\P{IsL}""", ""). // Only keep letters | |
replaceAll(Normalizer.normalize("""[àâä]""", Normalizer.Form.NFC), "a"). // Then transliterate accented characters into non-accented ones | |
replaceAll(Normalizer.normalize("""[éèêë]""", Normalizer.Form.NFC), "e"). | |
replaceAll(Normalizer.normalize("""[îìï]""", Normalizer.Form.NFC), "i"). | |
replaceAll(Normalizer.normalize("""[ôòö]""", Normalizer.Form.NFC), "o"). | |
replaceAll(Normalizer.normalize("""[ûùü]""", Normalizer.Form.NFC), "u"). | |
replaceAll(Normalizer.normalize("""[ç]""", Normalizer.Form.NFC), "c") |
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.dispatch.{FutureTimeoutException, Future} | |
import akka.actor.Actor | |
object FutureTest { | |
def main(args: Array[String]) { | |
val f1: Future[Int] = Future({ | |
Thread.sleep(2000) | |
0 | |
}, 500) |
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 BDB { | |
val dbenv = { | |
new Environment(...) | |
} | |
def close() { | |
dbenv.close() | |
} | |
} |
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
select | |
aid | |
, abalance | |
, count(*) | |
from ( | |
select | |
aid | |
, abalance | |
from pgbench_accounts | |
union all |
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
#!/bin/sh | |
set -v | |
set -e | |
rm -rf repro | |
mkdir repro | |
cd repro | |
git init | |
touch a b | |
git add --all |
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
global | |
daemon | |
group haproxy | |
log /dev/log local0 | |
maxconn 4000 | |
pidfile /var/run/haproxy.pid | |
stats socket /var/lib/haproxy/stats | |
user haproxy | |
defaults |
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 com.eaio.uuid.UUID | |
trait CommonJSONFormats extends DefaultJsonProtocol { | |
implicit def uuidFormat = new JsonFormat[UUID] { | |
def write(uuid: UUID) = JsString(uuid.toString) | |
def read(value: JsValue) = value match { | |
case JsString(x) => new UUID(x) | |
case _ => throw new DeserializationException("String expected") | |
} |
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 ruby | |
# coding: utf-8 | |
require "logger" | |
require "sequel" | |
require "sequel/extensions/pg_array" | |
require "json" | |
logger = Logger.new(STDERR) | |
logger.level = Logger::DEBUG |
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
require "thread" | |
class CountingSemaphore | |
def initialize(capacity, sleep_time=1.0) | |
@mutex = Mutex.new | |
@capacity = capacity | |
@original_capacity = capacity | |
@sleep_time = sleep_time | |
end |