githubが復活したら起こして

くれるスクリプトを書いたので昼寝する

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'net/http'
require 'uri'

uri = URI.parse('https://github.com/')
loop do
  puts "watch ... #{Time.now}"
  res = nil
  begin
    Net::HTTP.start(uri.host, uri.port) {|http|
      res = http.get(uri.path)
    }
  rescue => e
    puts 'down'
  rescue Timeout::Error
    puts 'down'
  end
  break if res and res.code.to_i < 400
  sleep 60
end

loop do
  `saykana ぎっとはぶふっかつ`
  sleep 1
end

http://github.comhttps://github.comはへのリダイレクトを返すページなので、しゃお先生が教えてくれなければこのまま眠り続けて死ぬところだった