View batch.js
function batch(cb, maxSize, timeout) {
var queue = [];
var timer;
var flushQueue = function() {
cb(queue);
queue = [];
};
return function enQueue(msg) {
View scales.js
'use strict';
module.exports = (function() {
var linear = function(domain, range) {
var d0 = domain[0], r0 = range[0], multipler = ( range[1] - r0 ) / ( domain[1] - d0 );
return function ( num ) {
return r0 + ( ( num - d0 ) * multipler );
};
}
View keybase.md

Keybase proof

I hereby claim:

  • I am mortimerp9 on github.
  • I am mortimer (https://keybase.io/mortimer) on keybase.
  • I have a public key whose fingerprint is BC13 E225 8D86 2CAB 6A1D DA1C B532 8844 EF4E 808F

To claim this, I am signing this object:

View check_kafkalag.sh
#!/bin/bash
#inspired by https://github.com/vide/nagios-scripts/blob/master/check_kafka_lag.sh
function printHelp() {
cat >&2 <<EOF
$@
--warning|-w Warning threshold
--critical|-c Critical threshold
View RichConfigString.scala
import com.typesafe.config.Config
import scala.util.Try
import scala.concurrent.duration.FiniteDuration
/**
* Some scala wrapper around the typesafe Config object to write configuration in the format:
* "host.defaults" configOrElse List("173.208.36.96:8800", "69.162.159.99:8800", "173.208.36.55:8800")
*
* The key is given as a string and `configOrElse` tries to get it from the configuration and guess the right type
* based on the default fallback type.
View divergingcolors.r
library(RColorBrewer)
colPos<-colorRampPalette(brewer.pal(9, "YlGn")[3:9])(100)
colNeg<-colorRampPalette(brewer.pal(9, "OrRd")[3:9])(100)
foo <- function(diff, bin) {
if(diff>=0) colPos[bin] else colNeg[bin]
}
mat$diff <- mat$x-mat$y
mat$bin <- cut(log10(abs(mat$diff)+1),100, labels=seq(1,100))
mat$col <- mapply(foo, mat$diff, mat$bin)
View gist:365fd4f306b70b2570e6

you should probably use distinct instead of toSet:

scala> th.pbenchOff()((1 to 1000).toSet.size)((1 to 1000).distinct.size)
Benchmark comparison (in 23.17 s)
Significantly different (p ~= 0)
  Time ratio:    0.43815   95% CI 0.42991 - 0.44639   (n=20)
    First     125.6 us   95% CI 124.0 us - 127.2 us
View MonoidRange.scala
object MonoidRange {
case class MonoidRangeBuilder[T](from: T, to: T, incl: Boolean)(implicit mo: Monoid[T], ordering: Ordering[T]) {
def by(step: T) = Stream.iterate(from) { previous: T =>
previous + step
}.takeWhile { x =>
if (incl) {
ordering.lteq(x, to)
} else {
ordering.lt(x, to)
View gist:fd1594415379a8f446c5
class MyArgs {
@Required
var db1: SQLArgs = new SQLArgs {}
@Required
var db2: SQLArgs = new SQLArgs {}
}
View gist:70e2d3114193a3179c3e
class MyArgs extends EnvArgs with SQLArgs {
//add extra app args here...
}