Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Merk bibendi

View GitHub Profile
@bibendi
bibendi / ubuntu_agnoster_install.md
Created Sep 6, 2018 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme
View ubuntu_agnoster_install.md

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@bibendi
bibendi / Capybara.md
Created Sep 3, 2018 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet
View Capybara.md

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@bibendi
bibendi / _service.md
Created Aug 25, 2018 — forked from naholyr/_service.md
Sample /etc/init.d script
View _service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@bibendi
bibendi / acceptance_helper.rb
Created Aug 21, 2018
Example Capybara tests
View acceptance_helper.rb
require 'rails_helper'
require 'capybara/rspec'
require 'selenium-webdriver'
require 'site_prism'
Capybara.server = :puma, { Silent: true }
Capybara.server_host = `hostname`.strip.downcase
Capybara.server_port = 3002
Capybara.default_max_wait_time = 5
View keybase.md

Keybase proof

I hereby claim:

  • I am bibendi on github.
  • I am bibendi (https://keybase.io/bibendi) on keybase.
  • I have a public key ASDynTp-5ubsrL1hm6jHzh0KkUbBfmCcb-sn_JLrSVU_awo

To claim this, I am signing this object:

View cpu_vs_io.rb
require 'benchmark/ips'
require 'open-uri'
require 'bigdecimal'
require 'bigdecimal/math'
class Contract
DIGITS = 10_000
URL = 'http://www.nooooooooooooooo.com/'.freeze
def call(parallel_io_only:, cpu_count:, io_count:)
View service-callbacks.rb
# ===== Common side in gem apress-api
Rails.application.routes.draw do
scope module: "apress", constraints: {domain: :current} do
namespace "api/v1" do
post 'callbacks/:service' => 'callbacks#create'
end
end
end
@bibendi
bibendi / benchmark.rb
Created Oct 25, 2017
Compare map vs map!
View benchmark.rb
key = "id".freeze
rows = []
5000.times { rows << {"id" => rand(5000).to_s} }
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('map') { rows.dup.map { |r| r[key].to_i } }
x.report('map!') { rows.dup.map! { |r| r[key].to_i } }
View ruby-job.md

Вопросы на собеседование Ruby программиста

Технический блок

  • Чем отличается module от class?
  • Чем отличается String от Symbol?
  • Слышал ли про duck typing?
  • С каким гемами работал? Какие больше всего понравились?
  • С какими версиями RoR работал?
  • Как обстоит дело с тестированием?
@bibendi
bibendi / join-values-explain.txt
Last active May 29, 2017
Postgres query optimization
View join-values-explain.txt
Nested Loop (cost=0.42..4594.88 rows=830 width=430) (actual time=0.038..18.896 rows=829 loops=1)
-> Values Scan on "*VALUES*" (cost=0.00..10.40 rows=832 width=4) (actual time=0.005..2.557 rows=832 loops=1)
-> Index Scan using trait_values_pkey on trait_values (cost=0.42..5.50 rows=1 width=430) (actual time=0.006..0.009 rows=1 loops=832)
Index Cond: (id = "*VALUES*".column1)
Filter: (((state)::text = 'accepted'::text) AND (public_state = 'published'::trait_value_public_state))
Rows Removed by Filter: 0
Total runtime: 21.202 ms