Skip to content

Instantly share code, notes, and snippets.

View lazaronixon's full-sized avatar

Lázaro Nixon lazaronixon

View GitHub Profile
@lazaronixon
lazaronixon / tagbuilder.rb
Created September 9, 2024 08:09
TagBuilder
class TagBuilder
def initialize(context, tag_name, content = nil, klass: nil, default_attributes: {}, **attributes, &block)
@context = context
@tag_name = tag_name
@content = content
@klass = klass
@default_attributes = default_attributes
@attributes = attributes
@block = block
end
@lazaronixon
lazaronixon / tabs.css
Last active August 30, 2024 07:02
Tab bar rails
.tabs {
display: flex;
flex-direction: column;
gap: var(--size-2);
}
.tabs__list {
background-color: var(--color-border-light);
block-size: var(--size-10);
border-radius: var(--rounded-md);
@lazaronixon
lazaronixon / application_helper.rb
Last active August 14, 2024 11:33
Current page helpers
module ApplicationHelper
def current_page_with_controllers?(controllers)
controllers.any? { |controller| current_page? controller: controller }
end
def current_page_with_actions?(actions)
actions.any? { |action| current_page? action: action }
end
def current_page_with_controllers_and_actions?(controllers, actions)
.popover {
background-color: var(--color-bg);
border-width: var(--border);
border-radius: var(--rounded-md);
box-shadow: var(--shadow-md);
color: var(--color-text);
inline-size: var(--popover-width, var(--size-72));
margin-block: var(--size-1);
padding: var(--size-4);
@lazaronixon
lazaronixon / medical_record.rb
Last active June 22, 2024 17:01
Api upload
class MedicalRecord < ApplicationRecord
enum kind: %i[ imaging results notes ]
belongs_to :patient, class_name: "User", inverse_of: :medical_records
has_one_attached :document, dependent: :detach
scope :with_kind, -> (kind) { where kind: kind }
after_create_commit :deliver_updation
@lazaronixon
lazaronixon / database.yml
Last active May 28, 2024 01:50
config/initializers/sqlite3.rb
# config/database.yml
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
@lazaronixon
lazaronixon / application_controller.rb
Last active October 2, 2024 14:28
Application controller and concerns
class ApplicationController < ActionController::Base
include SetCurrentRequestDetails
include SetCurrentTimeZone
include Authenticate
include ForgeryProtection
include ErrorResponses
include SetSentryUser
@lazaronixon
lazaronixon / Gemfile
Last active April 3, 2023 18:33
Action deliver
gem "abstract_notifier"
@lazaronixon
lazaronixon / settings.json
Last active February 2, 2023 05:32
VSCode as Atom
{
"workbench.startupEditor": "none",
"workbench.colorTheme": "Atom One Light",
"workbench.activityBar.visible": false,
"editor.minimap.enabled": false,
"editor.scrollBeyondLastLine": false,
"editor.guides.indentation": false,
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.renderControlCharacters": false,
@lazaronixon
lazaronixon / callbacks.rb
Created May 18, 2022 00:33
Elastic search index async
module ElasticsearchExtension
module Callbacks
extend ActiveSupport::Concern
included do
after_commit -> { IndexJob.perform_later(:create, self.class.name, self.id) }, on: :create
after_commit -> { IndexJob.perform_later(:update, self.class.name, self.id) }, on: :update
after_commit -> { IndexJob.perform_later(:destroy, self.class.name, self.id) }, on: :destroy
end
end