Skip to content

Instantly share code, notes, and snippets.

View peterb's full-sized avatar

Peter Baker peterb

  • 23:30 (UTC +02:00)
View GitHub Profile
class ForwardsMailbox < ApplicationMailbox
def process
Idea.create(description: mail.subject, clip: blob_from_attachment)
end
private
def blob_from_attachment
ActiveStorage::Blob.create_and_upload!(
io: StringIO.new(mail.attachments.first.body.to_s),
49 ==> Running Formulae#formula!(mysql@5.7)
50 ==> Determining dependencies...
51 ==> brew fetch --retry cmake gdbm openssl@1.1 pkg-config python@3.8 readline sphinx-doc sqlite xz
52 ==> Determining dependents...
53 ==> Starting build of mysql@5.7
54 ==> brew fetch --retry mysql@5.7 --build-bottle --force
55 ==> brew install --only-dependencies --verbose --build-bottle mysql@5.7
56 ==> brew install --verbose --build-bottle mysql@5.7
57 ==> brew audit mysql@5.7 --online --git --skip-style
58 ==> brew bottle --verbose --json mysql@5.7
# Aqui cargo los datos que necesitamos para contestar las consultas del agente de viajes, prefiero
# el Hash porque este objeto obtengo varios métodos que me permite realizar operaciones complejas
# sin escribir una sola línea de código, que es una de las grandes ventajas del aspecto funcional
# de Ruby, que permite utilizar un estilo declarativo, en vez de decirle a la computadora cómo hacer
# la computación le digo qué computación deseo realizar y dejo que se encargue de los detalles.
precios = {
cancun: { enero: 2500, febrero: 2300, marzo: 2000},
varadero: { enero: 1700, febrero: 2000, marzo: 2200 }
}
### Rake task
namespace :crawl do
desc "Analizar datos"
task :my_web_page => :environment do
start_page = 1
end_page = 33
spider = Spider.new(1)
puts spider.header_row
@peterb
peterb / ninguno
Created October 31, 2012 22:28 — forked from Anton1985/ninguno
Errores, q tengo en la generacion del login
#model/users.rb
class User < ActiveRecord::Base
attr_accessible :email, :password_hash, :password_salt
attr_accessor :password
before_save :encrypt_password
validates_confirmation_of :password
validates_presence_of :password, :on => :create
validates_presence_of :email
@peterb
peterb / gist:1085681
Created July 15, 2011 22:21
/tmp/homebrew-mysql-5.5.14-W7GO/mysql-5.5.14/CMakeCache.txt
We couldn’t find that file to show.
# Needed to be separate from setup_facebook_session to avoid double render error
def setup_facebook_app
#ensure_application_is_installed_by_facebook_user unless headless_mode or params[:app_token] == Digest::MD5.hexdigest(form_authenticity_token)
end
def create
if @thing.save
render :partial => 'thing', :layout => false
else
render :action => 'new', :layout => false
end
end
$('form').live('submit', function() {
<form name="frmbusqueda" action="../advanced_tel/lista_ordenes_5.php" method="post" onsubmit="return verificar()">
<table width="100%" cellspacing="4">
<tr>
<td>&nbsp;</td>
<td><input type="checkbox" name="checkbox1" value="checkbox" onClick="habilitaDeshabilitack1(this.form)">
Por Area Cliente</td>
</tr>
<tr>
<td>Area Cliente </td>
class Pharmacist < ActiveRecord::Base
has_many :wards
has_many :beds, :through => :wards
has_many :admissions, :through => :beds
has_many :patients, :through => :admissions
...