Skip to content

Instantly share code, notes, and snippets.

View descovi's full-sized avatar
🐈
Programming with cat

Alessandro Descovi descovi

🐈
Programming with cat
View GitHub Profile
@descovi
descovi / paperclip.rb
Created December 16, 2017 14:35
Configurazione di Paperclip S3 per l'Europa (Francoforte).
# config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:s3_host_name] = 's3.eu-central-1.amazonaws.com'
@descovi
descovi / development.rb
Created December 16, 2017 13:35
Configurazione per integrazione con amazon s3 e paperclip.
secrets = Rails.application.secrets
config.paperclip_defaults = {
storage: :s3,
s3_credentials: {
bucket: secrets.amazon_bucket_name,
access_key_id: secrets.amazon_access_key_id,
secret_access_key: secrets.amazon_secret_access_key,
s3_region: "eu-central-1"
}
}
class ApplicationController < ActionController::Base
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || stored_location_for(resource) || root_path
end
end
@descovi
descovi / gist:7624800
Created November 24, 2013 08:24
error from unicorn
E, [2013-11-24T08:23:48.282063 #20438] ERROR -- : reaped #<Process::Status: pid 29427 exit 1> worker=1
I, [2013-11-24T08:23:48.282426 #20438] INFO -- : worker=1 spawning...
I, [2013-11-24T08:23:48.283720 #29440] INFO -- : worker=1 spawned pid=29440
I, [2013-11-24T08:23:48.301879 #29440] INFO -- : Refreshing Gem list
E, [2013-11-24T08:23:48.343457 #29430] ERROR -- : couldn't find HOME environment -- expanding `~' (ArgumentError)
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/guard-1.8.3/lib/guard.rb:23:in `expand_path'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/guard-1.8.3/lib/guard.rb:23:in `<module:Guard>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/guard-1.8.3/lib/guard.rb:8:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
#config windowHintsDuration 5
@descovi
descovi / validate_url.rb
Created February 20, 2013 07:54
Validate a url with http or without / Validare una url con http sia senza http
# RegEx: is from http://stackoverflow.com/a/13311941/632478
# Rubular: http://rubular.com/r/cdkLxAkTbk
validates :url, format: { with: /^(http|https):\/\/|[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/ix }
@descovi
descovi / application.rb
Created October 10, 2012 17:19
Settare l'applicazione per avere una timezone comune.
# Le query ora dialogano non più su utc ma sono impostato sulla time zone Italiana.
module Registration
class Application < Rails::Application
config.time_zone = 'Rome'
config.active_record.default_timezone = :local
@descovi
descovi / pagine.js.coffee
Created October 1, 2012 16:58
Quanto è bella?
$.ajax 'http://localhost:3000/risorsa/index',
type: 'GET',
data: "uniquekey=#{codice_commessa}",
dataType: 'json',
processData: true,
success: (data)->
customer = data.customer
for key, value of data.productInstance
if value.productName == "SCHEDA_AZIENDA_GIALLO"
productReferenceUrl = value.productReference.replace("ITA|","")
@descovi
descovi / event_custom.js.coffee
Created September 24, 2012 10:46
Event custom in coffescript
# launch event
$('body').trigger 'event_custom'
# capture the event
$('body').bind 'event_custom', ->
alert "event fired!"
@descovi
descovi / replacement.css
Created September 3, 2012 14:32
CSS replacement di Nicolas Gallagher
.replace {
font: 0/0 a;
text-shadow: none;
color: transparent;
}