Skip to content

Instantly share code, notes, and snippets.

View dabit's full-sized avatar

David Padilla dabit

View GitHub Profile
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
@dabit
dabit / .irbrc
Created February 24, 2022 18:54
Disable console autocomplete
require 'irb/completion'
IRB.conf[:USE_AUTOCOMPLETE] = false
### 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:
@dabit
dabit / some_reflex_test.rb
Last active June 9, 2020 15:25
reflex testing
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"
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
@dabit
dabit / libertinaje.rb
Created July 15, 2019 22:47
libertinaje
module Attributes
attr_accessor :mi_atributo
end
class LaClase
include Attributes
def por_que_funciona?
valor = mi_atributo + 3
end
@dabit
dabit / test.rb
Created July 10, 2019 19:33
gitlabci
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
@dabit
dabit / 1.rb
Created July 9, 2019 16:04
Trucos para desarrolladores
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
@dabit
dabit / 10.rb
Last active May 1, 2019 15:18
translations
I18n.t('welcome', scope: 'pages.title.welcome')
I18n.t('pages.title.welcome')
I18n.t('activerecord.model.dog') # => "Bienvenido"
@dabit
dabit / gist:44495c54e14607aae979
Last active February 2, 2016 15:36
Software Engineer wishbird.com.mx
# Senior Software Engineer
Buscamos a un talentoso Desarrollador / Programador con experiencia para colaborar en nuestro emocionante proyecto Wishbird.com.mx.
Una plataforma que ayuda a encontrar y contratar experiencias, tours y actividades en todo México.
Que estamos buscando:
* Nivel experiencia: Intermedio o Senior
* Inicio: enero 2016
* Tareas: