Skip to content

Instantly share code, notes, and snippets.

View fedesoria's full-sized avatar

Federico Soria fedesoria

View GitHub Profile
@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 / 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>
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
class User
after_initialize :init
def init
self.number ||= 0.0 #will set the default value only if it's nil
end
end
@fedesoria
fedesoria / chubas.coffee
Created June 19, 2012 05:05
window variables
window.variable = "foo"
en vez de
variable = "foo"
y asi lo puedes llamar desde donde sea como
window.variable
@fedesoria
fedesoria / checkin_server.rb
Created September 12, 2012 02:28
stream in sinatra
class CheckinServer < Sinatra::Base
include Paperclip::Glue
set :server, :thin
set :views, settings.root + '/../app/views/sinatra'
connections = []
@fedesoria
fedesoria / test_routes.rb
Created February 2, 2013 00:57
Test routes on console
# include routing and URL helpers
include ActionDispatch::Routing
include Rails.application.routes.url_helpers
# use routes normally
users_path #=> "/users"

Capybara

save_and_open_page

Matchers

have_button(locator)
@fedesoria
fedesoria / through_polymorphic.rb
Last active December 27, 2015 05:19
What I'm I doing wrong?
class User
has_many :parameter_values, as: :valuable
has_many :parameters,-> { uniq }, :through => :parameter_values
end
class ParameterValue
belongs_to :parameter
belongs_to :valuable, :polymorphic => true
end
@fedesoria
fedesoria / gist:7934894
Created December 12, 2013 20:30
Sublime Text - Preferences User
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"fade_fold_buttons": false,
"file_exclude_patterns":
[
"*.tmTheme.cache",
"*.tmPreferences.cache",