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' | |
| # | |
| # Code example for my blogpost | |
| # | |
| # Hash lookup in Ruby, why is it so fast? | |
| # | |
| # | |
| # Struct used to store Hash Entries |
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 ApplicationRecord < ActiveRecord::Base | |
| primary_abstract_class | |
| def self.inherited(subclass) | |
| super | |
| return unless subclass.has_attribute?(:deleted_at) | |
| setup_for_soft_delete(subclass) | |
| rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid, ActiveRecord::ConnectionNotEstablished | |
| 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
| require 'irb/completion' | |
| IRB.conf[:USE_AUTOCOMPLETE] = false |
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
| ### Keybase proof | |
| I hereby claim: | |
| * I am dabit on github. | |
| * I am dabit (https://keybase.io/dabit) on keybase. | |
| * I have a public key ASBsBa_fMCF3KDZm8ko55Q8kctNFh-MRXYNgtumbNn8azwo | |
| To claim this, I am signing this object: |
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 'test_helper' | |
| class SomeReflexTest < StimulusReflex::TestCase | |
| setup do | |
| @user = users(:john) | |
| cookies.encrypted[:user_id] = @user.id | |
| end | |
| test '#create creates a Model' do | |
| name = "This is a test" |
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 StimulusReflex::TestCase < ActionCable::Connection::TestCase | |
| tests ApplicationCable::Connection | |
| def channel | |
| @channel = StimulusReflex::Channel.new connect, "test" | |
| end | |
| def reflex_class | |
| self.class.determine_constant_from_test_name(self.class_name) { |constant| constant } | |
| 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
| module Attributes | |
| attr_accessor :mi_atributo | |
| end | |
| class LaClase | |
| include Attributes | |
| def por_que_funciona? | |
| valor = mi_atributo + 3 | |
| 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 'application_system_test_case' | |
| class HomepagesTest < ApplicationSystemTestCase | |
| test 'homepage shows store name' do | |
| visit root_path | |
| assert_content 'My Tiendita Punto Com' | |
| end | |
| test 'homepage shows slogan' do |
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
| raise if Rails.env.production? | |
| unless User.exists?(email: 'test@example.com') | |
| organization = Organization.create!(name: 'Acme Inc', token: '12341234a') | |
| user = User.create!( | |
| email: 'test@example.com', | |
| password: 'test123test', | |
| role: :admin, | |
| confirmed_at: Time.current, | |
| organization: organization |
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
| I18n.t('welcome', scope: 'pages.title.welcome') | |
| I18n.t('pages.title.welcome') | |
| I18n.t('activerecord.model.dog') # => "Bienvenido" |
NewerOlder