2010-01-01から1年間の記事一覧
http://d.hatena.ne.jp/chabom/20100818/1282092637 のコードはBasic 認証でもう使えないので、OAuth 対応した。利用するには、Consumer key, Consumer secret, Access Token, Access Token Secret は Twitter Developer Platform — Twitter Developers でア…
このコードは、TwitterのBASIC認証廃止に伴い利用できません。 $URL = "http://twitter.com/statuses/followers.xml?cursor=" $USER = "username" $PASSWD = "password" $OLD_FILE = "followers_old.txt" $nc = New-Object System.Net.NetworkCredential($US…
((Get-ChildItem (Get-ChildItem env:TEMP).Value | where {$_ -is [System.IO.FileInfo]} | sort LastWriteTime -Desc)[0]).FullNameファイルのみの抽出のところで where { $_.Attributes -eq 'Archive' } とすると、Archive だけのファイルだけになって [A…
By default, an object inherits permissions from its parent object, either at the time of creation or when it is copied or moved to its parent folder. The only exception to this rule occurs when you move an object to a different folder on t…
$PSCP = "C:\tools\putty\pscp.exe -p" # -p は timestamp を保持 $7Z = "C:\Program Files\7-Zip\7z.exe" @( @{ "host" = "192.168.0.1" "user" = "user" "pass" = "password" "src" = "/var/log/httpd/*.1" "dst" = "d:\backup\web1" }, @{ "host" = "192.…
$7z = 'C:\Program Files\7-Zip\7z.exe' $dir = 'f:\Exchange\LogFiles' Get-ChildItem $dir -Recurse | foreach { if ($_.Name -match '.+log$') { $orig = $_.FullName $zip = $_.FullName + '.zip' & $7z a -tzip $zip $orig rm $orig } }
NTEmacs で Shift_JIS のファイルを開くと文字化けになって、C-x RET r で Shift_JIS として開くも、一部 \372 とか \373 などと化けて表示される。で、他のエディタで開くと「はしご高」とかが化けてるのがわかって、要は IBM 拡張文字は Shift_JIS の範囲…
どうでもいいけど、このはてなダイアリーのテーマ (Monotone-flower) の CSS でフォント名が間違っている。いや、どうでもよくないか。 body { font-family:arial, sans-sarif; } h1 { font-family:arial, sans-sarif; } 正しくは sans-serif ね。
Encode::decode #!/usr/bin/perl # utf8 で保存しとくこと use strict; use warnings; use Data::Dumper; use Encode; my $input = "あ"; print Dumper($input); #=> $VAR1 = '縺・; バイト列 print Dumper( decode("utf8", $input) ); #=> $VAR1 = "\x{3042…
base64エンコード $str = "たちあがれ日本" # 文字列からバイト列 (utf-8) に変換する $byte = [System.Text.Encoding]::UTF8.GetBytes( $str ) # 文字列からバイト列 (iso-2022-jp) に変換する # $enc = [System.Text.Encoding]::GetEncoding("iso-2022-jp"…
#!/usr/bin/perl use strict; use warnings; use Mail::POP3Client; use Mail::MboxParser::Mail; my $user = "username"; my $pass = "password"; my $host = "example.jp"; my $ssl = 1; my $pop = new Mail::POP3Client( USER => $user, PASSWORD => $pas…
#!/usr/bin/perl use strict; use warnings; my @host = ( { 'hostname' => "host1", 'size' => 613475, 'used' => 16551 }, { 'hostname' => "host2", 'size' => 613501, 'used' => 15214 }, ); printf "%-5s %8s %8s %8s %4s\n", "Host", "Size", "Used", …
#!/usr/bin/perl use strict; use warnings; use Mail::MboxParser; use DateTime::Format::Mail; my $mbox = $ARGV[0]; die unless ($mbox); my $mb = Mail::MboxParser->new($mbox, decode => 'ALL', parseropts => { enable_cache => 1, cache_file_name …
DateTime::Format::Mail #!/usr/bin/perl use strict; use warnings; use DateTime::Format::Mail; my $date = "Thu, 17 Jun 2010 00:00:35 +0900"; my $dt = DateTime::Format::Mail->parse_datetime($date); print $dt->ymd(""), "\n"; $ ./rfc2822date.pl…
#!/bin/sh # 毎日の統計をsubversionリポジトリにコミットする date=`date '+%Y%m%d'` cd /home/turbo/log /home/turbo/stat.pl > stat.txt svn ci -m "update $date" svn up で、cronに仕込むと。 $ crontab -e 0 2 * * * /home/turbo/stat.sh
open my $fh, '<', $file or die $!; while (<$fh>) { # chomp; s/\r?\n$//; # 0D0Aのときがあったので push @list, $_ unless /^$/; } close $fh; レコード区切り文字 $/ を設定して chomp してもいいのだが、Windows だと 0D0A、Linux だと 0A となり、フ…