Skip to content

Instantly share code, notes, and snippets.

View biske's full-sized avatar

Ivan Bisevac (Иван Бишевац) biske

View GitHub Profile
# Backup database to .sql file:
pg_dump -U admin -h localhost -W --no-owner omh > dump201408191629.sql
# Restore database from .sql file:
psql -U postgres -d omh_development -W -h localhost < ~/dump201410131620.sql
# Description of flags:
# -U username of database user
@biske
biske / rsync.sh
Last active August 29, 2015 14:05
rsync -avz remote_username@remote_ip_or_doman_name:/path/to/remote/file /path/to/local/folder
# Example to copy production.log from remote user's folder to local home folder:
rsync -avz [email protected]:~/production.log ~/
# Options:
# -a archive mode
# -v increase verbosity
@biske
biske / user.rb
Created August 14, 2014 11:27 — forked from moeffju/user.rb
class User < ActiveRecord::Base
alias :devise_valid_password? :valid_password?
def valid_password?(password)
begin
devise_valid_password?(password)
rescue BCrypt::Errors::InvalidHash
return false unless Digest::SHA1.hexdigest(password) == encrypted_password
logger.info "User #{email} is using the old password hashing method, updating attribute."
self.password = password
Инсталација Рубија и Реилс окружења на Убунту
Пре инсталације Рубија:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison \
subversion g++-4.7 libmagickwand-dev
Инсталација g++-4.7
Уколико на званичним серверима дистрибуције не постоји g++-4.7 онда је потребно додати неки сервер у коме се он налази. На пример:
Додавање корисника jerry у постојећу групу ftp:
usermod -a -G ftp jerry
-- To mark database 'applogs' as not accepting new connections:
update pg_database set datallowconn = false where datname = 'TARGET_DB';
/* Query pg_stat_activity and get the pid values you want to kill,
then issue SELECT pg_terminate_backend(pid int) to them. */
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
# To restart nginx type:
nginx -t reload
# For more options:
# http://www.rootr.net/man/man/nginx/8
@biske
biske / git_history.sh
Created September 8, 2014 13:36
git - See the whole history of some line in file
gitk -L36,36:app/models/user.rb
@biske
biske / etc hosts
Created September 12, 2014 12:40
How to swich between two different servers with same url
# Add row to /etc/hosts
# Format is:
# ipaddress hostname
# Example:
16.18.11.156 www.google.com
# This way whenever you type www.google.com it go to 16.18.11.156
http://jafty.com/blog/restoring-postgresql-database-with-pg_restore/