Skip to content

Instantly share code, notes, and snippets.

Sergey Tokarenko stokarenko

Block or report user

Report or block stokarenko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stokarenko
stokarenko / Several GitHub accounts
Last active Nov 10, 2015
Several GitHub accounts
View Several GitHub accounts
$ ssh-add ~/.ssh/id_rsa_some_other_github_account_name
$ git clone git@some_other_github_account_name.github.com:community/repo.git
# Add to repo/.git/config the `name` section like this
# [user]
# name = some_other_github_account_name
# email = some_other_github_account_name@users.noreply.github.com
View _while_true_vs_loop.rb
require 'benchmark'
MAX = 10**8
puts Benchmark.measure{
a = MAX
while(true)
a -= 1
break if a == 0
View bitwise_operators_in_ruby.rb
require 'benchmark'
require 'benchmark/ips'
seed = 1239012
Benchmark.ips do |x|
x.report('bitwise multiplication by 2') { seed << 1 }
x.report('arithmetic multiplication by 2') { seed * 2 }
x.report('bitwise division by 2') { seed >> 1 }
View lazy_chaining.rb
require 'benchmark'
require 'benchmark/ips'
NORMAL_ITERATIONS = 100
LONG_ITERATIONS = 2000
def map_to_self(array, iterations)
iterations.times do
array = array.map{ |i| i }
end
View array_to_hash.rb
require 'benchmark'
require 'benchmark/ips'
seed = [1,2,3]
map_proc = ->(i){ [i,i] }
Benchmark.ips do |x|
x.report('inject') { seed.inject({}){ |mem, i| mem[i]=i; mem } }
x.report('to_h') { seed.map(&map_proc).to_h }
x.report('Hash[map]') { Hash[seed.map(&map_proc)] }
View class_ancestors.rb
module A
def func
p 'A'
super
end
end
class B
def func
p 'B'
@stokarenko
stokarenko / capybara_chrome.rb
Created Aug 29, 2017
Headless Chrome within RSpec & Capybara
View capybara_chrome.rb
# spec/support/capybara_chrome.rb
require 'selenium/webdriver'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
RSpec.configure do
Capybara.server = :puma
Capybara.server_port = 5000
You can’t perform that action at this time.