This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pg_dump -D -U nome_usuario -h 127.0.0.1 -i -f nome_arquivo.sql -n nome_schema -T ignorar_tabela nome_banco |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls features/*.feature | xargs cucumber --language pt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Enumerable | |
def return(*) | |
if block_given? | |
each do |i| | |
value = yield(i) | |
return value if value | |
end | |
nil | |
else | |
super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useradd -G group_name -m user_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer