- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/Exception
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/SSLCertificateNotVerified
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/ServerBrokeConnection
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/Exceptions/Timeout
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/ExceptionWithResponse
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/RequestFailed
- An exception per HTTP status:
- http://www.rubydoc.info/github/rest-client/rest-client/RestClient/RequestFailed
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
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90 | |
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6 | |
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac | |
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92 | |
namespace :db do | |
desc 'Dumps the database to backups' | |
task dump: :environment do | |
dump_fmt = ensure_format(ENV['format']) | |
dump_sfx = suffix_for_format(dump_fmt) | |
backup_dir = backup_directory(Rails.env, create: true) |
Settting up a Container Registry with docker-gitlab
This should be used for new users to getting started with the container registry feature on docker-gitlab.
-
Docker Distribution >= 2.4
-
Docker GitLab >= 8.8.4 ( #708 must be merged)
-
TLS certificates because it should be run with https it's not designed to use it without https
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
# Model | |
expect(@user).to have(1).error_on(:username) # checks whether there is an error in username | |
expect(@user.errors[:username]).to include("can't be blank") # check for the error message | |
# Rendering | |
expect(response).to render_template(:index) | |
# Redirecting |
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 Hash | |
def has_keys?(*keys) | |
keys.inject(self) do |pointer, key| | |
return false if !pointer.respond_to?(:has_key?) || !pointer.has_key?(key) | |
pointer[key] | |
end | |
true | |
end | |
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
# This works best in 2019 forward because its basically the code from the gem itself with some tweaks added: | |
# https://github.com/teamcapybara/capybara/blob/master/lib/capybara/registrations/drivers.rb | |
# The additional option/flags work for me but you probebly want to checkout what you would need here first: | |
# https://peter.sh/experiments/chromium-command-line-switches/ | |
Capybara.register_driver :selenium_chrome_headless do |app| | |
# Capybara::Selenium::Driver.load_selenium | |
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts| | |
opts.args << '--window-size=1920,1080' |
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://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
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
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })} | |
RSpec::Matchers.define :accept_nested_attributes_for do |association| | |
match do |model| | |
@model = model | |
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym) | |
if @nested_att_present && @reject | |
model.send("#{association}_attributes=".to_sym,[@reject]) | |
@reject_success = model.send("#{association}").empty? | |
end | |
model.send("#{association}").clear |
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 'rubygems' | |
require 'rspec' | |
require 'webmock' | |
require 'vcr' | |
require 'pry' | |
# in a Rails app, this would be in an initializer | |
WebMock.disable_net_connect!( | |
allow_localhost: true, | |
net_http_connect_on_start: true |
TL;DR
Install Postgres 9.6, and then:
sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main