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
# first way | |
# frozen_string_literal: true | |
class EncryptionService | |
delegate :encrypt_and_sign, :decrypt_and_verify, to: :encryptor | |
class << self | |
def encrypt(secret:) | |
new.encrypt_and_sign(secret) | |
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 Utilities | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def method_one | |
puts 'Hello from an instance method' | |
end | |
module ClassMethods |
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
# categories without link | |
rails g model Category name parent_id:integer:index | |
class Category < ApplicationRecord | |
has_many :subcategories, class_name: 'Category', foreign_key: 'parent_id', dependent: :destroy | |
belongs_to :parent, class_name: 'Category', foreign_key: 'parent_id', optional: true | |
end | |
# linked_categories | |
rails g model Category name |
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 ReviewConfiguration < BaseRecord | |
has_many :review_answers, dependent: :destroy | |
accepts_nested_attributes_for :review_answers, allow_destroy: true | |
end | |
def review_answers_attributes=(attributes) | |
attributes = attributes.map(&:deep_symbolize_keys) | |
review_answer_ids = attributes.map{|el| el[:id]}.compact | |
begin | |
review_answers << ReviewAnswer.where(id: review_answer_ids) |
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 InventoryItem < ApplicationRecord | |
belongs_to :location | |
accepts_nested_attributes_for :location | |
end | |
def location_attributes=(attrs) | |
begin | |
self.location_id = Location.find_by!(name: attrs[:name]) | |
rescue ActiveRecord::RecordNotFound | |
super |
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 Base | |
include ActiveModel::Model | |
extend ActiveModel::Callbacks | |
attr_accessor :id | |
# https://stackoverflow.com/questions/17681789/rails-what-is-a-proper-way-to-include-callbacks-into-tableless-model | |
define_model_callbacks :save, :create | |
ALL = [] |
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
parseData(json: any){ | |
for (let indice in json.body.indicesItem){ | |
let entry = json.body.indicesItem[indice].indice; | |
if (entry.trim() == "IGPA" || entry.trim() == "IPSA" || entry.trim() == "INTER-10"){ | |
this.datos.push({ | |
key: "indice", | |
value: json.body.indicesItem[indice], | |
}); | |
} | |
} |
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
2018-04-25 14:42:15 SMTP connection from (jcanalesm.me) [172.17.0.1]:51024 I=[172.17.0.2]:25 closed by QUIT | |
2018-04-25 14:42:15 1fBLcd-00002t-Kf => [email protected] F=<> R=dnslookup T=remote_smtp S=31219 H=mail.jcanalesm.me [69.164.201.194] I=[172.17.0.2] K C="250- 30859 byte chunk, total 31219\\n250 OK id=1fBLcd-00002w-N1" | |
2018-04-25 14:42:15 1fBLcd-00002t-Kf Completed | |
2018-04-25 14:42:15 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1fBLcd-00002w-N1 | |
2018-04-25 14:42:15 SMTP connection from [172.17.0.1]:51028 I=[172.17.0.2]:25 (TCP/IP connection count = 1) | |
2018-04-25 14:42:15 1fBLcd-00002z-PS DKIM: d=jcanalesm.me s=dkim c=relaxed/relaxed a=rsa-sha256 b=1024 [invalid - public key record (currently?) unavailable] | |
2018-04-25 14:42:15 1fBLcd-00002z-PS DKIM: d=jcanalesm.me s=dkim c=relaxed/relaxed a=rsa-sha256 b=1024 [invalid - public key record (currently?) unavailable] | |
2018-04-25 14:42:15 1fBLcd-00002z-PS DKIM: d=jcanalesm.me s=dkim c=relaxed/relaxed a=rsa-sha256 b=1024 [invalid - public key record (currently |
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
prueba |
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
#!/bin/bash | |
# Check before running, may need intervention | |
# Pass in the following to the script, or hardcode it. | |
# Uncomment if hardcoding input. | |
BOOT_PARTITION="/dev/sdg1" | |
DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" | |
DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" | |
POOL="vault" |