Skip to content

Instantly share code, notes, and snippets.

View palkan's full-sized avatar

Vladimir Dementyev palkan

View GitHub Profile
@palkan
palkan / Guardfile
Created December 19, 2015 16:50
Guardfile for Rails
# По умолчанию запускаем только необходимых для тестов наблюдателей,
# то есть всех, кроме server.
# Для запуска всех: bundle exec guard -g default
scope groups: ['specs']
group 'specs' do
# запускаем тесты и использованием Spring
guard :rspec, cmd: "bundle exec spring rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
@palkan
palkan / shared_feature.rb
Created December 19, 2015 18:52
Capture exceptions with screenshots (feature specs)
shared_context "feature", type: :feature do
after(:each) do |example|
next unless example.exception
meta = example.metadata
next unless meta[:js] == true
filename = File.basename(meta[:file_path])
line_number = meta[:line_number]
screenshot_name = "screenshot-#{filename}-#{line_number}.png"
save_screenshot(screenshot_name) # rubocop:disable Lint/Debugger
puts meta[:full_description] + "\n Screenshot: #{screenshot_name}"
@palkan
palkan / .travis.yml
Last active April 23, 2020 18:04
Travis config for TH project
language: ruby
rvm:
- 2.2.3
# Если Travis пишет вам слишком часто, то отключаем email уведомления
notifications:
email: false
# Указываем базу данных
addons:
@palkan
palkan / after_commit_conditional.rb
Created December 22, 2015 09:57
CounterCulture skip after commit
def _after_commit_hook
super unless skip_after_commit_hook
@_counter_culture_active = false
end
def skip_after_commit_hook
false
end
@palkan
palkan / postgres_queries_and_commands.sql
Last active December 5, 2019 13:01 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@palkan
palkan / ac_streams_bench.rb
Created November 9, 2016 11:39
ActionCable Streaming Benchmark
# rubocop disable:all
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
@palkan
palkan / actioncable_streaming_patch.rb
Created November 9, 2016 11:46
ActionCable Streaming Patch
module ActionCable::Channel::Streams
def worker_pool_stream_handler(broadcasting, user_handler, coder: nil)
{ connection: connection, id: @identifier.to_json }
end
end
class ActionCable::SubscriptionAdapter::SubscriberMap
def invoke_callback(callback, message)
callback[:connection].send(:websocket).transmit(
"{\"identifier\": #{callback[:id]},\"message\": #{message}}"
@palkan
palkan / docker-clean.sh
Last active November 29, 2016 12:41
Clean Docker Files
#!/bin/bash
# remove exited one-off containers:
docker ps --filter status=dead --filter status=exited -a | grep "_run" | awk '{ print $1 }' | xargs -I@ docker rm -v @
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -I@ docker rmi @
# remove unused volumes
docker volume ls -qf dangling=true | xargs -I@ docker volume rm @
@palkan
palkan / post.md
Created December 7, 2016 16:41
AnyCable post

title: 'AnyCable:the Action Cable Power-Up' category: Back-end date: 2016-12-17 description: 'This article tells the story of the AnyCable project which aims to increase Action Cable performance and functionality.' draft: true authors:

name: 'Vladimir Dementyev'

about: 'Back-end Developer at Evil Martians'

@palkan
palkan / Gemfile
Last active April 25, 2024 14:23
RSpec profiling with RubyProf and StackProf
gem 'stackprof', require: false
gem 'ruby-prof', require: false