Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
read arq ost < <(uname -om)
os=$(lsb_release -i | sed 's/.*:[[:space:]]//')
kernelr=$(uname -r)
host=$(sysctl -a 2>/dev/null|grep kernel.hostname|sed 's/.*=[[:space:]]//')
echo $os
echo $kernelr
echo $host
@JamesAndresCM
JamesAndresCM / zfsinstall-1-setup.sh
Created February 17, 2018 06:08 — forked from johnramsden/zfsinstall-1-setup.sh
Install scripts for installing Arch Linux on ZFS. Not runnable, just listed commands.
#!/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"
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 => exim@jcanalesm.me 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
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],
});
}
}
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 = []
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
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)
@JamesAndresCM
JamesAndresCM / parent_child.rb
Last active November 10, 2021 13:13
example parent child
# 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
module Utilities
def self.included(base)
base.extend(ClassMethods)
end
def method_one
puts 'Hello from an instance method'
end
module ClassMethods