Last active
December 28, 2015 02:18
-
-
Save parrot-studio/7426569 to your computer and use it in GitHub Desktop.
miniが待てないんだよщ(゚Д゚щ)
This file contains 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
# encoding: utf-8 | |
require 'mail' | |
MAIL_ENCODING = 'ISO-2022-JP' | |
MYADDR = "hogehoge" | |
def send_message | |
mes = "mini来た!!" | |
m = Mail.new | |
m.charset = MAIL_ENCODING | |
m.body.charset = MAIL_ENCODING | |
m.from = MYADDR | |
m.to = MYADDR | |
m.subject = mes | |
m.body = mes.encode(MAIL_ENCODING, :invalid => :replace, :undef => :replace).force_encoding('binary') | |
m.deliver! | |
end | |
loop do | |
ret = `curl -I http://store.apple.com/jp` | |
exit unless ret | |
fl = ret.lines.first.chomp | |
m = fl.match(/(\d\d\d)/) | |
exit unless m | |
case m[1].to_i | |
when 0 | |
exit | |
when 200..299 | |
send_message | |
exit | |
else | |
sleep 300 | |
next | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
このスクリプトのおかげで、miniを即座に注文できましたよヽ(`・ω・´)ノ