Skip to content

Instantly share code, notes, and snippets.

window.printSource = (object, depth) ->
depth ?= 1
indent = new Array(depth + 1).join(' ')
entries = []
for all key, value of object
entries.push "\"#{key}\": #{value}"
if object.__proto__?
for all key, value of object.__proto__
entries.push "\"#{key}\": #{value}"
require 'closure-compiler'
task :copy do
IO.popen('pbcopy', 'w') do |io|
io << Closure::Compiler.new.compile(IO.popen("coffee -p *.coffee"))
end
end
@eric
eric / boo.irc
Created November 22, 2010 23:38
# boo.irc
# written by prym
alias ooooMDOP {
if ([$3]) { QUOTE MODE $C -oooo $0 $1 $2 $3 ;}{
if ([$2]) { QUOTE MODE $C -booo *!*@* $0 $1 $2 ;}{
if ([$1]) { QUOTE MODE $C -boo *!*@* $0 $1 ;}{
if ([$0]) { QUOTE MODE $C -bo *!*@* $0 ;}
}
}
@eric
eric / gist:718455
Created November 28, 2010 00:59 — forked from catlike/gist:718450
require 'rubygems'
require 'sinatra'
require 'lib/sms'
require 'thread'
SECONDS_PER_MESSAGE = 1.0
queue = Queue.new
consumer = Thread.new do
@eric
eric / js_builder_template.rb
Created January 25, 2011 20:58
Playing around with a possible .jsbuilder template type for outputting json in sinatra
class JsBuilderTemplate < Template
def precompiled_preamble(locals)
[ super, "begin" ].join("\n")
end
def precompiled_postamble(locals)
"end.to_json"
end
def precompiled_template(locals)
@eric
eric / SAFE-RUBY.rb
Created February 16, 2011 06:24 — forked from holman/SAFE-RUBY.rb
require 'net/https'
require 'always_verify_ssl_certificates'
module SecurityModule
class HighSecurity
class ReallyHighSecurity
def self.turn_on_safe_connections
OpenSSL::SSL::VERIFY_NONE
end
end
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] LLVM ERROR: Cannot yet select: 0x101909010: f64 = bit_convert 0x101909410 [ORD=347] [ID=7]
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] 0x101909410: i64 = and 0x101957e10, 0x101954d10 [ORD=346] [ID=6]
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] 0x101957e10: i64,ch = CopyFromReg 0x10350fd88, 0x10191c110 [ORD=346] [ID=5]
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] 0x10350fd88: ch = EntryToken [ORD=346] [ID=0]
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] 0x10191c110: i64 = Register %reg16384 [ORD=346] [ID=1]
3/16/11 2:24:34 PM [0x0-0x76076].com.topfunky.PeepOpen[2111] 0x101954d10: i64 = Constant<-4> [ORD=346] [ID=2]
3/16/11 2:24:34 PM com.apple.launchd.peruser.501[213] ([0x0-0x76076].com.topfunky.PeepOpen[2111]) Exited with exit code: 1
3/16/11 2:25:26 PM com.apple.launchd.peruser.501[213] (com.apple.pbs) Throttling respawn: Will start in 10 seconds
3/16/11 2:25:40
@eric
eric / README.md
Created March 18, 2011 20:20
A simple mechanism to log metrics to Redis

Redis Timeseries Metric

I've been playing around with trying to make it as simple as possible to start logging a few metrics with as little effort in setup as possible.

As I was working on Papertrail I came up with a couple interesting ideas, some of which were inspired by OpenTSDB.

Storing metrics

In this example we are pretending we're processing emails as background jobs and would like to track how many we've sent over time.

[1 : 0] eric@kiccoro:/Users/eric > wget http://bazaar.launchpad.net/~graphite-dev/graphite/main/download/head:/whisper.py-20080505183243-3ypo8j4r6x1np8hq-2/whisper.py
--2011-03-19 13:11:15-- http://bazaar.launchpad.net/~graphite-dev/graphite/main/download/head:/whisper.py-20080505183243-3ypo8j4r6x1np8hq-2/whisper.py
Resolving bazaar.launchpad.net... 91.189.90.11
Connecting to bazaar.launchpad.net|91.189.90.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21690 (21K) [text/x-python]
Saving to: `whisper.py'
100%[================================================================================================>] 21,690 90.5K/s in 0.2s
@eric
eric / DISCLAIMER.md
Created March 28, 2011 22:59
Log directly to Papertrail or any remote syslog target from Heroku