Skip to content

Instantly share code, notes, and snippets.

View DmitryBash's full-sized avatar

Batracov Dmitrii DmitryBash

  • Netherlands
View GitHub Profile
@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%'
@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 / 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 / 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 / rails-5-6-ubuntu-mina-puma-nginx.md
Created March 18, 2020 12:45 — forked from wafiq/rails-5-6-ubuntu-mina-puma-nginx.md
How to deploy Rails 5/6 in Ubuntu VM using Mina deployment with Puma webserver and Nginx

Rails 5 and 6 Deployment with Ubuntu, Mina, Puma and Nginx

Based on this tutorial but simplified and inlined. Particularly removed any Rails and 3rd party services part, assumed you just need deployment to any Ubuntu machine.

Prerequisite

  1. A functional Rails app
  2. Hosted Git repository (Github, Bitbucket, Gitlab)
  3. Cloud hosting account (Digital Ocean, Vultr, Linode, Lightsail)
  4. Local SSH account
@DmitryBash
DmitryBash / multiple_ssh_setting.md
Created March 19, 2020 16:08 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

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 "[email protected]"
@DmitryBash
DmitryBash / kubernetes_commands.md
Created March 19, 2020 16:54 — forked from edsiper/kubernetes_commands.md
Kubernetes Useful Commands
@DmitryBash
DmitryBash / _README.md
Created March 24, 2020 14:06 — forked from shime/_README.md
comparing dates and times in RSpec

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
import React from 'react'
// Example 1: translation
const TranslationContext = {
// most likely, from Provider or any other top-level component
locale: 'en',
strings: {
en: {
'user.my_account': 'My account'
@DmitryBash
DmitryBash / docker-pry-rails.md
Created March 26, 2020 14:04 — forked from briankung/docker-pry-rails.md
Using pry-rails with Docker