パソコン・インターネット

2016年9月 5日 (月)

Texで発音記号:tipa.sty

発音記号が簡単に入力できるパッケージ。

[æ] は [\textipa{\ae}] , [ə] は [\textipa{@}] のように直感的に入力できる。

入力方法はマニュアル
http://mirrors.ctan.org/fonts/tipa/tipa/doc/tipaman.pdf
の30ページ以降に列挙されている。

最新のW32TeXには既に入っているようなので早速使ってみた。

ソース

\documentclass[fleqn,a4paper,12pt]{jsarticle}
\usepackage{tipa,tipx}

\begin{document}
\begin{tabular}{ll}
apple &[\textipa{\'\ae p@l}]\\
significance &[\textipa{s@gn\'If@k@ns}]\\
tensions &[\textipa{t\'En\textteshlig @nz}]\\
airport &[\textipa{\'Erp\`O:rt}]\\
conference &[\textipa{k\'Anf@:r@ns}]\\
city &[\textipa{s\'Iti}]\\
global &[\textipa{gl\'oUb@l}]\\
leaders &[\textipa{l\'I:d@:rz}]\\
convening &[\textipa{k@nv\'I:n@N}]\\
summit &[\textipa{s\'2m@t}]\\
\end{tabular}
\end{document}

PDF出力

Textipa

思わず笑ってしまうほど便利。

 

 

2015年11月25日 (水)

Tex:色をHTMLのColor Nameで表現するstyファイル

Texのgraphicパッケージには68色が定義されているが、いまいち欲しい色が見つからないという人が多いのではないだろうか。

かといって、いちいちrgbなどで指定するのは大変だ。

そこで、htmlのカラーネームが直接使えたら便利ではないかと思い、147色のhtmlカラーネームの16進コードをperlでtexのrgbに自動変換し、styファイルを作ってみた。

「htmlcolor.sty」をダウンロード

「coltest.tex」をダウンロード

「coltest.pdf」をダウンロード

これにより、たとえば

ほげ\chocolate{ほげ}ほげ

と書くだけで、色指定されたところがhtmlのchocolateカラーで

Htmlcolor0

と表示される。

使い方は普通に、

\usepackage[dvipdfmx, usenames]{color}
\usepackage{htmlcolor}

または

\usepackage[dvipdfm, usenames]{color}
\usepackage{htmlcolor}

とすればよい。

ただしカラーネーム"tan"は数学関数のtanと重複するので、"ctan"という色名で使用してほしい。

tex による出力サンプルは以下の通り。

Htmlcolor1

Htmlcolor2

Htmlcolor3

Htmlcolor4

Htmlcolor5

htmlcolor.sty と coltest.tex は以下のcgiスクリプトで書き出した。

#!/usr/bin/perl

$|=1;
use POSIX qw(ceil);

print "Content-type:text/plain;charset=UTF-8\n\n";

#htmlcolor.styの書き出し

print qq|%This file enables you to set colors in latex by 147 html color names.
%Ex. \\lawngreen{your text} presents 'your text' in lawngreen.
%But please notice that the only color 'tan' must be written as 'ctan': \\ctan{your text}.
%
%You can also use the 68 colors in Graphic package as before: {\\color{RubineRed} your text}.
%
%Please use this file with the Color package:
%\\usepackage[dvipdfmx, usenames]{color}
%\\usepackage{htmlcolor}
%or
%\\usepackage[dvipdfm, usenames]{color}
%\\usepackage{htmlcolor}
%
%For sample tex document and images, please visit http://icepotato.cocolog-nifty.com/blog/

|;

my @cname;
open CT,"colors.txt";
foreach(<CT>){
    s/\r|\n//g;
    if(/^(\w+?)\t.(\w\w)(\w\w)(\w\w)$/){
        my $colname = $1;
        my $r = sprintf("%.2f", (hex($2) / 255));
        my $g = sprintf("%.2f", (hex($3) / 255));
        my $b = sprintf("%.2f", (hex($4) / 255));
        $colname =~ s/^tan$/ctan/;
        print qq|\\definecolor{$colname}{rgb}{$r,$g,$b}\n|;
        push @cname, $colname;
    }
}
close CT;

print "\n";

foreach(@cname){
    print "\\def\\$_#1{{\\color{$_}#1}}\n";
}

print "\n";

#coltest.texの書き出し

print qq|\\documentclass[a4paper,10pt]{jarticle}
\\usepackage[dvipdfmx, usenames]{color}
\\usepackage{htmlcolor}
\\usepackage{colortbl}
\\pagestyle{empty}
\\setlength{\\topmargin}{-15mm}
\\setlength{\\headheight}{0mm}
\\setlength{\\headsep}{0mm}
\\setlength{\\oddsidemargin}{-15mm}
\\setlength{\\evensidemargin}{-15mm}
\\setlength{\\textwidth}{\\paperwidth}
\\addtolength{\\textwidth}{-30mm}
\\setlength{\\arrayrulewidth}{0.7mm}
\\setlength{\\fboxrule}{0.7mm}

\\begin{document}

\\bf

\\begin{tabular}{\|l\|c\|l\|c\|l\|c\|}
\\hline
|;

my $max = 3 * ceil(@cname / 3);

for($i = 0;$i < $max;++$i){
    if($cname[$i]){print "$cname[$i]&\\cellcolor{$cname[$i]}{  }";}
    else {print "-&-";}
    if(($i + 1) % 3 == 0){
        print "\\\\\n\\hline\n";
        if(($i + 1) % 60 == 0){ #20行ごとに改ページ
            print "\\end{tabular}\n\n\\newpage\n\n\\begin{tabular}{|l|c|l|c|l|c|}\n\\hline\n";
        }
    } else {print "&";}
}

print "\\end{tabular}\n\n\\newpage\n\n";

print "\\fcolorbox{black}{white}{\n\\begin{minipage}{.75\\textwidth}\n";

foreach(@cname){
    print qq"\\$_\{$_\}\\hspace{2ex}";
}

print qq"\n\\end{minipage}\n}\n\n";

print "\\fcolorbox{black}{black}{\n\\begin{minipage}{.75\\textwidth}\n";

foreach(@cname){
    print qq"\\$_\{$_\}\\hspace{2ex}";
}

print qq"\n\\end{minipage}\n}\n\n";

print "\\end{document}\n\n";

exit;

 

 

2015年10月28日 (水)

PerlでShiftjisのファイルを文字化けさせずに操作する

ShiftjisでPerlスクリプトを書きShiftjisのファイルを読み込むとよく文字化けする。

これは、いわゆるダメ文字(2バイト目がPerlの制御文字と同じコード)のせいである。

Perlスクリプトと読み込むファイルをともにutf8にすれば万事解決するのであるが、なかなかそうもいかない人が多いらしい。

理由は簡単で、Windowsで作成した文書のほとんどがShiftjisだからだ。それらをすべてutf8に変更するのは非常に骨が折れる。

Shiftjisの世界では文字化けを回避する方法はないとされるが、とりあえずPerlスクリプトだけでもutf8にすることで応急処置ができそうなので試してみた。

まず、問題の再現。

ダメ文字を満載した以下のHTMLファイルを用意。

sjisperl.html(Shiftjisで書かれている)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
</head>
<body style="font-family:monospace;font-size:12px">
<p>平成二七年度氷芋掘り大会</p>
<p>参加費 \3500</p>
<p>ァА①院魁機掘后察宗拭繊叩邸如鼻法諭蓮僉咫奸廖戞曄檗漾瓠磧紂隋蕁襦蹇錙顱鵝纊犾</p>
<p>ーゼЪⅧ閏骸擬啓梗纂充深措端甜納票房夕麓兌喙媼彈拏杣歇濕畆禺綣膽藜觴躰鐚饉鷦倞劯</p>
<p>―ソЫⅨ噂浬欺圭構蚕十申曾箪貼能表暴予禄兔喀媾彌拿杤歃濬畚秉綵臀藹觸軆鐔饅鷭偆砡</p>
<p>‐ゾЬⅩ云馨犠珪江讃従疹曽綻転脳評望余肋兢咯嫋彎拆枉歉濔畩秕緇臂蘊訃躱鐓饐鷯偰硎</p>
<p>/タЭ運蛙疑型洪賛戎真楚耽顛膿豹某与録竸喊嫂弯擔杰歐濘畤秧綽膺蘓訖躾鐃饋鷽偂硤</p>
<p>\ダЮ㍉雲垣祇契浩酸柔神狙胆点農廟棒誉論兩喟媽彑拈枩歙濱畧秬綫臉蘋訐軅鐇饑鸚傔硺</p>
<p>AチЯ㌔荏柿義形港餐汁秦疏蛋伝覗描冒輿倭兪啻嫣彖拜杼歔濮畫秡總臍藾訌軈鐐饒鸛僴礰</p>
<p>+ボк閲顎宮鶏砿施旬須捜畜怒倍府本養几嘴學悳掉桀毬炮痣窖縵艝蛔諚轆閔驅黠垬葈</p>
<p>-ポл榎掛弓芸鋼旨楯酢掃竹倒培怖翻慾處嘶斈忿掟桍毫烟痞窩縹艚蛞諫轎閖驂黥埈蒴</p>
<p>±マм厭笠急迎閤枝殉図挿筑党媒扶凡抑凩嘲孺怡掵栲毳烋痾竈繃艟蛩諳轗閘驀黨埇蕓</p>
<p>×ミн㍻円樫救鯨降止淳厨掻蓄冬梅敷盆欲凭嘸宀恠捫桎毯烝痿窰縷艤蛬諧轜閙驃黯﨏蕙</p>
<p>参加申込は icepotato@ice.po.ta.to まで。(メアドの@は半角にして)</p>
</body>
</html>

これをShiftjisで書かれた次のPerlスクリプトで、主として半角記号を置き換えるという、過酷な置換操作を行ってみる。

sjisPerlDirect.cgi(Shiftjisで書かれている)

#! /usr/bin/perl
use Encode;

print "Content-type: text/html;charset=shift_jis\n\n";

open IN, "sjisperl.html";

foreach(<IN>){
    s/二七/二八/g;
    s/\@/@/g;
    s/\[/[/g;
    s/\\/¥/g;
    s/\]/]/g;
    s/\^/^/g;
    s/\_/\-/g;
    s/\`/`/g;
    s/\{/{/g;
    s/\|/|/g;
    s/\}/}/g;
    s/\~/~/g;
    print "$_\n";
}

close IN;

exit;

__END__

と、もちろんこうなる。

Sjisperl1_2

問題は再現できた。というか酷すぎる。特に、スクリプト内に s/表/裏/; のようにダメ文字を記述することすらエラーの原因になる。

そこで、Perlスクリプトだけでもutf8で保存し、以下の黄色い字の部分を追加する。さらにShiftjisではできないはずのダメ文字の置換(赤い字)も追加。

sjisPerlOnUtf8.cgi(utf8 no signatureで書かれている)

#! /usr/bin/perl
use utf8;
use Encode;


print "Content-type: text/html;charset=shift_jis\n\n";

open IN, "sjisperl.html";

foreach(<IN>){
    $_ = decode('CP932', $_);
    s/\r|\n//g;
    s/二七/二八/g;
    s/表/裏/g;
    s/申/申(さる)/g;
    s/Ⅸ/Ⅸ(9)/g;
    s/㌔/㌔(きろ)/g;
    s/\@/@/g;
    s/\[/[/g;
    s/\\/¥/g;
    s/\]/]/g;
    s/\^/^/g;
    s/\_/\-/g;
    s/\`/`/g;
    s/\{/{/g;
    s/\|/|/g;
    s/\}/}/g;
    s/\~/~/g;
    $_ = encode('CP932', $_);
    print "$_\n";
}

close IN;

exit;

__END__

すると次のように全く文字化けは起きず、置換操作(青丸の部分)もすべてうまくいっている。

Sjisperl2_3

やっていることは以下の通り。

  1. Shiftjisのファイルを読み込む際にCP932として扱ってPerlの内部文字列にデコード
  2. 好きなように料理
  3. 書き出すときにCP932としてエンコード。

これでShiftjisの膨大なファイル資源を当面は再利用できそうだ。

 

 

2014年11月13日 (木)

最新のDebianで標準ネットワークアダプタがeth0でない件

大学で小耳に挟んだのだが、最新のDebian系のネットワーク再起動で、

ifdown eth0 && ifup eth0

とやって、失敗している人が多いらしい。

実際、

ifdown: interface eth0 not configured
Ignoring unknown interface eth0=eth0.

と怒られる。

# cat /etc/network/interfaces

で中身を見てみると、デフォルトで

auto lo
iface lo inet loopback

となっている。

一応ここに書いてある。

つまりネットワークの再起動は

ifdown lo && ifup lo

とやればいい。

iptablesを再設定したときとか必要。

が、誰も教えてくれないようなので(氷芋も自分で気付いた)、念のため記しておいた。

 

 

2014年10月15日 (水)

Perl: 順序を変えずに配列の重複を取り除く

自作のブラウザに以前と同じブックマークを追加してしまった場合など、順番は保持しつつあとから加えたものだけを削除したいことがある・・・かもしれない。

一番原始的なのは、元の配列@aの中身を順番を明示しつつハッシュに格納する方法。

noSortCut.cgi

#! /usr/bin/perl

$|=1;

my @a = ('いちご','みかん','りんご','ぶどう','ざくろ','みかん','いちご','ざくろ','みかん','いちご');
my @b;

print "Content-type:text/plain\n\n";

print "\@a: ";
foreach(@a){print "$_ ";}
print "\n";
print "\#↑ はじめの配列\n";
print "\n";

my %c;

my $i = 0;
foreach(@a){
    print "$_\($i\)";
    if($c{$_} eq ''){ # if(!$c{$_}) だと0が入っていても $c{'a'}=0 がfalse判定されてしまうからダメ
        $c{$_} = $i;
        ++$i;
    }
}

print "\n";
print "\#↑ \$iが5以上のときは既に\%cが埋まっているので数字は格納されない\n";
print "\n";

foreach(keys %c){
    print "\$c\{\'$_\'\}=$c{$_} ";
    $b[$c{$_}] = $_;
}

print "\n";
print "\#↑ \%cには各のキーに対し,4以下の番号のみが格納されているが順番が崩れている\n";
print "\n";

print "\@b: ";
foreach(@b){print "$_ ";}
print "\n";
print "\#↑ 出来上がり";
print "\n\n";

exit;

出力

@a: いちご みかん りんご ぶどう ざくろ みかん いちご ざくろ みかん いちご 
#↑ はじめの配列

いちご(0)みかん(1)りんご(2)ぶどう(3)ざくろ(4)みかん(5)いちご(5)ざくろ(5)みかん(5)いちご(5)
#↑ $iが5以上のときは既に%cが埋まっているので数字は格納されない

$c{'りんご'}=2 $c{'みかん'}=1 $c{'いちご'}=0 $c{'ざくろ'}=4 $c{'ぶどう'}=3 
#↑ %cには各のキーに対し,4以下の番号のみが格納されているが順番が崩れている

@b: いちご みかん りんご ぶどう ざくろ 
#↑ 出来上がり

上のように、ハッシュは順番を保持しないことがわかる。

次にスカラー変数で処理してみる。各要素を一つの文字列にしてしまえば順番は保持されるはずだ。

noSortCut2.cgi

#! /usr/bin/perl

$|=1;

my @a = ('いちご','みかん','りんご','ぶどう','ざくろ','みかん','いちご','ばなな','ざくろ','みかん','いちご');
my @b;

print "Content-type:text/plain\n\n";

print "\@a: ";
foreach(@a){print "$_ ";}
print "\n\#↑ はじめの配列\n\n";

my $s = "\@";
foreach(@a){
    if($s !~ /\@$_\@/){$s .= "$_\@";}
}

print "\$s: $s\n\n";

$s =~ s/^\@|\@$//g;

@b = split("\@", $s);

print "\@b: ";
foreach(@b){print "$_ ";}
print "\n\#↑ 出来上がり\n\n";

exit;

出力

@a: いちご みかん りんご ぶどう ざくろ みかん いちご ばなな ざくろ みかん いちご 
#↑ はじめの配列

$s: @いちご@みかん@りんご@ぶどう@ざくろ@ばなな@

@b: いちご みかん りんご ぶどう ざくろ ばなな 
#↑ 出来上がり

しかしデータに区切り文字と同じものが含まれていると使えない。上の例ではメールアドレスなど。やはり配列のままがいいようだ。最初の例を簡単にしてみる。

noSortCut3.cgi

#! /usr/bin/perl

$|=1;

my @a = ('いちご','みかん','りんご','ぶどう','ざくろ','みかん','いちご','ばなな','ざくろ','みかん','いちご');
my @b;

print "Content-type:text/plain\n\n";

print "\@a: ";
foreach(@a){print "$_ ";}
print "\n\#↑ はじめの配列\n\n";

my %c;
foreach(@a){
    if(!$c{$_}){ $c{$_} = 1; push @b, $_;}
}

print "\@b: ";
foreach(@b){print "$_ ";}
print "\n\#↑ 出来上がり\n\n";

exit;

出力

@a: いちご みかん りんご ぶどう ざくろ みかん いちご ばなな ざくろ みかん いちご 
#↑ はじめの配列

@b: いちご みかん りんご ぶどう ざくろ ばなな 
#↑ 出来上がり

なんとこれをもっと簡単に記述できることがわかった。

noSortCut4.cgi

#! /usr/bin/perl

$|=1;

my @a = ('いちご','みかん','りんご','ぶどう','ざくろ','みかん','いちご','ばなな','ざくろ','みかん','いちご');
my @b;

print "Content-type:text/plain\n\n";

print "\@a: ";
foreach(@a){print "$_ ";}
print "\n\#↑ はじめの配列\n\n";

my %c;
my @b = grep {!$c{$_}++} @a;

print "\@b: ";
foreach(@b){print "$_ ";}
print "\n\#↑ 出来上がり\n\n";

exit;

出力はnoSortCut3.cgiと全く同じ。perlは奥が深いと思った。

 

 

2014年10月 7日 (火)

Firefoxを軽くて安全に設定

最近UIが単純化して何かと不評のFireforであるが、設定によって起動を軽くできることがわかった。

閲覧ページのキャッシュや履歴、オフライン用データが溜まっていくと起動が遅くなる。
これを解除すると劇的に起動が速くなった。

またトラッキングクッキーが鬱陶しい。
特定のWebサイトを見た直後に、そのサイトに関する広告がドバッと出てくることも。
そこでFirefox終了と同時にCookieを削除。

Cookieを削除してしまうとパスワードが消え、ブログなどにログインし辛くなると思いきや、そんなことはない。

確かに一発アクセスはできなくなってしまうが、Firefoxがパスワードを覚えていてくれる。ログイン画面でパスワードが自動入力されるのだ。ボタン一つでココログにもログインできる。

トドメに、「トラッキングの拒否をサイトに通知する」をチェック。
まだ対応している企業は少ないようだが、気持ち悪いトラッキングにはみんなで意思表示しよう!

以上を設定すると以下のようになる。

ツール>オプション>プライバシー

Ffsetting1

上の赤丸をクリックし、Firefox終了時に消すデータを選択。

Ffsetting2

「保存されているパスワード」と「サイトの設定」は残す。

最後にmozillaの以下のページ
https://www.mozilla.org/ja/firefox/dnt/
を読み、
「私たちは自身の利益よりも理念を追求しており、インターネットは商品ではなく大切な公共の資産であると考えています。」
に感動して設定完了。

やっぱりFirefoxはやめられない。

 

 

2014年9月29日 (月)

Javascriptで簡単な塗り絵をしてみた

ピクセル単位で色を取得するにはプラグインが必要なようだ。
仕方なく幼稚に遊んでみた。

Palet

上部の四角いカラーパレットをクリックすると,色を取得する。
白い丸をクリックするとそれが取得した色になる。
マウスを動かすと、マウスの通った白丸が取得した色になる。
塗り絵をやめたい白丸をクリックすると塗り絵が止まる。

<html>
<head>
<script type="text/javascript">
var color;
var canPaint=!canPaint;
</script>
<style>
<!--
span {cursor:pointer;}
//-->
</style>
<title>色で遊ぶ</title>
</head>
<body style="background:black">
<span style="color:red" onClick="color=this.style.color;canPaint=false;">■</span>
<span style="color:orange" onClick="color=this.style.color;canPaint=false;">■</span>
<span style="color:yellow" onClick="color=this.style.color;canPaint=false;">■</span>
<span style="color:green" onClick="color=this.style.color;canPaint=false;">■</span>
<span style="color:blue" onClick="color=this.style.color;canPaint=false;">■</span>
<span style="color:pink" onClick="color=this.style.color;canPaint=false;">■</span><br><br>

<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span>
<span style="color:white" onMouseOver="if(canPaint)this.style.color=color;" onClick="this.style.color=color;canPaint=!canPaint;">●</span><br>

</body>
</html>

WindowsなのでShiftjisで保存。
FirefoxでもIEでも動いた。

 

2014年4月15日 (火)

jcode.plでdefined(%hash) is deprecated at ../perllib/jcode.pl line 684.のエラー

perlがバージョンアップして5.14になったら

defined(%hash) is deprecated at ../perllib/jcode.pl line 684.
        (Maybe you should just omit the defined()?)
defined(%hash) is deprecated at ../perllib/jcode.pl line 693.
        (Maybe you should just omit the defined()?)

なるエラーが出るようになった。

defined関数はスカラーに適用されるものなので、ハッシュだとだめらしい。ハッシュが作られているかどうか調べればいいだけなので、682行目からの

sub z2h_euc {
    local(*s, $n) = @_;
    &init_z2h_euc unless defined %z2h_euc_inited;
    $s =~ s/($re_euc_c|$re_euc_kana)/
    $z2h_euc{$1} ? ($n++, $z2h_euc{$1}) : $1
    /geo;
    $n;
}

sub z2h_sjis {
    local(*s, $n) = @_;
    &init_z2h_sjis unless defined %z2h_sjis_inited;
    $s =~ s/($re_sjis_c)/$z2h_sjis{$1} ? ($n++, $z2h_sjis{$1}) : $1/geo;
    $n;
}

を次のように修正したら解決。

sub z2h_euc {
    local(*s, $n) = @_;
    &init_z2h_euc if !%z2h_euc;
    $s =~ s/($re_euc_c|$re_euc_kana)/$z2h_euc{$1} ? ($n++, $z2h_euc{$1}) : $1/geo;
    $n;
}

sub z2h_sjis {
    local(*s, $n) = @_;
    &init_z2h_sjis if !%z2h_sjis;
    $s =~ s/($re_sjis_c)/$z2h_sjis{$1} ? ($n++, $z2h_sjis{$1}) : $1/geo;
    $n;
}

 

 

2013年8月28日 (水)

Postfixで外部にメールが送信できずName service error for...のエラーが出る

検索してもなかなか出てこない。日本語のサイトは全滅っぽい。

と思ったらデンマークにあった。
http://www.sslug.dk/~chlor/postfix/

ここにある通り、
/etc/resolv.conf

/var/spool/postfix/etc/
にコピーしたら解決。

ところでこの/etc/resolv.conf、かなりくせ者で、うっかり給電目的でUSBに無線LANアダプタのようなものを差し込むと中身が消去されてしまったりする。

開いてみて空っぽだったら、たとえば
nameserver 192.168.0.1
(↑普通はプロバイダのブロードバンドルータ)
のように書き込んで修復すべし。

 

 

2013年8月26日 (月)

Linux:PostfixからメールをCGIに転送するとCan't locate cgi-lib.pl等のエラーが出る

Can't locate cgi-lib.plのエラー自体は単にcgi-lib.plが見つからねっぞ、という意味だが、cgi-lib.plが存在している場合でもエラーが出ることがある。

Web上では、cgi-lib.plのパスを変えたりするとエラーが消えたという報告が数多くあるが、それでも解決しないことがある。

それはメールをCGIに転送した場合。

この場合CGIを実行するのは別ユーザ(Postfix)となるので、cgi-lib.plのパスを / から始まるフルパスにしなければならない。

use lib '/home/icepotate/public_html';

reqwire 'cgi-lib.pl';

次に、ファイルの書き込みができない場合がある。これもパーミッションの問題。CGIの実行者が他のユーザだから、書き込み人も他のユーザ。

そこで、ファイルのパーミッションを標準の644でなく666にする。

あとは/etc/aliasesに

icepotato: "|/home/icepotate/public_html/maillog.cgi"

のように書き込み、newaliasesを実行すれば、届いたメールをperlスクリプトで処理してファイルに保存できる。

 

 

より以前の記事一覧

2019年9月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

ブックマーク

無料ブログはココログ