Created
August 26, 2008 14:02
Revisions
-
leahneukirchen revised this gist
Aug 26, 2008 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ require 'open-uri' n = ARGV[0] =~ /^\d+$/ ? ARGV.shift : 5 q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } open("http://www.google.com/search?ie=utf-8&oe=utf-8&q=#{q}&num=#{n}").read. scan(%r{<h3 class=r><a href="(.*?)" class=l>(.*?)</a>}) { |url, desc| puts url puts " " + desc[0..70].gsub(%r{</?em>}, '') unless $q -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,5 +4,5 @@ require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read puts (html[%r{<font size=\+1><b>(.*?)</b></h2>}, 1] || 'not a calculation'). gsub(%r{\240|<font size=-2> </font>}, "").gsub("×", "x"). gsub(%r{<sup>(.*?)</sup>}, '^\\1 ') 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ #!/usr/bin/env ruby -s # goog [-q] [num] <string> / 26aug2008 chneukirchen / public domain require 'open-uri' n = ARGV[0] =~ /^\d+$/ ? ARGV.shift : 5 q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } open("http://www.google.com/search?q=#{q}&num=#{n}").read. scan(%r{<h3 class=r><a href="(.*?)" class=l>(.*?)</a>}) { |url, desc| puts url puts " " + desc[0..70].gsub(%r{</?em>}, '') unless $q } -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,5 @@ require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read puts (html[%r{<font size=\+1><b>(.*?)</b></h2>}, 1] || 'not a calculation'). gsub(%r{\240|<font size=-2> </font>}, "").gsub("×", "x"). gsub(%r{<sup>(.*?)</sup>}, '^\\1 ') -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # gcalc <google calculator string> / 26aug2008 chneukirchen / public domain require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,5 @@ require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read puts (html[%r{<font size=\+1><b>(.*?)</b></h2>}, 1] || 'not a calculation'). delete("\240").gsub("×", "x").gsub(%r{<sup>(.*?)</sup>}, '^\\1 ') -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,4 @@ require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read puts (html[%r{<font size=\+1><b>(.*?)</b></h2>}, 1] || 'not a calculation').delete("\240") -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ #!/usr/bin/env ruby require 'open-uri' q = ARGV.join(" ").gsub(/./m) { "%%%02X" % $&[0] } html = open("http://www.google.com/search?q=#{q}").read puts html[%r{<font size=\+1><b>(.*?)</b></h2>}, 1] || 'not a calculation'