Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@eric1234
eric1234 / logworm_logger.rb
Created October 20, 2010 14:56
Logger that writes to logworm
class LogwormLogger < ActiveSupport::BufferedLogger
def initialize(level = DEBUG)
super Logworm::Logger, level
end
end
class Logworm::Logger
def self.write(msg)
table = defined?(Rails) ? "#{Rails.env}_logger" : 'logger'
log table, :msg => msg
21:01 <allen_> just tested, and found out row data size 2000 bytes and 4000 bytes does not have differences. interesting...
21:02 <benblack> differences in what?
21:02 <benblack> (and what's a row? ;) )
21:03 <allen_> different in data size. row as in db, i meant
21:04 <allen_> fyi, my case is disk io intensive.
class A
def implicit_block_implicit_ensure
begin
"block"
ensure
"ensure"
end
end
def implicit_block_explicit_ensure
@momania
momania / gist:653276
Created October 29, 2010 10:14
HeartMonitor using Akka FSM
import akka.actor.{Actor, FSM}
import java.util.concurrent.TimeUnit
sealed trait Health
case object Stale extends Health
case object Alive extends Health
case object Dead extends Health
case object HeartBeat
director routing_mesh round-robin {
{
.backend = {
.host = "...some ip...";
.port = "...some port...";
.first_byte_timeout = 90s;
.between_bytes_timeout = 90s;
}
# ...more backends...
}
@telent
telent / gist:704274
Created November 17, 2010 22:46
Some random notes on Mirah, mostly culled from the mailing list

Stuff in Ruby that is/isn't supported, or is different

=begin / =end

Rib Rdb writes: "The new parser doesn't support this". Use single line comments instead

The object model

The ruby object model is not the same as the java object model. The

@andersonsp
andersonsp / setup_load_paths.rb
Created November 18, 2010 22:26
fork of the darcy's setup_load_paths.rb from http://bit.ly/rvm-passenger-slp
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
dir = File.dirname(File.dirname(__FILE__))
rvmrc = File.join(dir, ".rvmrc")
if File.exists? rvmrc
@headius
headius / gist:727684
Created December 3, 2010 23:01
A GIL for JRuby?
~/projects/jruby ➔ # single thread performance
~/projects/jruby ➔ jruby --server bench/bench_threaded_reverse.rb 1
...
concurrency is - 1
started thread 0
Thread 0 running
another 10 in #<Thread:0xc8c7d6 run>
another 10 in #<Thread:0xc8c7d6 run>
another 10 in #<Thread:0xc8c7d6 run>
@deepak
deepak / singleton_foo.rb
Created December 9, 2010 12:51
defining a singleton method on a attribute of an instance of a class
# defining a singleton method on a attribute of an instance of a class
# which method is recommended, define_singleton_methods is short-and-sweet. benchmark.
class FooNestedDef
attr_accessor :info
def initialize
@info = []
# NOTEL mindbending - def inside a def works. is this legal?
@andymccurdy
andymccurdy / crier.py
Created December 11, 2010 01:09
Crier: simple introspection for long-running Python processes
import pprint
import os
import sys
import threading
import time
import traceback
_crier = None
def init_crier(temp_dir='/tmp'):
"Initialzies Crier, ensuring it's only created once in the process"