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 'benchmark' | |
| def array_plus_array(n) | |
| result = [] | |
| n.times do |i| | |
| result = result + [i] | |
| end | |
| result | |
| 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
| require 'benchmark' | |
| require 'active_support/core_ext/hash/keys' | |
| def create_mixed_hash(size) | |
| hash = {} | |
| size.times do |i| | |
| if i.even? | |
| hash[i.to_s] = "value#{i}" | |
| else | |
| hash[i.to_s.to_sym] = "value#{i}" |
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 "sqlite3" | |
| require "benchmark" | |
| DB_NAME = "test.sqlite" | |
| parent_connection = SQLite3::Database.new(DB_NAME) | |
| parent_pid = Process.pid | |
| mode = ARGV[0] || "constant" | |
| process_count = ARGV[1] == "--processes" ? ARGV[2].to_i : 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
| module OAuth | |
| extend ActiveSupport::Concern | |
| SIGN_UP = "sign_up" | |
| SIGN_IN = "sign_in" | |
| DESTINATION_PARAMS_KEY = :destination | |
| DESTINATION_SESSION_KEY = "oauth.destination" | |
| ORIGIN_PARAMS_KEY = :origin | |
| ORIGIN_SESSION_KEY = "oauth.origin" |
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
| users_file = Rails.root.join('storage', 'users.yml.erb') | |
| if File.exist? users_file | |
| users = YAML.load(ERB.new(File.read(users_file)).result) | |
| User.insert_all( | |
| users.map { |user| user.except("password") }, | |
| unique_by: :username | |
| ) | |
| 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
| ass ApplicationController < ActionController::Base | |
| before_action :authenticate! | |
| helper_method :current_user | |
| helper_method :user_signed_in? | |
| private | |
| def authenticate | |
| @current_user = nil |
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
| # frozen_string_literal: true | |
| module Router | |
| class << self | |
| include Rails.application.routes.url_helpers | |
| def default_url_options | |
| Rails.application.config.action_controller.default_url_options || {} | |
| 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
| require 'sqlite3' | |
| require 'minitest/autorun' | |
| puts "info: gem version: #{SQLite3::VERSION}" | |
| puts "info: sqlite version: #{SQLite3::SQLITE_VERSION}/#{SQLite3::SQLITE_LOADED_VERSION}" | |
| puts "info: sqlcipher?: #{SQLite3.sqlcipher?}" | |
| puts "info: threadsafe?: #{SQLite3.threadsafe?}" | |
| class TestCase < Minitest::Test | |
| def setup |
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 "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| gem "sqlite3" | |
| gem "enumerable-statistics" | |
| end | |
| require "benchmark" |
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
| <form action="#"> | |
| <section data-controller="passphrase"> | |
| <label for="passphrase-for-registration">Passphrase</label> | |
| <input type="text" | |
| id="passphrase-for-registration" | |
| data-passphrase-registration-target="input" | |
| data-action="passphrase#validate" | |
| autocomplete="new-password" | |
| required | |
| minlength="12" |