Skip to content

Instantly share code, notes, and snippets.

View mpugach's full-sized avatar

Maksym Pugach mpugach

View GitHub Profile

Capybara

save_and_open_page

Matchers

have_button(locator)
@mpugach
mpugach / application_controller.rb
Created November 1, 2014 15:34
Rails basic auth
class ApplicationController < ActionController::Base
before_filter :enable_http_auth, if: :use_http_auth?
private
def use_http_auth?
Rails.env.production?
end
def enable_http_auth
@mpugach
mpugach / puma.rb
Last active August 29, 2015 14:12 — forked from catsby/puma.rb
preload_app!
min_threads = Integer(ENV['MIN_THREADS'] || 0)
max_threads = Integer(ENV['MAX_THREADS'] || 5)
threads min_threads, max_threads
workers Integer(ENV['WORKER_COUNT'] || 3 )
on_worker_boot do
ActiveSupport.on_load(:active_record) do
@mpugach
mpugach / debug.rb
Last active January 26, 2017 14:01
Noticeable Rails debug message
# Thanks to http://stackoverflow.com/a/927275/1041467
def debug_msg(msg, title = 'DEBUG')
Rails.logger.debug "\e[5;1;34m#{title}:\e[0m #{msg}"
end
// create an index with an analyzer "myindex"
curl -X PUT localhost:9200/myindex -d '
{
"settings" : {`
"index":{
"number_of_replicas":0,
"number_of_shards":1,
"analysis":{
"analyzer":{
"first":{
@mpugach
mpugach / helper.rb
Created May 12, 2015 12:55
rails3-jquery-autocomplete test helper
def choose_autocomplete_result(item_text, input_selector = 'input[data-autocomplete]')
page.execute_script %{ $('#{input_selector}').trigger("focus") }
page.execute_script %{ $('#{input_selector}').trigger("keydown") }
item_selector = "ul.ui-autocomplete li.ui-menu-item:contains('#{item_text}')"
expect(page).to have_selector('ul.ui-autocomplete li.ui-menu-item', text: item_text)
page.execute_script %{ $("#{item_selector}").trigger("mouseenter").trigger("click"); }
end
@mpugach
mpugach / protips.js
Last active August 29, 2015 14:23 — forked from nolanlawson/protips.js
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"

TL;DR

sudo pg_dropcluster 9.4 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main

@mpugach
mpugach / sphinx.rb
Created September 30, 2015 11:31
brew install sphinx 2.1.6
#/usr/local/Library/Formula/sphinx.rb
class Sphinx < Formula
desc "Sphinx is a full-text search engine"
homepage "http://www.sphinxsearch.com"
revision 1
stable do
url 'http://sphinxsearch.com/files/sphinx-2.1.6-release.tar.gz'
sha1 'fe4dfc605afe8f58d9e25fd0c58dfed1673ec4b1'