echo `ifconfig $(netstat -nr | grep -e default -e "^0\.0\.0\.0" | head -1 | awk '{print $NF}') | grep -e "inet " | sed -e 's/.*inet //' -e 's/ .*//' -e 's/.*\://'`
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
| # spec/support/capybara.rb | |
| require 'capybara/rails' | |
| require 'capybara/rspec' | |
| # port and url to webpack server | |
| WEB_TEST_PORT = '5005'.freeze | |
| WEB_TEST_URL = "http://localhost:#{WEB_TEST_PORT}".freeze | |
| def capybara_wait_for_webpack_server | |
| 10.times.each do |_| |
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
| # Integrate Gem/Engine and main Rails app | |
| ## Overview | |
| - [Paths](#paths) | |
| - [Routes](#routes) | |
| - [Add functionality to controller](#controllers) | |
| - [Improving (Extending or overriding) Engine functionality](#extend-engine-class) | |
| - [Helpers](#helpers) | |
| - [Assets](#assets) |
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
| # Reference: https://www.igvita.com/2007/02/13/building-dynamic-webrick-servers-in-ruby/ | |
| require 'webrick' | |
| class Echo < WEBrick::HTTPServlet::AbstractServlet | |
| def do_GET(request, response) | |
| puts request | |
| response.status = 200 | |
| end | |
| def do_POST(request, response) | |
| puts request |
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
| ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib |
In your command-line run the following commands:
brew doctorbrew update
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
| function __git_dirty { | |
| git diff --quiet HEAD &>/dev/null | |
| [ $? == 1 ] && echo " ↺ " | |
| } | |
| function __git_branch { | |
| __git_ps1 "%s" | |
| } | |
| function __my_rvm_ruby_version { |
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 MyJob < ActiveJob::Base | |
| queue_as :urgent | |
| rescue_from(NoResultsError) do | |
| retry_job wait: 5.minutes, queue: :default | |
| end | |
| def perform(*args) | |
| MyService.call(*args) | |
| 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
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
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
| html = DATA.read | |
| require "capybara/dsl" | |
| require "capybara/poltergeist" | |
| require "openssl" | |
| app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] } | |
| Capybara.register_driver :poltergeist do |app| | |
| Capybara::Poltergeist::Driver.new(app, debug: true, js_errors: true, timeout: 60, logger: $stdout, | |
| phantomjs_options: %w[--load-images=yes --ignore-ssl-errors=yes]) |
