Skip to content

Instantly share code, notes, and snippets.

View v-yarotsky's full-sized avatar

Vlad Yarotsky v-yarotsky

View GitHub Profile
@v-yarotsky
v-yarotsky / sucks.rb
Created August 30, 2016 22:37
Just stop using anonymous classes already
require 'benchmark/ips'
class A; end
foo = Class.new
Benchmark.ips do |t|
t.report("normal") { A.name }
t.report("anonymous") { foo.name }
end

Keybase proof

I hereby claim:

  • I am v-yarotsky on github.
  • I am v_yarotsky (https://keybase.io/v_yarotsky) on keybase.
  • I have a public key whose fingerprint is B8B8 B5CF 34B0 8389 EA69 E3BB 3436 3EA3 16B0 13AB

To claim this, I am signing this object:

@v-yarotsky
v-yarotsky / acceptance_test.rb
Created May 20, 2015 22:33
CB2 failing test shows that CB2 stays in half-open state forever after opening once
require "spec_helper"
require "thread"
describe "CB2 acceptance test" do
WORKERS = 1
RESPONSE_TIME_SEC = 0.01
def make_breaker(redis)
CB2::Breaker.new(
service: "test service",
def nil.+@(*)
if Module.last_method_defined
method_name, klass = Module.last_method_defined
klass.class_eval <<-RUBY
alias_method "#{method_name}_without_logging", "#{method_name}"
def #{method_name}(*args, &block)
p "called #{method_name}"
send("#{method_name}_without_logging", &block)
end
RUBY
$ bundle exec rake
Run options:
# Running tests:
..../home/travis/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_server'
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/em-proxy-0.1.8/lib/em-proxy/proxy.rb:10:in `block in start'
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
from /home/travis/.rvm/gems/ruby-1.9.3-p327/gems/em-proxy-0.1.8/lib/em-proxy/proxy.rb:5:in `start'
WorkingExample before dump and load: #<WorkingExample:0x1076c37e0 @foo=1, @bar=2>
WorkingExample dumpU:WorkingExamplei
WorkingExample after dump and load: #<WorkingExample:0x1076c33d0 @foo=1>
FaultyExample before dump and load: @foo=,@bar=,@qux=3
FaultyExample dumpIU:FaultyExamplei
FaultyExample after dump and load: @foo=1,@bar=,@qux=
project :rainbowunicorns do
environment :staging do
server do
host "staging.rainbowunicorns.com"
location "/mnt/apps/rainbowunicorns"
env :TERM => "xterm-256color"
user "boss"
identity_file "~/.ssh/my_uber_secret_key"
end
end
Uncaught Error: Temple::InvalidExpression: Generator supports only core expressions - found [:escape, true, [:dynamic, "t"]]
@v-yarotsky
v-yarotsky / tmux-mouse-fix.rb
Created June 11, 2012 14:26
Homebrew tmux formula with mouse scroll down fix
require 'formula'
class TmuxMouseFix < Formula
url 'http://sourceforge.net/projects/tmux/files/tmux/tmux-1.6/tmux-1.6.tar.gz'
md5 '3e37db24aa596bf108a0442a81c845b3'
homepage 'http://tmux.sourceforge.net'
head 'https://tmux.svn.sourceforge.net/svnroot/tmux/trunk'
depends_on 'libevent'
@v-yarotsky
v-yarotsky / .tmux.conf
Created March 22, 2012 11:57
Mac OS X tmux config
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH