This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Инсталација Рубија и Реилс окружења на Убунту | |
Пре инсталације Рубија: | |
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 онда је потребно додати неки сервер у коме се он налази. На пример: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Додавање корисника jerry у постојећу групу ftp: | |
usermod -a -G ftp jerry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To restart nginx type: | |
nginx -t reload | |
# For more options: | |
# http://www.rootr.net/man/man/nginx/8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gitk -L36,36:app/models/user.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://jafty.com/blog/restoring-postgresql-database-with-pg_restore/ |