Skip to content

Instantly share code, notes, and snippets.

View alexandrebini's full-sized avatar

Alexandre Bini alexandrebini

View GitHub Profile
<%= content_for(:javascript) do %>
<%= javascript_tag "save_related_category_src(#{@category.categories.any?})"%>
<%- for category in @category.categories do %>
<%= javascript_tag "add_new_related_category(#{category.id})" %>
<% end %>
<% end %>
require "config/environment.rb"
namespace :carrierwave do
task :destroy, :class, :mount_uploader, :version do |task,args|
desc "Destroy one image version"
eval(args[:class]).all.each do |r|
r.instance_eval(args[:mount_uploader].to_sym).instance_eval(args[:version].to_sym).remove!
end
end
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
module WillPaginateHack
def self.included(base)
base.alias_method_chain :url, :hack
end
private
def url_with_hack(page)
if page > 1
url_without_hack(page)
else
namespace :backup do
task :set_name do
set :backup_folder, "/tmp"
set :backup_name, "#{application}-#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S')}"
set :backup_path, "#{backup_folder}/#{backup_name}"
end
task :db do
yml = YAML.load_file("#{repository}/config/database.yml")
@alexandrebini
alexandrebini / gist:1073029
Created July 8, 2011 22:56
get twitter kkey
def index
client = TwitterOAuth::Client.new( :consumer_key => 'key', :consumer_secret => 'key')
if session['token'].blank?
session['token'] = client.request_token(:oauth_callback => 'http://127.0.0.1:8000')
end
request_token = session['token']
if params['oauth_token'].blank?
redirect_to request_token.authorize_url
@alexandrebini
alexandrebini / pagseguro.pt-BR.yml
Created September 17, 2011 17:31
pagseguro.pt-BR.yml
pt-BR:
activemodel:
attributes:
pag_seguro/order:
abandon_url:
address: Endereço
address_city: Cidade
address_complement: Complemento
address_district: Bairro
address_number: Número
@alexandrebini
alexandrebini / gist:2471019
Created April 23, 2012 13:47
sshfs macos
# http://blog.philippklaus.de/2011/07/sshfs-on-mac-os-x-10-6-8-with-fuse4x/
# http://www.unityisplural.com/2011/11/getting-fuse4x-installed-on-osx-lion.html
xcode-select --switch /Applications/Xcode.app
brew install fuse4x sshfs
sudo cp -rfX /usr/local/Cellar/fuse4x-kext/0.10.0/Library/Extensions/fuse4x.kext /Library/Extensions
sudo chmod +s /Library/Extensions/fuse4x.kext/Support/load_fuse4x
@alexandrebini
alexandrebini / gist:2772444
Created May 23, 2012 00:04
remove .DS_Store
find ./ -type f | grep .DS_Store | xargs rm