Skip to content

Instantly share code, notes, and snippets.

@joel
Created May 29, 2012 13:51
Show Gist options
  • Save joel/2828485 to your computer and use it in GitHub Desktop.
Save joel/2828485 to your computer and use it in GitHub Desktop.
get last version of TextMate 2 Alpha
#!/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
@loveybot
Copy link

Yay Ruby!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment