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 / 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:
View lib_passenger_monitor.rb
# Finds bloating passengers and try to kill them gracefully.
# @example:
require 'logger'
class PassengerMonitor
# How much memory (MB) single Passenger instance can use
# Log file name
DEFAULT_LOG_FILE = 'passenger_monitoring.log'
serg-kovalev /
Created Aug 1, 2014
How to upgrade PostgreSQL server from 8.4 to 9.1 or above
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
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 /
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
#!/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
#echo "will do rm $1"
rm $1
serg-kovalev /
Last active Aug 29, 2015
RVM wrapper that loads needed environment in CRON tasks
#!/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)


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


You can’t perform that action at this time.