Skip to content

Instantly share code, notes, and snippets.

@sergeyenin
sergeyenin / class_module.rb
Created August 5, 2011 21:47
ClassModule
module ClassModule
#all successors excluding self
def successors(klass=self.name.to_s)
descendants = []
begin
ObjectSpace.each_object(class << eval(klass);self;end) do |found|
descendants << found
end
rescue Exception=>e
@sergeyenin
sergeyenin / gist:1128633
Created August 5, 2011 22:04
BasicObjects` descendants
BasicObject
|=Object
|=Date
|=Fiber
|=Mutex
|=ThreadGroup
|=Thread
|=Enumerator::Yielder
|=Enumerator::Generator
@sergeyenin
sergeyenin / .irbrc
Created August 6, 2011 07:36
wirble config
# load libraries
require 'rubygems'
require 'wirble'
require 'pp'
alias q exit
# Easily print methods local to an object's class
class Object
def irb_methods
require 'ray'
class Life
Width = 1920
Height = 1080
Size = Ray::Vector2[Width, Height]
def initialize
@image = Ray::Image.new Size
@sergeyenin
sergeyenin / 01. Gemfile
Created January 3, 2012 15:28 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'
@sergeyenin
sergeyenin / Gemfile
Created February 6, 2012 13:14 — forked from rwjblue/Gemfile
Simple CQL to Thrift Comparison in ruby
source :rubygems
gem 'rake'
gem 'forgery'
gem 'cassandra-cql', :path => '../cassandra-cql'
gem 'cassandra', :path => '../cassandra'
gem 'perftools.rb'
gem 'rbtrace'
@sergeyenin
sergeyenin / user_system_real.md
Created February 8, 2012 18:56 — forked from anildigital/user_system_real.md
Ruby Benchmark module: meanings of “user”, “system”, and “real”?

Ruby Benchmark module: meanings of “user”, “system”, and “real”?

>> Benchmark.bm(7) { |b| b.report('Report:') { s = '' ; 10000.times { s += 'a' } }  }
			 user     system      total        real
Report:  0.150000   0.010000   0.160000 (  0.156361)

These are the same times that the Unix time command or other typical benchmarking tools would report:

user: the amount of time spent executing userspace code (i.e.: your code),

@sergeyenin
sergeyenin / cassandra_1_mln_inserting.rb
Created July 18, 2012 15:33
CassandraModelCql inserting 1 mln rows and counting it
# encoding: utf-8
$:.unshift File.expand_path("../../lib/",__FILE__)
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
require ENV_PATH
class String
# http://www.devarticles.com/c/a/Development-Cycles/Tame-the-Beast-by-Matching-Similar-Strings/3/
module Soundex
Codes = {
'b' => 1,
'f' => 1,
'p' => 1,
'v' => 1,