Skip to content

Instantly share code, notes, and snippets.

View fedesoria's full-sized avatar

Federico Soria fedesoria

View GitHub Profile
class LeftBoxInput < SimpleForm::Inputs::Base
def input
"<div class='input-prepend'><span class='add-on'>#{options[:symbol]}</span>#{@builder.text_field(attribute_name, input_html_options)}</div>".html_safe
end
end
@fedesoria
fedesoria / prepend_checkbox_input.rb
Created October 14, 2011 23:40
Custom input for simple_form using twitter bootstrap
class PrependCheckboxInput < SimpleForm::Inputs::Base
def input
"<div class='input-prepend'>
<label class='add-on active' title='#{options[:tooltip]}' rel='tooltip' >
#{@builder.check_box(attribute_name.to_s + '_check')}
</label>
#{@builder.text_field(attribute_name, input_html_options)}
<span class='help-inline'>
#{options[:help]}
</span>
@fedesoria
fedesoria / apache.log
Created August 5, 2011 00:32
apache log error
[ pid=29556 thr=140539690551104 file=ext/apache2/Hooks.cpp:865 time=2011-08-04 16:42:49.371 ]: Unexpected error in mod_passenger: An error occurred while receiving HTTP upload data: The timeout specified has expired (70007)
Backtrace:
in 'boost::shared_ptr<Passenger::BufferedUpload> Hooks::receiveRequestBody(request_rec*)' (Hooks.cpp:1293)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:566)
@fedesoria
fedesoria / paperclip_scopes.rb
Created April 14, 2011 03:27
Paperclip Scopes
# For finding images as in Article.attachments.images
scope :images, where("file_content_type LIKE ?", "image%")
# For finding other files Article.attachments.docs
scope :docs, where("file_content_type NOT LIKE ?", "image%")
require 'open-uri'
def roulette(bet)
open('http://roulette.engineyard.com/').read.match("13") ? 35 * bet : 0
end
gateway.transfer 1000, '[email protected]',
:subject => "The money I owe you", :note => "Sorry it's so late"
gateway.transfer [1000, '[email protected]'],
[2450, '[email protected]', :note => 'You will receive another payment on 3/24'],
[2000, '[email protected]'],
:subject => "Your Earnings", :note => "Thanks for your business."
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
// Es de Yahoo, pero puedes cambiarlo a cualquier pagina que publique el tipo de cambio
mx_rate = YahooCurrency.get_rate!("USD", "MXN")
sub_number_to_currency(@product.price * mx_rate.rate)
<% form_for @offer do |f| %>
<%= f.label :version, 'Version' %>:
<%= f.text_field :version %><br />
<%= f.label :author, 'Author' %>:
<%= f.text_field :author %><br />
<% end %>