Skip to content

Instantly share code, notes, and snippets.

@sorokadima
sorokadima / index.rb
Last active January 2, 2020 09:49
Rails Catch Exception (Ruby On Rails try catch)
def res params
begin
# do something
Rails.logger.info "debug #{Time.now.to_datetime}"
Rails.logger.info params
rescue Exception => e
Rails.logger.info "debug_Exception #{Time.now.to_datetime}"
Rails.logger.info e.message
end
end
@sorokadima
sorokadima / SSH Upload Folder.sh
Last active February 14, 2020 12:52
SSH Upload Folder (sshpass)
sshpass -p "PaSSwOrD" rsync -avz -e 'ssh -p 222' /home/user/projects/local/ admin@144.444.444.444:/var/www/public/ --ignore-errors
@sorokadima
sorokadima / index.sh
Last active January 15, 2020 08:13
sudo apt install Error (E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?)
# E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
# E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
sudo lsof /var/lib/dpkg/lock
sudo kill -9 <PID> && sudo dpkg --configure -a
@sorokadima
sorokadima / Gemfile
Created January 2, 2020 13:08
Rails CORS (Ruby on Rails Cross-Origin Resource Sharing)
gem 'rack-cors'
@sorokadima
sorokadima / JS console log.txt
Last active March 2, 2020 12:58
intellij idea Liva Templates (Pre PHP, PHPStorm, Var dump PHP live template, intellij idea, console.log, console log, phpstorm, php storm, rubymine, ruby mine, webstorm, web storm)
// $END$ - куди поставити курсор
console.log('', $END$);
@sorokadima
sorokadima / index.rb
Last active January 16, 2020 16:12
Ruby add subdomain to URL
# WAY 1
url = 'https://www.example.com/post/hello-world'
subdomain = 'blog'
index = url.index('://www.') ? url.index('://www.') + 7 : url.index('://') + 3
url.insert(index, subdomain + '.')
p url
# WAY 2
url = 'https://www.example.com/post/hello-world'
@sorokadima
sorokadima / index.txt
Last active March 15, 2020 18:24
Ubuntu paths ( .desctop folder, Application folder, Убунту папка з ярликами, ярлики, якрлик)
Applications
/usr/share/applications/
Default aplications list
/etc/gnome/defaults.list
Sublime text exec
/snap/sublime-text/current/opt/sublime_text/sublime_text
/opt/sublime_text/sublime_text
@sorokadima
sorokadima / index.rb
Last active January 11, 2020 10:45
Ruby unless && statement (unless or and, Ruby Draft)
a = true
b = false
# if one of variable false run exception
if !a or !b
p 'ERROR 1' # +
end
unless a or b
@sorokadima
sorokadima / bash_cheat_sheet bash .sh
Last active March 8, 2024 10:38
Bash cheat sheet (Run command by time interval, Find file on disk, Script output to file)
# Run command by time interval
watch -n 60 index.sh
# Find file on disk
find / -name "myfile"
find / -name "%myfile%"
# Script output to file
ls > log.txt
ls >> log.txt # don't rewrite file
@sorokadima
sorokadima / index.sh
Last active January 14, 2020 08:00
Ubuntu kill chromium (chrome, kill chromium process)
pkill -o chrome && pkill -o chromium