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
# In your active `rails c` session type | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.connection_pool.clear_reloadable_connections! | |
# or, in your ~/.irbrc add the following | |
require 'rubygems' | |
if ENV.include?('RAILS_ENV') && ENV["RAILS_ENV"] == 'development' |
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
# encoding: utf-8 | |
require 'tmpdir' | |
require 'stringio' | |
require 'zip/zipfilesystem' | |
# Base class for all other types of spreadsheets | |
class Roo::GenericSpreadsheet | |
include Enumerable |
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
var http = require('http'), | |
director = require('director'), | |
loggly = require('loggly'); | |
var loggly_client = loggly.createClient({ | |
subdomain: "delphi", | |
json: true | |
}); | |
var send_to_loggly = function(json_package) { |
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
var http = require('http'), | |
director = require('director'); | |
var router = new director.http.Router({ | |
'/add_log': { | |
post: function () { | |
console.log(this.req.body); | |
this.res.writeHead(200, { 'Content-Type': 'application/json' }); |
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
Asynch Recursion | |
setInterval(function(){ doStuff(); },100); | |
// bad... but better is this | |
(function loop(){ | |
doStuff(); | |
setTimeout(loop,100); | |
})(); |
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 |
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
=begin | |
The task: Rewrite this class in multiple ways (at least 2). Currently, on class | |
instantiation a bunch of methods are defined. What are some other ways you could | |
have written this and what are the trade-offs? | |
I'll give you one: You can rewrite this using ghost methods (method_missing) | |
and dynamically handle the method call. There are multiple variations in which | |
you can write/handle the method call so pick one or two and give it a shot. | |
For each variation you should note a pro and a con to the solution. For example, |
NewerOlder