Skip to content

Instantly share code, notes, and snippets.

View rodrigotassinari's full-sized avatar

Rodrigo Tassinari de Oliveira rodrigotassinari

View GitHub Profile
@rodrigotassinari
rodrigotassinari / example.sh
Created March 17, 2015 19:07
bash syntax to define defaults if no environment values are set
$ FOO=1234
$ echo ${FOO} ${BAR}
> 1234
$ echo ${FOO:-555} ${BAR:-666}
> 1234 666
@rodrigotassinari
rodrigotassinari / gist:2406384
Created April 17, 2012 14:37
Advanced file upload solutions
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 July 12, 2011 18:47 — forked from sagmor/gist:1041943
Patched Ruby 1.9.2 for faster load and GC
# 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 January 13, 2011 00:58
.bashrc para agradar o iTerm2
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
eval `/usr/libexec/path_helper -s`
source ~/.bash_profile
cd .
# 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"
# 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
class Image < ActiveRecord::Base
COMMON_ATTACHMENT_OPTIONS = {
:content_type => :image,
:max_size => 1.megabyte,
:thumbnails => {
:thumbnail => "75x75!",
:small => "100x",
:medium => "240x",
:large => "500x",
}
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