Skip to content

Instantly share code, notes, and snippets.

Avatar

Rodrigo Tassinari de Oliveira rodrigotassinari

View GitHub Profile
@rodrigotassinari
rodrigotassinari / example.sh
Created Mar 17, 2015
bash syntax to define defaults if no environment values are set
View example.sh
$ FOO=1234
$ echo ${FOO} ${BAR}
> 1234
$ echo ${FOO:-555} ${BAR:-666}
> 1234 666
@rodrigotassinari
rodrigotassinari / gist:2406384
Created Apr 17, 2012
Advanced file upload solutions
View gist:2406384
Requirements:
- multiple file uploads at the same time (or at least queued)
- compatible with IE8+, Firefox 3.6+, Chrome 5+, Safari 4+
Nice to haves:
- individual and/or global progress bar
- drag & drop
- no flash necessary
Existing solutions (any comments? any other recommendations?):
@rodrigotassinari
rodrigotassinari / gist:1078666
Created Jul 12, 2011 — forked from sagmor/gist:1041943
Patched Ruby 1.9.2 for faster load and GC
View gist:1078666
# Ruby 1.9 Fast require:
# https://gist.github.com/1008945
curl https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6/load.patch > load.patch
# Ruby 1.9.2 GC Patch:
# https://gist.github.com/856296
curl https://raw.github.com/gist/856296/a19ac26fe7412ef398bd9f57e61f06fef1f186fe/patch-1.9.2-gc.patch > gc.patch
rvm install 1.9.2-p180 --patch load.patch,gc.patch -n loadgc
rm gc.patch load.patch
@rodrigotassinari
rodrigotassinari / .bashrc
Created Jan 13, 2011
.bashrc para agradar o iTerm2
View .bashrc
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
eval `/usr/libexec/path_helper -s`
source ~/.bash_profile
cd .
View gist:243509
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
View gist:162775
# modificado a partir de http://github.com/relevance/etc/raw/26ae85c2f6c7d2640a3c75d619ad7ab8fc1cc570/bash/ruby_switcher.sh
# (ver http://blog.thinkrelevance.com/2009/7/29/ruby-switcher-working-with-multiple-ruby-versions-has-never-been-this-easy)
#
# modificado para usar o ruby nativo do ubuntu (9.04) como default
# permite alternar entre os rubys todos E o ruby nativo do ubuntu
#
# modificações (ao final do arquivo somente):
# * inclusão da função 'use_native_ruby'
# * comentário da linha que ativa o ruby nativo do leopard por padrão
# * inclusão de linha que ativa o ruby nativo do ubuntu por padrão
View gist:161521
class Image < ActiveRecord::Base
COMMON_ATTACHMENT_OPTIONS = {
:content_type => :image,
:max_size => 1.megabyte,
:thumbnails => {
:thumbnail => "75x75!",
:small => "100x",
:medium => "240x",
:large => "500x",
}
View gist:161515
class TempImage < Image
has_attachment({
:storage => :file_system,
:path_prefix => "public/uploads/#{table_name}",
}.merge(COMMON_ATTACHMENT_OPTIONS)
)
after_create :queue_move_to_s3
def move_to_s3