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
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
#
# 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 //'`
}
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}"
DIRECTORIES = %w(Users/username)
TO = '/path/for/backup'
OPTIONS = { :rsync => '--progress -varRu', :remote => false }
rsync DIRECTORIES, nil, TO, OPTIONS
class MigrateProductsToPaperclip < ActiveRecord::Migration
def self.up
# Rename the old "image" column to "old_file_name", since Product.image will now try to do Paperclip stuff
rename_column :products, :image, :old_file_name
# Rename asset directories to pluralize
File.rename("public/system/product","public/system/products")
File.rename("public/system/products/image","public/system/products/images")
pt-BR:
errors:
messages:
expired: "expirou, por favor solicite uma nova"
not_found: "não encontrado"
already_confirmed: "já foi confirmado, por favor tente fazer login"
not_locked: "não foi bloqueado"
not_saved:
one: "1 erro evitou que este %{resource} fosse gravado:"
other: "%{count} erros evitaram que este %{resource} fosse gravado:"
@shadowmaru
shadowmaru / db-open
Created March 6, 2017 23:43 — forked from helderco/db-open
Script to open a mysql database in Sequel Pro from a service in docker-compose.
#!/bin/bash
set -e
show_help() {
cat << EOF
Usage: ${0##*/} [-u USER] [-p PASS] [-P PORT] [-H HOST] [DATABASE]
${0##*/} -h
Open a standard connection in Sequel PRO.