Skip to content

Instantly share code, notes, and snippets.

Pierre Andrews Mortimerp9

Block or report user

Report or block Mortimerp9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Mortimerp9
Mortimerp9 / batch.js
Created Sep 1, 2015
batch queue calls with javscript
View batch.js
function batch(cb, maxSize, timeout) {
var queue = [];
var timer;
var flushQueue = function() {
cb(queue);
queue = [];
};
return function enQueue(msg) {
@Mortimerp9
Mortimerp9 / scales.js
Created May 30, 2015
Scales in javascript - d3 inspired
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:

@Mortimerp9
Mortimerp9 / check_kafkalag.sh
Last active Nov 2, 2017
Check kafka lag and queue growth with nagios/nrpe and KafkaOffsetMonitor
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
@Mortimerp9
Mortimerp9 / RichConfigString.scala
Created Aug 27, 2014
Smarter rich ConfigString to wrap Typesafe Config in Scala
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.
@Mortimerp9
Mortimerp9 / divergingcolors.r
Last active Aug 29, 2015
diverging color schemes for negative and positive numbers in R
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)
@Mortimerp9
Mortimerp9 / gist:365fd4f306b70b2570e6
Created Jul 14, 2014
toSet vs distinct in scala
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
@Mortimerp9
Mortimerp9 / MonoidRange.scala
Last active Aug 29, 2015
Create ranges from any monoid in scala (with Algebird Monoid)
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...
}
You can’t perform that action at this time.