def foo(x, y)
method(__method__).parameters.map do |_, name|
binding.local_variable_get(name)
end
end
foo(1, 2) # => 1, 2
This file contains 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 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
This file contains 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
# .ebextensions/cache.config | |
files: | |
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02a_set_cache.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash | |
set -xe |
class MyWorker
def perform(params={})
puts "params: #{params.inspect}"
params = params.to_h.transform_keys(&:to_sym)
puts "params after transform: #{params.inspect}"
execute(**params)
end
def execute(name: "there", age: 20)
As outlined here, there are a couple of situations where you need to authenticate with GitHub by using an Acces Token:-
- If you have Two-Factor Authentication (2FA) enabled.
- You are accessing an organisations protected content using SAML Single-Sign On (SSO).
In your GitHub account, go to Settings / Developer settings / Personal access tokens
and select Generate New Token
. Make a note of the token somewhere safe since this is the only chance you get to see it.
This file contains 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
# Here's an example of how you might set <tt>Time.zone</tt> on a per request basis and reset it when the request is done. | |
# <tt>current_user.time_zone</tt> just needs to return a string identifying the user's preferred time zone: | |
# | |
class ApplicationController < ActionController::Base | |
around_action :set_time_zone | |
def set_time_zone | |
if logged_in? | |
Time.use_zone(current_user.time_zone) { yield } | |
else |
This file contains 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
# app/models/user.rb | |
class User < ActiveRecord::Base | |
validates :zip_code, presence: true, zip_code: true | |
end |
This file contains 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
# DEBUG_RESOLVER=1 will show the activities of the resolver. | |
`DEBUG_RESOLVER=1 bundle update` |
This file contains 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 'bundler/inline' | |
require 'json' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'rest-client' | |
gem 'nokogiri' | |
gem 'memory_profiler' | |
end |
This file contains 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
# semaphore: | |
old steps: | |
export RAILS_ENV=test | |
bundle install --deployment --path vendor/bundle | |
bundle exec rake db:create | |
bundle exec rake db:setup | |
bundle exec rake db:test:prepare | |
bundle exec rake spec |
NewerOlder