Created
March 30, 2011 05:07
-
-
Save marocchino/893893 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'rubygems' | |
require 'wirble' | |
require 'ap' | |
require 'pp' | |
Wirble.init | |
Wirble.colorize | |
alias q exit | |
def vim file="." | |
system("vim #{file}") | |
end | |
def zsh | |
system("zsh") | |
end | |
def ssh *server# {{{ | |
if server.size > 1 | |
system("ssh #{server*"@"}") | |
else | |
system("ssh default_user@#{server}") | |
end | |
end# }}} | |
def copy path, options={}# {{{ | |
from = options[:from] || "origin" | |
to = options[:to] || "target" | |
Dir.glob("#{ENV["PWD"].sub(to,from)}/#{path}").each { |file| | |
system "mkdir -p #{file.sub(from,to).sub(/[^\/]+$/,"")};cp -r #{file} #{file.sub(from,to)}" | |
} | |
end# }}} | |
def find extension, regexp, output=STDOUT # {{{ | |
root = RAILS_ROOT rescue ENV["PWD"] | |
if extension.to_s =~ /[\.\*\/]/ | |
path = "#{root}/#{extension}" | |
else | |
path = "#{root}/**/*.#{extension}" | |
end | |
unless output == STDOUT | |
ofile = output | |
output = File.open("#{root}/#{ofile}", "w+") | |
end | |
size = 0 | |
Dir.glob(path).each do |file| | |
lines = File.read(file).split("\n").select{|line| line =~ regexp } | |
unless lines.size == 0 | |
hash = {:file => file , :match => lines} | |
if output == STDOUT | |
ap hash | |
else | |
output.puts hash.to_yaml | |
end | |
size += 1 | |
end | |
end | |
unless output == STDOUT | |
output.close | |
end | |
"found #{size} file(s)" | |
end# }}} | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
if ENV.include?("RAILS_ENV") && !Object.const_defined?("RAILS_DEFAULT_LOGGER") | |
#if ActiveRecord::Base.connection.class != ActiveRecord::ConnectionAdapters::SQLServerAdapter | |
require 'logger' | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
#end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment