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
| #!/usr/bin/env ruby | |
| # Copy a heroku app (buildpacks, add-ons, labs, config, users). | |
| # This script is idempotent so it can run against an existing app. | |
| # | |
| # Usage: | |
| # $> clone-heroku-app source-app target-app | |
| require 'json' |
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 'factory_bot_rails' | |
| RSpec.configure do |config| | |
| config.before do | |
| Random.srand(config.seed) | |
| Faker::Config.random = Random.new(config.seed) | |
| allow(SecureRandom).to(receive(:uuid).and_wrap_original { |*| Faker::Internet.uuid }) | |
| 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
| # Wrapper for Segment. | |
| module Services::Analytics | |
| PREVENT_EXCEPTION = true | |
| def self.backend_default | |
| key = ENV['SEGMENT_SOURCE_SERVER_KEY'] | |
| if Rails.env.production? || (key && !key.blank?) | |
| @backend_default ||= Segment::Analytics.new( |
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
| copy($(".checklist-item:not(.checklist-item-checked)").map(function() { | |
| var $el = $(this), | |
| item = $el.find(".checklist-item-details-text").text(); | |
| if ($el.hasClass("checklist-item-state-complete")) { | |
| item = "- [x] " + item; | |
| } else { | |
| item = "- [ ] " + item; | |
| } | |
| return item; | |
| }).get().join("\n")); |
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
| RAILS WAY FOR REFERENCE ------------------------------------------------------- | |
| @note This was designed "web client" first, not really good for APIs. | |
| HTTP Verb Path Action Used for | |
| GET /photos photos#index display a list of all photos | |
| GET /photos/new photos#new return an HTML form for creating a new photo | |
| POST /photos photos#create create a new photo | |
| GET /photos/:id photos#show display a specific photo | |
| GET /photos/:id/edit photos#edit return an HTML form for editing a photo |
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
| config_default: &config_default | |
| adapter: <%= ENV['DATABASE_ADAPTER'] || 'postgresql' %> | |
| encoding: utf8 | |
| pool: <%= (ENV['DATABASE_POOL'] || ENV['MAX_THREADS'] || 5) %> | |
| # Readonly mode | expected privileges: [CONNECT, SELECT] | |
| config_default_readonly: &config_default_readonly | |
| <<: *config_default | |
| url: <%= ENV['DATABASE_URL_READONLY'] %> |
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
| module Test | |
| module RGB | |
| include Kit::Contract | |
| before ->(r:, g:, b:) { (0..255) === r && (0..255) === g && (0..255) === b } | |
| after [ | |
| ->(result:) { result.is_a?(String) }, | |
| ->(result:) { result.start_with?('#') }, | |
| ->(result:) { result.length.in?([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
| module RGB | |
| # First step ----------------------------------------------------------------- | |
| before ->(r:, g:, b:) { (0..255) === r && (0..255) === g && (0..255) === b } | |
| after [ | |
| ->(result:) { result.is_a?(String) }, | |
| ->(result:) { result.start_with?('#') }, | |
| ->(result:) { result.length.in?([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
| def sig(method_name) | |
| meth = method(method_name) | |
| parameters = meth.parameters.map do |type, name| | |
| case type | |
| when :req | |
| name | |
| when :rest | |
| "*#{name}" | |
| when :opt | |
| # Unknown default argument. |
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 'dry-types' | |
| require 'pry' | |
| module Types | |
| include Dry.Types | |
| end | |
| ProtocolType = Types::Symbol.enum(:http, :async, :websockets) | |
| HttpVerb = Types::Symbol.enum(:get, :post) |
NewerOlder