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 / 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 / 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 / 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 / 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 / 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 / times_table.R
Last active December 17, 2019 20:54
Times table prediction using neuralnet & caret in R
library(caret)
library(ModelMetrics)
library(recipes)
library(neuralnet)
library(sigmoid)
# Create the dataset
tt <- data.frame(multiplier = rep(1:10, times = 10), multiplicand = rep(1:10, each = 10))
tt <- cbind(tt, data.frame(product = tt$multiplier * tt$multiplicand))
@andreyuhai
andreyuhai / full_name_regexp.md
Created November 6, 2019 19:11
Regexp matching <last_name>, <first_name> <middle_name>

Regexp matching last name, first name and middle name

"Last Name, FirstName Middle Name".match /^(?<last_name>\p{Alpha}+)[,\s]+(?<first_name>\p{Alpha}+)(?: *)(?<middle_name>.+)?$/
@andreyuhai
andreyuhai / capybara_poltergeist_crawlera_proxy.md
Last active October 25, 2019 13:45
How to use Crawlera proxy with Poltergeist/PhantomJS?

How to use Crawlera proxy with Poltergeist/PhantomJS?

require 'capybara'
require 'capybara/poltergeist'

Capybara.register_driver :poltergeist do |app|
    Capybara::Poltergeist::Driver.new(app, js_errors: false, phantomjs_options: ['--ignore-ssl-errors=true','--load-images=no', '--proxy=proxy.crawlera.com:8010', '--ssl-protocol=any'])
end
@andreyuhai
andreyuhai / ssh.md
Created July 25, 2019 09:25
Add SSH-keys

Add SSH Keys After Fresh Install

chmod 600 ~/.ssh/id_rsa chmod 700 ~/.ssh

Run ssh-add on the client machine, that will add the SSH key to the agent.

Confirm with ssh-add -l (again on the client) that it was indeed added.
@andreyuhai
andreyuhai / rbenv.md
Created July 25, 2019 09:12
Installing rbenv dependencies before installing Ruby with rbenv

sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev -y

source