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
# rails new app_name -m ./template.rb | |
self.instance_variable_set(:@options, self.instance_variable_get(:@options).merge( | |
skip_javascript: true, | |
skip_hotwire: true, | |
skip_action_mailbox: true, | |
skip_action_text: true, | |
database: 'postgres' | |
)) |
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
on run {input, parameters} | |
tell application "iTerm" | |
if not (exists first window) then | |
create window with default profile | |
end if | |
tell current window | |
-- leave only one tab opened | |
repeat (count of tabs) - 1 times | |
tell current tab |
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
module Concerns | |
module BrowserCheck | |
extend ActiveSupport::Concern | |
NOT_SUPPORTED_VERSIONS = { | |
ie: 11, | |
edge: 19, | |
ios: 12, | |
android: 6 | |
}.freeze |
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
When(/^nothing$/) do | |
user1 = FactoryBot.create(:account_user) | |
user2 = FactoryBot.create(:account_user) | |
user1_session = User.serialize_into_session(user1) | |
user2_session = User.serialize_into_session(user2) | |
inject_session 'warden.user.user.key' => user1_session | |
visit '/' |
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 'capybara/cuprite' | |
# Then, we need to register our driver to be able to use it later | |
# with #driven_by method. | |
Capybara.register_driver(:cuprite) do |app| | |
Capybara::Cuprite::Driver.new( | |
app, | |
**{ | |
window_size: [1200, 800], | |
# See additional options for Dockerized environment in the respective section of this article |
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
encoding_env_vars = 'LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8' | |
required_ruby_version = File.open('.ruby-version').read.chomp | |
env_ruby_version = ENV['RUBY_VERSION'].chomp | |
project_path = File.expand_path("#{File.dirname(__FILE__)}/../..") | |
if required_ruby_version != env_ruby_version | |
require 'pty' | |
PTY.spawn("#{encoding_env_vars} rvm in #{project_path} do #{__FILE__}") do |stdout, stdin, pid| | |
while !stdout.eof? | |
puts stdout.gets |
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
# https://www.morozov.is/2019/01/11/partial-application-in-ruby.html | |
fun = ->(tag, text) { "<#{tag}>#{text}</#{tag}>" } | |
curried_fun = fun.curry | |
bold_fun = curried_fun.('b') | |
p fun.('b', 'yo') # "<b>yo</b>" | |
p curried_fun.('b').('yo') # "<b>yo</b>" | |
p bold_fun.('yo') # "<b>yo</b>" |
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 'time' | |
loop do | |
time = Time.now.to_s + "\r" | |
print time | |
$stdout.flush | |
sleep 1 | |
end |