Skip to content

Instantly share code, notes, and snippets.

View cotocisternas's full-sized avatar

Coto Cisternas cotocisternas

View GitHub Profile
@cotocisternas
cotocisternas / validation.md
Created January 31, 2019 15:58
rails custom validations

Rails Custom Validations

app/models/doc.rb

# frozen_string_literal: true

class Doc
  include Mongoid::Document
  include Mongoid::Timestamps
@cotocisternas
cotocisternas / convecta.md
Last active January 14, 2019 00:45
Convecta Problems

Integracion AAndes

Problemas con CONVECTA

Property Date

Ambas fechas se representan identicas, y se homologan a la fecha de publicacion del XML, no de la propiedad

  • property[:publication_date]
  • property[:update_date]
pry(main)> properties.map { |property| property[:publication_date] }
@cotocisternas
cotocisternas / search.rb
Last active November 19, 2018 23:54
Matrix Validation
# frozen_string_literal: true
require 'boo/validation'
module API
module Validations
module Params
Search = Boo::Validation.Params do
configure do
config.type_specs = true
install() {
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
@cotocisternas
cotocisternas / taggable.rb
Created July 19, 2017 20:55
Mongoid Concern for Taging
module Mongoid
module Taggable
extend ActiveSupport::Concern
included do
field :tags, type: Array, default: []
index tags: 1
def tag_list=(tags)
self.tags = tags.to_s.split(",").collect{ |t| t.strip }.delete_if{ |t| t.blank? }
@cotocisternas
cotocisternas / try_ssh.rb
Last active August 10, 2017 20:27
try_ssh
#!/usr/bin/env ruby
require 'net/ssh'
require 'timeout'
require 'unicode'
require 'colorize'
hosts = ['127.0.0.1']
ports = ['22']
users = ['root', 'admin', 'ec2-user']
@cotocisternas
cotocisternas / security-rules.pp
Last active September 30, 2016 03:40
Puppet Security Rules
Firewall {
require => undef,
}
firewall { '000 INPUT allow related and established':
proto => 'all',
action => 'accept',
state => ['RELATED', 'ESTABLISHED']
}
firewall { '001 accept all icmp':
proto => 'icmp',
@cotocisternas
cotocisternas / dns.pp
Created September 28, 2016 02:55
FIX? dns records for puppet autoconfig
# = Class: profiles::dns::server
#
# Author: Coto Cisternas <cotocisternas@gmail.com>
class profiles::dns::server (
$reverse = $profiles::params::primary_reverse,
$primary_domain = $profiles::params::domain,
$ns = $profiles::params::bind_nameservers,
$admin_email = $profiles::params::bind_admin_email,
$forwarders = $profiles::params::bind_forwarders,
$allow_query = $profiles::params::bind_allow_query,
@cotocisternas
cotocisternas / aut_enc.rb
Last active May 25, 2016 02:51
Ruby Aut Enc
require 'openssl'
require 'base64'
key = 'hello'.ljust(8, "\x00")
txt = 'hello'.ljust(64, "\x00")
des = OpenSSL::Cipher.new('DES-ECB')
des.encrypt
des.key = key
plain = des.update(txt) + des.final
Base64.encode64(plain)
@cotocisternas
cotocisternas / aut_enc.py
Last active May 25, 2016 02:51
Python Aut Enc
from Crypto.Cipher import DES
import base64
key = 'hello'.ljust(8, '\x00')
txt = 'hello'.ljust(64, '\x00')
des = DES.new(key, DES.MODE_ECB)
str = des.encrypt(txt)
base64.b64encode(str)