ror, scala, jetty, erlang, thrift, mongrel, comet server, my-sql, memchached, varnish, kestrel(mq), starling, gizzard, cassandra, hadoop, vertica, munin, nagios, awstats
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
def add1(arr, val, n) | |
# how many times are we going to increment | |
increment_count = n == 0 ? arr.length : n.abs | |
# are we going up or down the array | |
indices = n < 0 ? (-1..-arr.length) : (0...arr.length) | |
# iterate and update the array in place | |
indices.each do |index| | |
if (arr_value = arr[index]) == val | |
arr[index] = arr_value + 1 | |
# decrement and check the count all in one go |
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
def add1(arr, val, n) | |
stop = arr.length - 1 | |
count = 0 | |
(0..stop).each do |i| | |
index = n < 0 ? stop - i : i | |
if arr[index] == val | |
arr[index] += 1 |
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 interval(duration, fn){ | |
this.baseline = undefined | |
this.run = function(){ | |
if(this.baseline === undefined){ | |
this.baseline = new Date().getTime() | |
} | |
fn() | |
var end = new Date().getTime() | |
this.baseline += duration |