Skip to content

Instantly share code, notes, and snippets.

View leandroh's full-sized avatar
:shipit:
To deploy or not to deploy?

Leandro Pará leandroh

:shipit:
To deploy or not to deploy?
View GitHub Profile
full_name = "Leandro Parazito"
name_list = full_name.split()
greeting_list = "Hi, I'm x".split()
# Get last item in greeting_list
greeting_list[-1] = name_list[0]
greeting = " ".join(greeting_list)
@leandroh
leandroh / init.sh
Created May 21, 2010 11:44 — forked from atmos/init.sh
#!/bin/sh
curl http://gist.github.com/raw/323731/install_homebrew > install_homebrew.rb
ruby install_homebrew.rb
rm install_homebrew.rb
echo "PATH=/usr/local/bin:/Developer/usr/bin:\$PATH; export PATH" >> ~/.profile
source ~/.profile
echo "Your path is now $PATH"
brew install git
brew update
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
module ActiveRecord
module Acts
module AsFlagable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_flagable(options)
unless flagable?
class Pedido < ActiveRecord::Base
def gera_numero_pedido
self.numero = Array.new(9){rand(9)}.join while self.numero.nil? or Pedido.find_by_numero(self.numero)
end
end
# Reincarnation for classes
class Class
def reincarnate
buried = Object.__send__(:remove_const, self.name)
Object.const_set(self.name, Class.new(buried))
end
end
class Abc
module AssertionExtensions
def method_missing(method_id, *arguments, &block)
return super unless method_id.to_s =~ /^assert_(not_)?(.*)$/
method = "#{$2}?"
object = arguments.first
if $1
arguments.each do |object|
assert ! object.send(method), "#{method} is not false for #{object}"
Rails::Initializer.class_eval do
def load_application_initializers_with_plugin_initializers
if gems_dependencies_loaded
plugin_loader.load_plugin_initializers
end
load_application_initializers_without_plugin_initializers
end
alias_method_chain :load_application_initializers, :plugin_initializers
end
module Enumerable
def return(*)
if block_given?
each do |i|
value = yield(i)
return value if value
end
nil
else
super
pg_dump -D -U nome_usuario -h 127.0.0.1 -i -f nome_arquivo.sql -n nome_schema -T ignorar_tabela nome_banco