Created
May 29, 2012 13:51
-
-
Save joel/2828485 to your computer and use it in GitHub Desktop.
get last version of TextMate 2 Alpha
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
#!/usr/bin/env ruby | |
require "open-uri" | |
def print_status(status, n) | |
# The text of the status code is in [1] | |
case status.to_i | |
when 200 | |
puts "match #{n} http://dl.textmate.org/Application/TextMate_r#{n}.tbz" | |
system "wget http://dl.textmate.org/Application/TextMate_r#{n}.tbz" | |
system "mv -v TextMate_r#{n}.tbz ~/Downloads/" | |
exit | |
else | |
puts "...#{n}" | |
end | |
end | |
(9111..10000).each do |n| | |
url = "http://dl.textmate.org/Application/TextMate_r#{n}.tbz" | |
begin | |
io = open(url) | |
status = io.status[0] | |
rescue OpenURI::HTTPError => e | |
status = e.io.status[0] # => 3xx, 4xx, or 5xx | |
# puts "Whoops got a bad status code #{e.message}" | |
end | |
print_status(status, n) | |
sleep 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yay Ruby!!