Posted by root
Sun, 20 Jul 2008 03:46:00 GMT
AoH = [{"z"=>26}, {"g"=>7}, {"r"=>18}, {"a"=>1}, {"v"=>22}]
AoH.map{|e| e.to_a.flatten}.sort{|x,y| x[0] <=> y[0]}
AoH.map{|e| e.to_a.flatten}.sort{|x,y| x[1] <=> y[1]}
Posted in Ruby | Tags sort | no comments
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
Thu, 10 Jul 2008 14:44:00 GMT
def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
l = length - truncate_string.chars.length
text.chars.length > length ? text.chars[0...l] + truncate_string : text
end
def truncate(text, _length = 30, truncate_string = "...")
text[0..(_length-1)] + truncate_string
end
Posted in Ruby | Tags RoR | 2 comments
Posted by root
Wed, 09 Jul 2008 22:40:00 GMT
Here’s the mirror
Behind there is a screen
Turn around
On both ways you can get in
The experience of survival
Look around just people, can you hear their voice
Find the one who’ll guide you to the limits of your choice
The experience / of survival
Try to think about it …
That’s the chance to live your life and discover
Try to think about it
The experience of survival
The experience …
The experience of survival
The experience …
Posted in programming | Tags Enigma | 1 comment
Posted by root
Wed, 09 Jul 2008 20:08:00 GMT

Posted in programming | Tags web | no comments
Posted by root
Tue, 08 Jul 2008 00:26:00 GMT
Go to your TRAC project dir and issue the following commands:
1. cd to_your_trac_project_dir
2. ruby -i -pe ’$_.sub! /(repository_dir\s=\s).+/, “repository_dir = NEW_repository_PATH”’ trac.ini
3. trac-admin . resync
Posted in scripts | Tags SA | no comments
Posted by root
Sun, 06 Jul 2008 11:04:00 GMT
Some of the more rarely used string methods:
str = "the tester"
str["tester"]
str[/\w+\s\w+/]
emulates
capitalize!
str[/(\w+)/] = ($1[0] - 32).chr
RDoc Documentation
Posted in Ruby | Tags string | no comments
Posted by root
Fri, 04 Jul 2008 13:46:00 GMT
Results in the following:
once in a blue moon = 1.16699016 × 10-8 hertz
Can be tested here
Tags Google | no comments