Skip to content

Instantly share code, notes, and snippets.

View Fernan2's full-sized avatar

Fernando Calatayud Fernan2

View GitHub Profile
environment = ARGV.first
unless environment
puts 'Usage: ruby ask_ey.rb [EY_ENVIRONMENT]'
puts ''
puts 'You could try:'
puts ''
puts ' ruby ask_ey.rb Rankia003_Large'
puts ''
exit
@Fernan2
Fernan2 / articulos_de_referencia
Last active December 3, 2015 10:03
Artículos de referencia
A fulanito no le llegan los correos:
https://www.gliffy.com/go/html5/5656107?app=1b5094b0-6042-11e2-bcfd-0800200c9a66
Cómo hacer preguntas de manera inteligente
http://www.sindominio.net/ayuda/preguntas-inteligentes.html
http://www.rankia.com/blog/doble-o-nada/2098530-finanzas-bolsa-inversion-libros-disponibles-para-descargar
Download videos from youtube.com or other video platforms:
https://github.com/rg3/youtube-dl
@Fernan2
Fernan2 / testing a factory
Created November 20, 2014 17:31
Testing a factory
it 'debe ser factoría válida' do
promocion = FactoryGirl.create(:promocion)
1000.times do
usuario_ejemplo = FactoryGirl.create(:usuario_con_telefono)
lead = FactoryGirl.create(:lead, promocion: promocion, nombre: usuario_ejemplo.nombre, apellido1: usuario_ejemplo.apellidos,telefono: usuario_ejemplo.telefono, email: usuario_ejemplo.email, empresa: Faker::Lorem.words(3).join)
lead.save
expect(lead.errors).to be_empty
end
end
@Fernan2
Fernan2 / Promote A Database Replica
Last active August 29, 2015 14:24
Promote A Database Replica
https://support.cloud.engineyard.com/hc/en-us/articles/205408228-Promote-a-Database-Replica
En la BD réplica, antes de parar máquinas, comprobar el tiempo de la última sincronización (debe ser menor que 1 minuto):
psql -U postgres -t -c "SELECT (now() - pg_last_xact_replay_timestamp()) AS time_lag;"
En el App Master:
/etc/init.d/vixie-cron status
sudo /etc/init.d/vixie-cron stop
UPDATE: You'll need to be careful with vixie-cron stop. Your instances have a "cron nanny" task that is designed to restart cron in the event it should stop and this does carry the potential that cron could restart during your promotion. Depending on your scheduling of course this might not impact anything. The cron_nanny task itself is managed by inittab so it will restart automatically if killed.
@Fernan2
Fernan2 / refactor.txt
Last active October 18, 2016 12:15
Refactor
Hemos hecho un scaffolding para validar con nuestro cliente una propuesta:
rails g scaffold Client first_name:string last_name:string email:string phone:string city:string address:string website:string
Esto genera, entre otros, el archivo _form.html.haml incluido en este Gist.
Una vez que el scaffolding ha sido validado, lo queremos "pasar a limpio"; y lo primero que nos pide un refactor son todas esas repeticiones de las mismas tres líneas para cada campo:
.field
= f.label xxxx
@Fernan2
Fernan2 / tematizable_spec.rb
Created November 28, 2016 22:25
Use temping to test tematizable
require 'rails_helper'
require 'temping'
Temping.create :bebedor do
include Tematizable
end
describe Tematizable do
let(:cerveza) { create(:tematica, nombre: 'cerveza') }
let(:whisky) { create(:tematica, nombre: 'whisky') }
@Fernan2
Fernan2 / tematizable.rb
Created November 28, 2016 23:25
Tematizable concern
require 'active_support/concern'
module Tematizable
extend ActiveSupport::Concern
included do
has_many :tematizaciones, as: :tematizable, class_name: 'Tematizacion'
has_many :tematicas, through: :tematizaciones
end
@Fernan2
Fernan2 / 20170117102232_create_finalidad_prestamo.rb
Last active January 17, 2017 19:23
Enumerados en Rails y Postgres
class CreateFinalidadPrestamo < ActiveRecord::Migration
def up
execute <<-SQL
CREATE TYPE finalidad_prestamo AS
ENUM ('Reunificar deudas', 'Estudios', 'Imprevistos', 'Compra de vehículo', 'Viaje', 'Reformas hogar', 'Otros');
SQL
end
def down
execute <<-SQL
@Fernan2
Fernan2 / 20170117114400_create_prestamos.rb
Created January 17, 2017 19:23
Enumerados en Rails y Postgres 2
class CreatePrestamos < ActiveRecord::Migration
def change
create_table :prestamos do |t|
...
t.column :finalidad, :finalidad_prestamo
...
end
end
end
@Fernan2
Fernan2 / 20170118114400_add_finalidad_to_prestamos.rb
Last active January 17, 2017 19:30
Enumerados en Rails y Postgres 3
class AddFinalidadToPrestamos < ActiveRecord::Migration
def change
add_column :prestamos, :finalidad, :finalidad_prestamo
end
end