Created
May 29, 2012 17:10
-
-
Save Oaz/2829565 to your computer and use it in GitHub Desktop.
get last version of TextMate 2 once again
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" | |
require "FileUtils" | |
def with_resource(url) | |
begin | |
resource = open(url) | |
yield resource.status, resource | |
rescue OpenURI::HTTPError => the_error | |
yield the_error.io.status, nil | |
end | |
end | |
(9111..10000).each do |n| | |
url = "http://dl.textmate.org/Application/TextMate_r#{n}.tbz" | |
with_resource(url) do |status,resource| | |
case status[0].to_i | |
when 200 | |
puts "match #{n} #{url}" | |
FileUtils.copy_stream(resource,open("~/Downloads/TextMate_r#{n}.tbz","w")) | |
exit | |
else | |
puts "...#{n} #{status[0]} #{status[1]}" | |
end | |
end | |
sleep 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really interesting! Thx