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
| 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 test@15.15.15.15:~/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
| # 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
| curl -X POST --data 'user[email]=user@example.com&user[password]=pass' http://0.0.0.0:3000/users/sign_in |
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 ControllerTestCase < ActionController::TestCase | |
| include Devise::TestHelpers | |
| include Warden::Test::Helpers | |
| def setup | |
| Warden.test_mode! | |
| self.do_setup | |
| end |
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
| Prerequisites | |
| sudo apt-get install openjdk-7-jdk | |
| Install | |
| cd ~ | |
| wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.deb | |
| sudo dpkg -i elasticsearch-1.1.0.deb |
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
| def open_user_file | |
| print "File to open: " | |
| filename = gets.chomp | |
| fh = File.open filename | |
| yield fh | |
| fn.close | |
| rescue | |
| puts "Couldn't open your file!" | |
| end |
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
| require "capybara" | |
| html = DATA.read | |
| app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] } | |
| sess = Capybara::Session.new(:selenium, app) | |
| sess.visit("/") | |
| puts sess.find('#id1').text | |
| __END__ |
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
| require 'capybara/dsl' | |
| require 'selenium-webdriver' | |
| Capybara.run_server = false | |
| Capybara.default_driver = :selenium | |
| html_string = "<html> | |
| <body> | |
| <div id='foo'></div> | |
| </body> |
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
| require 'capybara/dsl' | |
| require 'selenium-webdriver' | |
| Capybara.run_server = false | |
| Capybara.default_driver = :selenium | |
| class Robot | |
| include Capybara::DSL | |
| def go |