Skip to content

Instantly share code, notes, and snippets.

View shadowmaru's full-sized avatar
:shipit:
Ship it!

Ricardo Shiota Yasuda shadowmaru

:shipit:
Ship it!
View GitHub Profile
require 'rubygems'
require 'activesupport'
def rsync(directories, from, to, options = {})
options.reverse_merge!(:rsync => "-varRu",
:remote => true)
directories.each do |dir|
destination = options[:remote] ? "#{from}:/#{dir}" : "/#{dir}"
command = "rsync #{options[:rsync]} #{destination} #{to}"
class PageSweeper < ActionController::Caching::Sweeper
observe Page
def after_save(page)
clear_page_cache
end
def after_destroy(page)
clear_page_cache
end
module ActionController
module Caching
class Sweeper
def sweep_directory(dirs)
dirs.each do |dir|
cache_dir = RAILS_ROOT + "/public/#{dir}"
FileUtils.rm_r(Dir.glob(cache_dir+"/*")) rescue Errno::ENOENT
RAILS_DEFAULT_LOGGER.info("Cache directory '#{cache_dir}' fully swept.")
class PageSweeper < ActionController::Caching::Sweeper
observe Page
def after_save(page)
clear_page_cache
end
def after_destroy(page)
clear_page_cache
end
#
# Generates the migration and opens it in TextMate
#
# ex.:
# mig AddNewColumnToModel new_column:integer
#
function mig {
mate `script/generate migration $@ | tail -n1 | sed 's/.*create //'`
}
Letícia: Olá Ricardo, em que posso ajudar ?
Ricardo: Olá, fiz um pedido no dia 2/7 e até hoje ele está em ´análise´
Ricardo: O número do pedido é XXXXX
Letícia : Sr.,infelizmente houve um erro no sistema,
sob o qual seu pedido se encontra. Pedimos
desculpas pelo transtorno, mas caso ainda
deseje adquirir este produto,pedimos para
class ImageModelsController < ApplicationController
before_filter :find_image_model, :only => [:update]
def update
if @image_model.update_attributes(params[:image_model])
@image_model.image.reprocess!
end
end
protected
<% calendar :year => 2009, :month => 1, :events => @events, :field => :happens_on do |date, events| %>
<% for event in events %>
<%= link_to event.name, event_path(event) %>
<% end %>
<% end %>
Useful Rails plugins
jrails
paperclip
resource_controller
restful-authentication
restful-authorization
shoulda
tlsmail
ultrasphinx
Processing OrdersController#fire (for xxx.xxx.xxx.xxx at 2008-11-19 09:06:43) [PUT]
Session ID: BAh7CjoOcmV0dXJuX3RvMDoMY3NyZl9pZCIlZmI0NGUxYzQxMTY0NWRhNDBh
YWVlZmM2ZmNhYTY3NzI6DHVzZXJfaWRpBiIKZmxhc2hJQzonQWN0aW9uQ29u
dHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7ADoNb3JkZXJf
aWQw--8ec59532c83eef92f2e1cdaada63121ecce91fdc
Parameters: {"action"=>"fire", "_method"=>"put", "authenticity_token"=>"f26f6ddcc8db30ba2a504002fb01883e1bfeb4b4", "id"=>"685019094", "e"=>"capture", "controller"=>"admin/orders"}
Gateway Error ...
Redirected to http://xxxxx.com/admin/orders
Completed in 0.65447 (1 reqs/sec) | DB: 0.04395 (6%) | 302 Found [http://xxxxxx.com/admin/orders/685019094/fire?e=capture]