#!/usr/bin/evn perl
use strict;
use warnings;
use utf8;
use Log::Log4perl qw(:easy);
use WWW::Mechanize::Chrome;
use File::Spec;
use File::Basename 'dirname';
use HTTP::Request::Common qw//;
use Encode;
use Furl qw//;
use JSON;
use Imager;
use DDP;
# TODO:
# * 会社付近の色を取得して雨が降っているか判定
my $dirname = File::Spec->rel2abs(dirname($0));
my $rain_url = 'http://www.river.go.jp/x/krd0207010.php?lon=139.50406730175018&lat=35.674031853779084&opa=0.4&zoom=8&leg=0&intvl=5&ext=0';
my $fn= $dirname . "/xrain.png";
my $logo = $dirname . '/logo_and_arrow.png';
Log::Log4perl->easy_init($ERROR);
my $mech = WWW::Mechanize::Chrome->new(headless => 1);
$mech->viewport_size({ width => 760, height => 780 });
$mech->get($rain_url);
my $png = $mech->content_as_png;
open(my $fh, '>', $fn) or die $!;
binmode($fh);
print {$fh} $png;
close $fh;
my $img = Imager->new;
$img->read(file => $fn) or die $img->errstr;
$img->rubthrough(
src => do {
my $tmp = Imager->new;
$tmp->read(file => $logo) or die $tmp->errstr;
$tmp;
},
tx => 460,
ty => 527,
);
$img->rubthrough(
src => do {
my $tmp = Imager->new;
$tmp->read(file => $logo) or die $tmp->errstr;
$tmp;
},
tx => 1203,
ty => 527,
);
$img->rubthrough(
src => do {
my $tmp = Imager->new;
$tmp->read(file => $logo) or die $tmp->errstr;
$tmp;
},
tx => 460,
ty => 1170,
);
$img->rubthrough(
src => do {
my $tmp = Imager->new;
$tmp->read(file => $logo) or die $tmp->errstr;
$tmp;
},
tx => 1203,
ty => 1170,
);
$img->write(file => $fn) or die $img->errstr;
my $req = HTTP::Request::Common::POST('https://slack.com/api/files.upload',
Content_Type => 'multipart/form-data',
Content => [
token => 'xxxx',
channels => 'xxxx',
file => [$fn],
title => Encode::encode_utf8('XRAIN自動投稿'),
initial_comment => $rain_url,
]
);
my $res = Furl->new->request($req);
my $json = Encode::decode_json($res->content);
#p $json;
前回は試合までの待ち時間が長かったのですが今回は第1試合なのですぐ試合でした。対戦相手は自分と同世代くらいの方でした。フィッチでは、なぜかパニクって「回答は何ていうんだっけ」という状態になりました。どうにか「アップ・ダウン」が頭に出てきたので、アップで通じました。(ラフ or スムースのほうが通じやすいかな。)相手がレシーブを選んだので自分からサーブになりました。(練習時間が短くて体が温まっていないとの判断でレシーブを選んだのだろうか。)
[FATAL] There is nothing to do here, since there are no nodes with any plugins.
Please refer to http://munin-monitoring.org/wiki/FAQ_no_graphs at /usr/share/munin/munin-html line xx
サーバ監視ツールの「munin」が逝っちゃったようだ😣
/var/log/munin-node/munin-node.log を覗くと、
yyyy/mm/dd-HH:MM:SS Munin::Node::Server (type Net::Server::Fork) starting! pid(xxx)
Resolved [*]:4949 to [::]:4949, IPv6
Not including resolved host [0.0.0.0] IPv4 because it will be handled by [::] IPv6
Binding to TCP port 4949 on host :: with IPv6
yyyy/mm/dd-HH:MM:SS Server closing!
との怪しいログが...。
調べると、CPANモジュール「Net::Server」のドキュメントに情報がありました。
On my linux box which defaults to net.ipv6.bindv6only=0, the following is output.
perl -e 'use base qw(Net::Server); main->run(host => "*")'
Resolved [*]:8080 to [::]:8080, IPv6
Not including resolved host [0.0.0.0] IPv4 because it will be handled by [::] IPv6
Binding to TCP port 8080 on host :: with IPv6
If you do not want or need IPv6, simply set ipv to 4, pass IPv4 along in the port specification, set $ENV{'IPV'}=4; before running the server, or uninstall IO::Socket::INET6.