Posted by root
Sat, 19 Jul 2008 21:59:00 GMT
require 'tempfile'
require 'net/http'
arg = ARGV[0].chomp
url = 'sa.dir.bg'
h = Net::HTTP.new(url, 80)
resp,data = h.get("/cgi/sabig.cgi?word=#{arg}", nil )
outtmp = Tempfile.new("translator")
outtmp << data.to_s
outtmp.rewind
puts %x[html2text "#{outtmp.path}"]
Posted in scripts | Tags tools | no comments
Posted by root
Sun, 13 Jan 2008 14:25:00 GMT
irb
Posted in Ruby | Tags tools | no comments
Posted by root
Sun, 13 Jan 2008 07:58:00 GMT
Rename each file in each sub-directory, substituting ‘%20’ with ’ ‘(space).
class File
def self.rename_basename(abs_name, old_str, new_str)
f_name = File.basename(abs_name).gsub Regexp.quote(old_str), new_str
d_name = File.dirname(abs_name)
File.rename(abs_name, d_name + '/' + f_name)
rescue
raise ArgumentError, "No such file #{filename}", caller
end
end
Dir["*/**"].each do |f|
if File.basename(f).match('%20')
File.rename_basename(f, '%20', ' ')
end
end
Posted in Ruby, scripts | Tags tools | no comments