#!/usr/bin/perl -T use strict; use warnings; use LWP::Simple; use POSIX qw(ceil); my $appid = "(YOUR APPID)"; my $yurl = "http://setsuden.yahooapis.jp/v1/Setsuden/latestPowerUsage?appid=$appid"; my $data = get($yurl); my ($usage) = $data =~ m{<Usage.*?>(\d+)</Usage>}; my ($capacity) = $data =~ m{<Capacity.*?>(\d+)</Capacity>}; my ($hour) = $data =~ m{<Hour.*?>(\d+)</Hour>}; my $rate = ceil($usage / $capacity * 100); my $url = 'https://chart.apis.google.com/chart?chxt=x&chbh=a,4,5&chs=225x69' .'&cht=bhs&chco=FFCC33,FF0000&chd=t:'.$rate.'|'.(100 - $rate) .'&chtt=%E6%9D%B1%E4%BA%AC%E9%9B%BB%E5%8A%9B%E4%BD%BF%E7%94%A8%E7%8A%B6%E6%B3%81' .$hour.'%E6%99%82%E5%8F%B0&chts=676767,14.5'; print qq(Location: $url\n\n);
<img src="//yapi.ta2o.net/setsuden/stdn.cgi">
<html> <head> <script> function stdn_graph_insert(json){ var usage = json["ElectricPowerUsage"]["Usage"]["$"];; var capacity = json["ElectricPowerUsage"]["Capacity"]["$"]; var hour = json["ElectricPowerUsage"]["Hour"]; var rate = Math.ceil(usage / capacity * 100); document.getElementById('stdn').src = 'https://chart.apis.google.com/chart?chxt=x&chbh=a,4,5&chs=225x69' + '&cht=bhs&chco=FFCC33,FF0000&chd=t:' + rate + '|' + (100 - rate) + '&chtt=%E6%9D%B1%E4%BA%AC%E9%9B%BB%E5%8A%9B%E4%BD%BF%E7%94%A8%E7%8A%B6%E6%B3%81' + hour + '%E6%99%82%E5%8F%B0&chts=676767,14.5'; }; function djson() { var script = document.createElement('script'); var appid = '(YOUR APPID)'; var apiurl = 'http://setsuden.yahooapis.jp/v1/Setsuden/latestPowerUsage' + '?appid=' + appid + '&output=json&callback=stdn_graph_insert'; script.id = apiurl; script.charset = 'UTF-8'; script.src = script.id; document.lastChild.appendChild(script); }; </script> </head> <body onload="javascript:djson();"> <img src="" id="stdn" name="stdn"> </body> </html>
\ls|perl -lne '$sz=-s$_;print qq(<a href="$_">$_</a>($sz)<br>)'>index.html
#!/usr/bin/perl use strict; use warnings; my $v = ""; vec($v, 0, 1) = 1; # 0ビット目を1に printbits($v); vec($v, 9, 1) = 1; # 9ビット目を1に printbits($v); vec($v, 0, 1) = 0; # 0ビット目を0に printbits($v); print vec($v, 0, 1), "\n"; # 0ビット目を見る print vec($v, 9, 1), "\n"; # 9ビット目を見る sub printbits { my ($v) = @_; my $bits = unpack("b*", $v); my @bits = split(//, $bits); print "$bits "; print join(",", @bits), "\n"; }
10000000 1,0,0,0,0,0,0,0 1000000001000000 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 0000000001000000 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0 0 1