Skip to content

Instantly share code, notes, and snippets.

View DmitryBash's full-sized avatar

Batracov Dmitrii DmitryBash

  • Netherlands
View GitHub Profile
@DmitryBash
DmitryBash / install.sh
Created March 17, 2020 12:40 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# https://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# https://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# https://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# https://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE`
@DmitryBash
DmitryBash / example_controller.rb
Created February 25, 2020 21:00 — forked from TheKidCoder/example_controller.rb
Rails - Sanitize Ordering Params
class ExampleController
include OrderingHelpers
def index
@clients = Clients.order(sanitized_ordering).where(user_id: current_user.id)
end
end
@DmitryBash
DmitryBash / saga.rb
Created February 17, 2020 12:20 — forked from sclinede/saga.rb
Example of Full Saga implementation in Ruby (with Usage example, also)
class Saga
class << self
def with_redis; raise NotImplementedError; end
attr_accessor :cleanup_delay, :queue, :last_txid
def queue
Thread.current[:saga_queue] ||= []
end
def last_txid
@DmitryBash
DmitryBash / postgres_queries_and_commands.sql
Created February 7, 2020 13:12 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@DmitryBash
DmitryBash / 01.1.lifecycle.rb
Created November 3, 2019 23:02 — forked from Aupajo/01.1.lifecycle.rb
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
@DmitryBash
DmitryBash / webpacker_rails.md
Created November 3, 2019 22:22 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
https://stackoverflow.com/questions/34424154/rails-validate-uniqueness-of-two-columns-together
https://matt.aimonetti.net/posts/2013/11/30/sharing-rails-sessions-with-non-ruby-apps/
https://codeburst.io/elixir-beside-rails-2b94414bcb03
https://www.google.com/search?q=rails+associations+tips&oq=rails+associations+tips&aqs=chrome..69i57j69i65j69i60j0l3.4166j0j7&sourceid=chrome&ie=UTF-8
https://blog.bigbinary.com/2013/07/01/preload-vs-eager-load-vs-joins-vs-includes.html
https://www.howtographql.com/graphql-ruby/0-introduction/
http://www.mitchcrowe.com/10-most-underused-activerecord-relation-methods/
https://github.com/leandromoreira/redlock-rb
https://medium.com/@devinburnette/be-prepared-7768d1a111e1
https://gist.github.com/rafaelsales/86ca62c45108abe7162a87813fea8e7e - what i dislike
https://github.com/rubocop-hq/ruby-style-guide
https://redisgreen.net/blog/pubsub-howto/ - redis pubsub
https://www.brianstorti.com/understanding-ruby-idiom-map-with-symbol/
https://www.youtube.com/watch?v=gIEMKOI_Y-4&t=1s - ruby 24 trics and tips
https://stackoverflow.com/questions/14881125/what-does-to-proc-method-mean
http://maximomussini.com/posts/ruby-to_proc/
https://bparanj.gitbooks.io/ruby-basics/content/part2/binding.html
https://www.reddit.com/r/ruby/comments/981kjw/10_ruby_tricks_we_should_use_to_improve_the_code/
https://www.driftingruby.com/episodes/random-ruby-tips-and-tricks
http://www.virtuouscode.com/2013/12/25/exception-causes-in-ruby-2-1/
https://chris.beams.io/posts/git-commit/
https://ncona.com/2011/07/how-to-delete-a-commit-in-git-local-and-remote/
http://christoph.ruegg.name/blog/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html
https://stackoverflow.com/questions/10153486/how-to-delete-the-last-n-commit-on-github-and-locally
https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github
https://toster.ru/q/455554 - how to checkout git reset --hard
https://git-scm.com/book/ru/v1/Git-%D0%B8%D0%B7%D0%BD%D1%83%D1%82%D1%80%D0%B8-%D0%9E%D0%B1%D1%81%D0%BB%D1%83%D0%B6%D0%B8%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D0%B8-%D0%B2%D0%BE%D1%81%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85 - Обслуживание и восстановление данных
https://chrisk.io/undo-git-pull/
https://support.beanstalkapp.com/article/1004-how-do-i-undo-things-in-git#3
https://git-scm.com/docs/git-annotate