Skip to content

Instantly share code, notes, and snippets.

Siarhei Kavaliou serg-kovalev

Block or report user

Report or block serg-kovalev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@serg-kovalev
serg-kovalev / lib_passenger_monitor.rb
Last active Aug 29, 2015
Phusion Passenger Monitor library: it allows you to automatically gracefully kill/reload passenger instances, the end user will not see any errors. See another gist that shows how to use it: https://gist.github.com/serg-kovalev/a201e89e69ee5a86ad79
View lib_passenger_monitor.rb
# Finds bloating passengers and try to kill them gracefully.
# @example:
# PassengerMonitor.run
require 'logger'
class PassengerMonitor
# How much memory (MB) single Passenger instance can use
DEFAULT_MEMORY_LIMIT = 450
# Log file name
DEFAULT_LOG_FILE = 'passenger_monitoring.log'
@serg-kovalev
serg-kovalev / postgres_upgrade_8_4_to_9_1.sh
Created Aug 1, 2014
How to upgrade PostgreSQL server from 8.4 to 9.1 or above
View postgres_upgrade_8_4_to_9_1.sh
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
# stop apache server if you need
# sudo /etc/init.d/apache2 stop
sudo -i -u postgres
pg_dumpall > dumpall_$(date +"%Y%m%d").pgdump
exit
sudo mv /var/lib/postgresql/dumpall_$(date +"%Y%m%d").pgdump ~/
sudo cp -r /etc/postgresql/8.4 /etc/postgresql/old
sudo apt-get install postgresql-9.1 -y
@serg-kovalev
serg-kovalev / check_pid_valid.sh
Last active Aug 29, 2015
This shell script checks if process exists and removes pid file if not. I use this script with monit to be sure that process exist before killing it
View check_pid_valid.sh
#!/usr/bin/env bash
# the first argument should be a path to pid file
if [[ -f "$1" ]] ; then
if [ $(ps -p $(cat $1) | wc -l) -gt 1 ] ; then
# process exists - do nothing
#echo "OK"
exit 0
else
#echo "will do rm $1"
rm $1
@serg-kovalev
serg-kovalev / rvm_env_wrapper.sh
Last active Aug 29, 2015
RVM wrapper that loads needed environment in CRON tasks
View rvm_env_wrapper.sh
#!/usr/bin/env bash
# usage
# rvm_env_wrapper /path/to/project some_ruby_file.rb
# rvm_env_wrapper /path/to/project some_comand arg1 arg2 arg3 etc
# OR
# rvm_env_wrapper --use ruby_version@gemset_name some_comand_or_file
# Permissions:
# sudo chown user:group rvm_env_wrapper
# sudo chmod 774 rvm_env_wrapper
#
View gist:1ed5ba2cff523eef67bf

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

You can’t perform that action at this time.