Skip to content

Instantly share code, notes, and snippets.

@Oaz
Created May 29, 2012 17:10
Show Gist options
  • Save Oaz/2829565 to your computer and use it in GitHub Desktop.
Save Oaz/2829565 to your computer and use it in GitHub Desktop.
get last version of TextMate 2 once again
#!/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
@joel
Copy link

joel commented May 29, 2012

Really interesting! Thx

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