Skip to content

Instantly share code, notes, and snippets.

View andreyuhai's full-sized avatar
🏠
Working from home

Burak andreyuhai

🏠
Working from home
View GitHub Profile
@andreyuhai
andreyuhai / new_ruby_project_procedure.markdown
Created February 13, 2020 16:01
A walkthrough for creating a new Ruby project

New Ruby software project procedure

First, ensure the following tools are available on the local system and reasonably up to date:

  • Git
  • Git-flow
  • RVM
  • Bash
  • SSH
@andreyuhai
andreyuhai / ror_custom.md
Created February 15, 2020 20:06
Ruby on Rails requiring custom script

Source: Love Your lib Directory By: Brian Cardarella

Using lib/ to extend core, stlib, or a gem

Far too often I’ve needed to extend a class that is being defined outside of my project. There are a few ways to deal with this. You can use a Composite to define a new class that you can then play around with. The downside to this is that I sometimes want to modify a class that is being inherited by other classes. This is when I think it is appropriate to Monkey Patch.

The pattern I have fallen upon is to define a gem_ext/ directory and a gem_ext.rb file in lib. I then make sure the extensions are loaded up using an initializer.

@andreyuhai
andreyuhai / capistrano_credentials.md
Last active February 22, 2020 23:06
Deploying Rails 5.2 Applications with New Encrypted Credentials using Capistrano

Deploying Rails 5.2 Applications with New Encrypted Credentials using Capistrano

Source

  1. Copy config/master.key from local filesystem to the production server under <project_root>/shared/config/master.key.

  2. Configure capistrano’s config/deploy.rb to include this line:

@andreyuhai
andreyuhai / capistrano_environment_variables.md
Created February 23, 2020 08:37
Capistrano - Environment Variables

Source

If you ever get key not found errors when deploying with Capistrano, then:

When ~/.bashrc contains first lines like this, any code afterwards won't be sourced:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
 *) return;;
@andreyuhai
andreyuhai / git_commit_only_deleted_files
Created June 20, 2020 18:41 — forked from alcidesqueiroz/git_commit_only_deleted_files
Git - Commit only deleted files...
git ls-files --deleted | xargs git rm
git commit
@andreyuhai
andreyuhai / database_size.md
Created June 23, 2020 21:17
Get the size of a database
SELECT table_schema "DB Name",
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
FROM information_schema.tables 
GROUP BY table_schema; 

Source

@andreyuhai
andreyuhai / wireshark_ssl.md
Last active June 24, 2020 10:41
Wireshark Filter for Analysis of SSL Traffic
@andreyuhai
andreyuhai / date_and_time_file_name.md
Created June 24, 2020 18:41
Show Date and Time in File Name

Source

Simply put $(date +%Y-%m-%d-%H.%M.%S)

mysqldump -u <user> -p <database> | bzip2 -c > <backup>$(date +%Y-%m-%d-%H.%M.%S).sql.bz2
@andreyuhai
andreyuhai / linux_screen.md
Last active June 25, 2020 11:00
How to scroll up/down in linux screen?

How to scroll up/down in Linux Screen?

Enter copy mode:

CTRL-A + [

Then use:

@andreyuhai
andreyuhai / capybara.md
Created August 15, 2020 09:48
How to register a driver and instantiate using Capybara
require 'capybara'
require 'selenium-webdriver'

Capybara.register_driver :selenium_w_proxy do |app|
  proxy = Selenium::WebDriver::Proxy.new(http: 'host:port', ssl: 'host:port')
  desired_caps = Selenium::WebDriver::Remote::Capabilities.firefox
  options = Selenium::WebDriver::Firefox::Options.new
  options.add_argument('--headless') # To make the browser headless
  options.add_preference('browser.download.dir', "/some/path/to/folder/") # Custom downloads directory