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
#!/opt/local/bin/ruby
class Dir
def self.create(dir, files=[])
Dir.mkdir(dir)
Dir.chdir(dir) do
files.collect { |f| File.new(f, 'w+') } if not files.empty?
yield if block_given?
end
end
pg_dump -D -U nome_usuario -h 127.0.0.1 -i -f nome_arquivo.sql -n nome_schema -T ignorar_tabela nome_banco
ls features/*.feature | xargs cucumber --language pt
module Enumerable
def return(*)
if block_given?
each do |i|
value = yield(i)
return value if value
end
nil
else
super
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 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}"
useradd -G group_name -m user_name
SELECT pg_database.datname,
pg_size_pretty(pg_database_size(pg_database.datname))
FROM pg_database
ORDER BY pg_database_size(pg_database.datname) DESC,
pg_database.datname;
# 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
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