Last active
February 7, 2017 11:21
-
-
Save nna774/78a1d0d5451f286c8ee9359a0e98ff81 to your computer and use it in GitHub Desktop.
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
[Unit] | |
Description=8h | |
After=network.target | |
[Service] | |
ExecStart=/home/nona/.dotfiles/bin/8h.sh | |
Type=oneshot | |
[Install] | |
WantedBy=multi-user.target |
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
#! /bin/sh -xe | |
WAIT=28800 # 8h | |
sleep ${WAIT} | |
/home/nona/.dotfiles/bin/slack.rb "<@U0323ESK6|nona7> もう${WAIT}秒も働き続けてるよ~~。そろそろ休んじゃダメ~?" |
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/ruby | |
# -*- encoding: utf-8 -*- | |
require 'json' | |
require "net/https" | |
WH_URI = "https://hooks.slack.com/services/~~~~~" | |
PER = 5400 # | |
def slack(msg) | |
uptime = `uptime`.chomp | |
hash = { | |
"text" => "#{msg} (uptime: #{uptime})", | |
"icon_emoji" => [":3:", ":3guru:", ":3heart:", ":3suya:", ":3oko:", ":3sake:"].sample, | |
"username" => `hostname`.chomp, | |
"channel" => "#nona-kanshi", | |
}.to_json | |
hash = "payload=" + hash | |
uri = URI.parse(WH_URI) | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
req = Net::HTTP::Post.new(uri.request_uri) | |
req.body = hash | |
res = https.request(req) | |
puts res.body | |
end | |
END { | |
slack "おやすみ~" | |
} | |
start = Time.now | |
cnt = 1 | |
while(true) do | |
diff = (Time.now - start).to_i | |
if (diff / PER).to_i > cnt then | |
cnt += 1 | |
slack "<@U0323ESK6|nona7> もう#{diff}秒も働き続けてるよ~~。そろそろ休んじゃダメ~?" | |
end | |
sleep 1 | |
end |
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/ruby | |
# -*- encoding: utf-8 -*- | |
require 'json' | |
require "net/https" | |
WH_URI = "https://hooks.slack.com/services/~~~~~" | |
uptime = `uptime`.chomp | |
hash = { | |
"text" => "#{ARGV[0]} (uptime: #{uptime})", | |
"icon_emoji" => [":3:", ":3guru:", ":3heart:", ":3suya:", ":3oko:", ":3sake:"].sample, | |
"username" => `hostname`.chomp, | |
"channel" => "#nona-kanshi", | |
}.to_json | |
hash = "payload=" + hash | |
uri = URI.parse(WH_URI) | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
req = Net::HTTP::Post.new(uri.request_uri) | |
req.body = hash | |
res = https.request(req) | |
puts res.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
8h決め打ちなのがちょっと微妙な気もしなくもない。