「head」を含む日記 RSS

はてなキーワード: headとは

2009-04-07

終端と先頭と末尾の対義語は何?

終端に対して「始端」という言葉が、一応あるようだ。ググってみたらあった。確かに聞いたことのある言葉ではあるが、終端ほどには使わない気がする。

先頭の対義語はなんだろう?頭(head)の反対が尾(tail)というわけで、末尾が妥当か?

何か違った見解があれば、教えて欲しい。

2009-03-18

公明党都議選重視?

コピーして、test.htaのような拡張子HTAで保存

HTAプログラム

 ↓

<html&gt;

<head&gt;

<style type="text/css"&gt;dt{float:left;clear:left;width:10em;}</style&gt;

<meta content="charset=Shift_JIS"/&gt;

</head&gt;

<body&gt;

<script type="text/javascript"&gt;</p&gt; <p&gt;window.onload = init;</p&gt; <p&gt;var url = [</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/h19sangiin/san_kekka/h19san_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/h19sangiin/san_kekka/h19san_hkai.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/h17shugiin/sokuhou/7kaijyo_s.htm"&gt;http://www.senkyo.metro.tokyo.jp/h17shugiin/sokuhou/7kaijyo_s.htm</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/h17togisen/sokuhou/2kaijyo_s.htm"&gt;http://www.senkyo.metro.tokyo.jp/h17togisen/sokuhou/2kaijyo_s.htm</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/h16san_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/data/h16san_hkai.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/h15shu_hkai.html"&gt;http://www.senkyo.metro.tokyo.jp/data/h15shu_hkai.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/data01_01_03.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_01_03.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/data01_02_05.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_02_05.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/data03_04.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data03_04.html</a&gt;",</p&gt; <p&gt; "<a href="http://www.senkyo.metro.tokyo.jp/data/data01_05_05.html"&gt;http://www.senkyo.metro.tokyo.jp/data/data01_05_05.html</a&gt;"</p&gt; <p&gt;];</p&gt; <p&gt;var base = "<a href="http://www.senkyo.metro.tokyo.jp/data/tokuhyo_23ku/"&gt;http://www.senkyo.metro.tokyo.jp/data/tokuhyo_23ku/</a&gt;";</p&gt; <p&gt;var file = ["chiyoda","chuou","minato","shinjyuku","bunkyo",</p&gt; <p&gt; "taitho","sumida","koutho","sinagawa","meguro",</p&gt; <p&gt; "ohta","setagaya","shibuya","nakaono","suginami",</p&gt; <p&gt; "toshima","kita","arakawa","itabashi","nerima",</p&gt; <p&gt; "adachi","katushika","edogawa"];</p&gt; <p&gt;for(var i=0; i<23; i++){</p&gt; <p&gt; url.push(base + file[i] + "\.html");</p&gt; <p&gt;}</p&gt; <p&gt;var id = [</p&gt; <p&gt; "2007 参院比", "2005 衆院比", "2005 都議会", "2004 参院比", "2003 衆院比",</p&gt; <p&gt; "2001 参院比", "2001 都議会", "2000 衆院比", "1998 参院比", "1997 都議会"</p&gt; <p&gt;];</p&gt; <p&gt;var ku = [</p&gt; <p&gt; "千代田","中央","港","新宿","文京",</p&gt; <p&gt; "台東","墨田","江東","品川","目黒",</p&gt; <p&gt; "大田","世田谷","渋谷","中野","杉並",</p&gt; <p&gt; "豊島","北","荒川","板橋","練馬",</p&gt; <p&gt; "足立","葛飾","江戸川"</p&gt; <p&gt;];</p&gt; <p&gt;var regexku = new RegExp("(" + ku.join("|") + ")区");</p&gt; <p&gt;var iframe = [];</p&gt; <p&gt;var data = {};</p&gt; <p&gt;var parse = [ function(){</p&gt; <p&gt; var d = iframe[0].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<10; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "0"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[1].contentWindow.document;</p&gt; <p&gt; var nobr = d.getElementsByTagName("nobr");</p&gt; <p&gt; for(var i=0, l=nobr.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(nobr[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=nobr[i].parentNode; j<4; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "1"] = e.firstChild.nodeValue;</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[2].contentWindow.document;</p&gt; <p&gt; var nobr = d.getElementsByTagName("nobr");</p&gt; <p&gt; for(var i=0, l=nobr.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(nobr[i].firstChild.nodeValue) &amp;&amp; nobr[i].parentNode.tagName == "SPAN"){</p&gt; <p&gt; for(var j=0, e=nobr[i]; j<6; j++){</p&gt; <p&gt; e = e.parentNode;</p&gt; <p&gt; }</p&gt; <p&gt; var e2 = e.nextSibling.nextSibling.firstChild.childNodes[2].firstChild;</p&gt; <p&gt; var k = 0;</p&gt; <p&gt; data[RegExp.$1 + "2"] = 0;</p&gt; <p&gt; while(e2){</p&gt; <p&gt; if(e2.firstChild.firstChild.nodeValue.indexOf("公明党") != -1){</p&gt; <p&gt; data[RegExp.$1 + "2"] += parseInt(e2.parentNode.nextSibling.childNodes[k+2].firstChild.nodeValue.replace(",",""), 10);</p&gt; <p&gt; }</p&gt; <p&gt; e2 = e2.nextSibling;</p&gt; <p&gt; k++;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "2"] = int2str(data[RegExp.$1 + "2"]);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[3].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<19; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "3"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[4].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; var regexku2 = /(大田|世田谷|練馬|足立|江戸川)/;</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "4"] = td[i].nextSibling.nextSibling.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; continue;</p&gt; <p&gt; }</p&gt; <p&gt; if(regexku2.test(td[i].firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "4"] = (data[RegExp.$1 + "4"] || 0) </p&gt; <p&gt; + parseInt(td[i].nextSibling.nextSibling.firstChild.nodeValue.replace(",","").replace(/\.\d+/,""));</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; for(var j=0; j<5; j++){</p&gt; <p&gt; data[ku[[10,11,19,20,22][j]]+"4"] = int2str(data[ku[[10,11,19,20,22][j]]+"4"]);</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[5].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<10; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "5"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[6].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<7; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "6"] = e.firstChild.firstChild.nodeValue.replace(/\.\d+/,"").replace("-","0");</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[7].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; for(var j=0, e=td[i]; j<9; j++){</p&gt; <p&gt; e = e.nextSibling;</p&gt; <p&gt; }</p&gt; <p&gt; data[RegExp.$1 + "7"] = e.firstChild.firstChild.nodeValue;</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(){</p&gt; <p&gt; var d = iframe[8].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if(regexku.test(td[i].firstChild.firstChild.nodeValue)){</p&gt; <p&gt; data[RegExp.$1 + "8"] = int2str(td[i].nextSibling.firstChild.firstChild.firstChild.nodeValue);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; show();</p&gt; <p&gt;}, function(n){ return function(){</p&gt; <p&gt; var d = iframe[n+9].contentWindow.document;</p&gt; <p&gt; var td = d.getElementsByTagName("td");</p&gt; <p&gt; data[ku[n]+"9"] = 0;</p&gt; <p&gt; for(var i=0, l=td.length; i<l; i++){</p&gt; <p&gt; if((((td[i].firstChild || 0).firstChild || 0).nodeValue || "").indexOf("公明") == 0){</p&gt; <p&gt; data[ku[n]+"9"] += parseInt(td[i].parentNode.lastChild.firstChild.firstChild.nodeValue.replace(",",""));</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt; data[ku[n]+"9"] = int2str(data[ku[n]+"9"]);</p&gt; <p&gt; show();</p&gt; <p&gt;}}];</p&gt; <p&gt;function init(){</p&gt; <p&gt; for(var i=0; i<23; i++){</p&gt; <p&gt; var dl = document.createElement("dl");</p&gt; <p&gt; dl.appendChild(document.createTextNode("\n【" + ku[i] + "区における公明票】\n"));</p&gt; <p&gt; for(var j=0; j<10; j++){</p&gt; <p&gt; var dt = document.createElement("dt");</p&gt; <p&gt; var dd = document.createElement("dd");</p&gt; <p&gt; dt.innerText = id[j];</p&gt; <p&gt; dl.appendChild(dt);</p&gt; <p&gt; dl.appendChild(dd);</p&gt; <p&gt; }</p&gt; <p&gt; document.body.firstChild.appendChild(dl);</p&gt; <p&gt; }</p&gt; <p&gt; for(var i=0; i<32; i++){</p&gt; <p&gt; var e = document.createElement("iframe");</p&gt; <p&gt; iframe[i] = e;</p&gt; <p&gt; e.style.display = "none";</p&gt; <p&gt; if(i<9) var f = parse[i];</p&gt; <p&gt; else var f = parse[9](i-9);</p&gt; <p&gt; e.attachEvent("onload", f);</p&gt; <p&gt; e.src = url[i];</p&gt; <p&gt; document.body.appendChild(e);</p&gt; <p&gt; }</p&gt; <p&gt;}</p&gt; <p&gt;function show(){</p&gt; <p&gt; for(var i=0; i<23; i++){</p&gt; <p&gt; var dl = document.body.firstChild.childNodes[i];</p&gt; <p&gt; for(var j=0; j<10; j++){</p&gt; <p&gt; var dt = dl.childNodes[j*2+1];</p&gt; <p&gt; dt.innerText = id[j] + " " + (data[ku[i]+j] || "");</p&gt; <p&gt; dt.nextSibling.innerText = bar(data[ku[i]+j], j);</p&gt; <p&gt; }</p&gt; <p&gt; }</p&gt; <p&gt;}</p&gt; <p&gt;function int2str(num){</p&gt; <p&gt; return new String(num).split("").reverse().join("").replace(/(\d{3})/g,"$1,").split("").reverse().join("");</p&gt; <p&gt;}</p&gt; <p&gt;function bar(str, flag){</p&gt; <p&gt; str = str || "";</p&gt; <p&gt; if(str == "" || str.length < 5) return "";</p&gt; <p&gt; var num = parseInt(str.match(/\d+/)) + 1;</p&gt; <p&gt; var arrow = (flag == 2 || flag == 6 || flag == 9) ? " ←" : "";</p&gt; <p&gt; var _bar = new Array(num).join("|") + arrow;</p&gt; <p&gt; return _bar;</p&gt; <p&gt;}</p&gt; <p&gt;</script&gt;

</body&gt;

</html&gt;

2009-02-06

Re: サーバRSSリーダーUAで弾く理由

なんでブクマトラバで誰も304 Not Modifiedについて触れていないんだ。

昔のバカなRSSアグリゲーターだとライブラリを使わずに自分HTTP取得処理を書いて304に対応していないので、毎回サーバーに負荷をかけていたというトホホな話があったけど。

まともなアグリゲーターならHEADリクエストで304に対応してるから負荷なんてかかんないよ。

そりゃ仮に1秒間に数百回もアクセスすりゃDoSになるけど、30秒に1回ぐらいだったら屁でもないよ。

ちなみにまなめの使ってるcococいそろぐ(仮): cococ v1.03のとおり304に対応してる。

2008-12-25

うう、おもしろすぎるぜ日経メディカルオンライン

コンサートでの激しい首振り、何度を超えると危険

http://medical.nikkeibp.co.jp/leaf/mem/pub/hotnews/bmj/200812/508975.html

元ネタは「Head and neck injury risks in heavy metal: head bangers stuck between rock and a hard bass

http://www.bmj.com/cgi/content/full/337/dec17_2/a2825

直接観察ってやっぱりステージ際から客席をじーっと見たりしたんだろうか。

いや、角度を測ってるから撮影かもしれないな。

熱狂するステージと観客、あくまで冷静な計測班。

「休暇中に健康を損なわぬためには、音楽にも大人の選択を。」

2008-12-08

Fucking Hostileの和訳 メモ

1, 2, 3, 4!

Almost every day

ほとんど毎日

I see the same face

同じ顔を

On broken picture tube

壊れたテレビで見るぜ

It fits the attitude

態度にピッタリだな

If you could see yourself

自分自身を見直してみろ

You put you on a shelf

自分のことを棚に上げながら

Your verbal masturbate

口先だけのオナニー

Promise to nauseate

ゲロみたいな約束なんだ、お前のやってることは

Today I'll play the part of non-parent

今日保護者の役はやれないな

Not make a hundred rules

100個もルールを作る気にもならない

For you to know about yourself

お前が自分自身についてわかるように

Not lie and make you believe

嘘なしで信じさせてやる

What's evil is making love

セックス

and making friends

友達も

and meeting God you're own way

神様に祈るのも悪いことさ

The right way

こいつが正しいんだ


(Chorus)

To see

見てみろ

To bleed

血を流してみろ

Cannot be taught

教えられることじゃねえ

In turn

次々に

You're making us

お前が俺を作ってるんだな

Ohhhh Fucking hostile

なんてお前は敵対的なんだ


We stand alone

俺たちは一人ぼっちってことさ


The truth in right and wrong

真実は間違ってるけど正しい

The boundaries of the law

法律すれすれのところで

You seem to miss the point

お前はしくじっちゃったみたいだな

Arresting for a joint?

マリファナに気づかれちまったのか?

You seem to wonder why

どうしてって聞きたいみたいだな

Hundreds of people die

何百もの人が死んでいって

You're writing tickets man

お前はその切符を書いてる

My mom got jumped -- they ran!

母親が飛ぶとあいつらは走るから

Now I'll play a public servant

警察と今遊んでるのさ


To serve and protect

奉仕して、守って

By the law and the state

法と国家によって

I'd bust the punks

パンク野郎をぶったおしてる

That rape steal and murder

盗み、強姦殺人

And leave you be

お前をそんなふうにして

If you crossed me

俺ともう一回会えるなら

I'd shake your hand like a man

人間にみたいに握手をしよう

Not a god

神じゃなくて


(Chorus)


Come meet your maker, boy

お前の親父に会わせろよ

Some things you can't enjoy

享受できないことだってあるさ

Because of heaven/hell

天国と地獄のせいさ

A fucking wives' tale

糞みたいな物語

They put it in your head

あいつらがお前の頭の中に入れて

Then put you in your bed

ベッドのそばで子守唄にする

He's watching say your prayers

お前のために祈ってる奴を見ろってあいつは言うなあ

Cause God is everywhere

神様はどこにでもいるからだってさ

Now I'll play a man learning priesthood

じゃあ俺は聖職者に付き従ってる男の役でもやってみよう

Who's about to take the ultimate test in life

誰が人生最大の問いなんてものを投げかけてきても

I'd question things because I am human

俺は人間だから答えてやろう

And call NO ONE my father who's no closer than a stranger

知らない奴より神様に近い奴なんていなんだ

I won't listen

聞きたくもないんだ


To see

見てみろ

To bleed

血を流してみろ

Cannot be taught

教えられることじゃねえ

In turn

次々に

You're making us

お前が俺をつくってるんだな

Fucking, fucking, fucking

糞みたいに

FUCKING HOSTILE!

お前は敵対的なんだ


安らかに眠れ

ダイムバッグダレル

2008-10-29

こうですかこうですか><

<html><head><style type="text/css">
a.amazon + a {
  display: none
}
a.amazon:visited + a {
  display: inline
}
a.example + a {
  display: none
}
a.example:visited + a {
  display: inline
}
</style></head><body>
<a href="http://www.amazon.co.jp/" class="amazon"></a><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4407316438"><img src="http://ecx.images-amazon.com/images/I/41eRtLoQJtL._SL160_.jpg" /></a>
<a href="http://www.example.com./" class="example"></a><a href="http://d.hatena.ne.jp/asin/4407316438"><img src="http://ecx.images-amazon.com/images/I/41eRtLoQJtL._SL160_.jpg" /></a>
</body></html>

IEはどうしたら良いですか!

教えてはまちちゃん!!

2008-10-20

http://anond.hatelabo.jp/20081020041605

はい! こんにちは! Hamachiya2ですよ!
いま、エガミくんの書き込みみながら、ざくっとソースみてみたよー。

XSSの対策ってね、ぼくもよくわかってないけど、
「出力時にエスケープする」っていうのが定石らしいよ。
でもエガミくんのやろうとしたのは「入力時のエスケープ」だね。

だから $_GET のところ(入力)で何かをするのではなくて…、
レスポンスのコーナーのところ。html変数埋め込んで echo してるとこ。
そこの全ての変数エスケープしちゃう方がいい感じかな。

その際に注意すべきは、html属性内(alt=ナントカとか、src=ナントカとか)に変数を埋め込んでいる場合は、ちゃんとクオートの類もエスケープする感じ?

echo '<img src="' . $hensuu . '" alt="ぺろぺろ" />';

とかなら、$hensuu はダブルクオートもエスケープだよ。
あ、htmlspecialchars ってダブルクオートはデフォルトで「&quot;」に変換されるんだっけ?
ちょっと試してみてね。

もし↓こんな風に、html属性のクオートにシングルクオートを使ってる場合だと…

echo "<img src='" . $hensuu . '" alt='ぺろぺろ' />";

これは

echo "<img src='" . htmlspecialchars($hensuu, ENT_QUOTES) . '" alt='ぺろぺろ' />";

こうする感じかな?

あと、サンプルコードには含まれていなかったけど、
本番の方だと、htmlheadの中でも変数つかってるよね。
たとえば、xxxで検索すると、titleタグメタタグにもxxxが入ってくる。
そのあたりも、とりあえず「表示しようとしてる箇所」の「表示する一歩手前」で全てエスケープしてやればいいと思うよ。

もしかしたら言ってること間違ってるかもしれないけど、
その時はきっと誰かが突っ込んでくれるはずー。

追記
あと、寂しいことってなに?

2008-09-03

http://anond.hatelabo.jp/20080902220310

寝る前にいくつか返信。

http://anond.hatelabo.jp/20080902220835]

たぶんそうだと思う。

http://anond.hatelabo.jp/20080902221735]

でもほら、ダイアリーの立ち上げ当時は似たようなもんじゃないかと。

でも、ダイアリー以外のブログ日記のことも考えると、本文中に書くということの意味もあると思う。

http://anond.hatelabo.jp/20080902224129]

同様の意見としてb:id:hatayasanとかb:id:ululunとかb:id:nakano87とかb:id:te2uとかね。元記事にチェックボックス案もmetaを使う前提でチェックが off なら head に件の meta を入れるって書いてあるのになぁ。リテラシーって大事だ。

そっちの仕様は別にいいの。自社サービスの機能を使うのにmetaを本文に書かせるのがダメ

b:id:masayc 技術力を期待してはてな使ってる人ってどれくらいいるんだろうね?俺は、日本”語”でweb2.0ごっこしたいだけで、もし英語が達者ならdiggdelicious使うけどな。

日本語Web2.0ごっこなら、私が唯一中期間使った例で申し訳ないけどドリコムブログの方が優れてた。使ってたの数年前だけど(今はWP)。例えばデザイン編集画面で、ブログの2or3カラムレイアウトに表示する要素をDnDで並べ替えたりとか。DHTMLすげーって感じ。

はてなWeb2.0の特徴の一つと言われてるマッシュアップとかがろくにできない。はてなデータを外で使うための機能は多いけど、外のサービスとかをはてなに持ち込めない。Blogパーツ、裏技使わないと自由に貼れないでしょ?

2.0っぽさではてなよりも劣ってるサービスってあんま無いんじゃなかろうかと。むしろ往年のWeb日記仕様を引きずってるし、メジャーバージョンは1。Web1.9。

b:id:xevra 技術的には指摘の通りだろう。だが経営的にはこれが正解。なぜなら一覧非表示機能を希望し、文句言ってくる人は0.01%程度。この程度のものにリソースは割けない。完璧を求めるのは趣味の領域。jkonは正しい。

今は一覧非表示機能に限った話してないんだけど。上の方のアレもそうだけど、非表示絡みでコメしてる人は何故かピントが合わない。

例えばブログモード使ってる人ってけっこう多いけど、彼らは絶対に記事毎に編集コメント管理できた方が便利。トラバ先を記憶する機能ってそんなに開発リソース必要ですか。大した事無い機能変更にもがっつりリソースを割かないと改善できないのが問題。

まぁでも確かに、現在はてダの低い技術ポテンシャルという前提の下では、jkonは正しいね。

b:id:ghostbass なんだって??テーブルの変更なんか必要ないけど?

そうなんですか。考えてみます。思いつかなかったら勉強してみます。Boromさんの案が正解かも。

b:id:EvilGood おそらくそうなんだろうけど、小手先回避なんだろうとは思うが、さきざきサーバーの処理能力が上がって、すべて記法解析でやった方が速度出る日が来そうなんだよな。はてなXMLDBとか検討してるんだろうか?

はてな未来を見据えてそういう拡張をしてきたのか、という点はさておき、すべてを記法でやろうとすると記事の編集時の可読性が下がります。本文にmetaとか記事見出しなのに何故か本文にあるとかトラバ送ったかどうか解らないとか。

ユーザーの快適性とか開発の柔軟性とかを犠牲にしてまで、未来の鯖速度を追求するというのはなかなかどうも、説得されないです。

さらに追記。

b:id:skicco はてな記法ごまかしてくれたおかげで、他のブログサービスではできない重複したカテゴリへの登録ができてる。これが可能なのってはてダくらいじゃね?

最近ブログサービスは知らないですけど、WordPressではできます。ところでカテゴリってリストから選べないと Typo りますよね。

b:id:casm とりあえずブクマ。月収100万の詳細希望(まて

ごめん、年1000万の間違いだったかも。倍近く違うじゃん。malaさんが入社したてのころにどっかでこういうの書いてた。うるおぼえ

b:id:kana-kana_ceo普通なら、日記編集フォームに一つ『ブクマページでブコメを表示する』というチェックボックスを付ける。チェックが off なら head に件の meta を入れる」← なんで、非表示がデフォなんだろう?

一人くらい勘違いする人がいるとは思ってた。非表示がデフォなんて書いてない。デフォでチェックが on にしてあればおk。

チェックボックスのラベルは肯定文で書くのが UI の Tips。「非」表示は否定語。

b:id:al001 "少なくとも"技術力の問題では無いと思うが。面倒とかそういうのであれば分かるけど。 / チェックボックスオンオフ出来るだけで良いなら、DB弄らずともJavaScriptだけで出来る。

まず後半。またまた冗談を。クライアントサイドの解決法じゃ meta が body の下にある事は変わらなかろうて。パース後に動かすつもり?

そういや手元で試してみたら、 Firebugソースを見ると body 内の meta も head の下にあったものとしてパースされるね。

前半は、他の人も同様の事言ってますね。要するに費用対効果の話。

でも、面倒=費用が高くついてるのはシステムの出来が悪いから。スパゲッティーを紐解きたくないんでしょう。

ブコメ非表示みたいなおそらくほとんど使われないような機能だけがこうやって糞仕様存置されてるってんなら、経営判断って意見も説得力がありますね。

2008-09-02

http://anond.hatelabo.jp/20080902220310

ここで糞仕様と言ってるのは meta で判別する仕様とか body 内の meta を拾っちゃう仕様とか、ではなく、はてダ仕様のクソさを言ってます。

これまた至る所で指摘されてるけど、普通なら、日記編集フォームに一つ「ブクマページでブコメを表示する」というチェックボックスを付ける。チェックが off なら head に件の meta を入れる。

こんだけあちこちで言われてるアイディアですから、当然スタッフは思いついたでしょう。さすがにそこまで馬鹿じゃないでしょう。

でも実装しませんでした。実装できないんです。


ダイアリーに関してはその通りだと思うし、ぜひチェックボックスはつけて欲しい。でも、ダイアリー以外のブログ日記のことも考えると、本文中に書くということの意味もあると思う。好きなようにmetaタグheadに入れることが出来るとは限らないから。

ブコメ一覧非表示機能で露呈したはてな技術力の低さ

はてなブックマークのコメント一覧非表示機能について - はてなブックマーク日記 - 機能変更、お知らせなど

みんな知ってる記事だよね。

ブコメでもちらほら批判されてるけど、

はてなダイアリーで任意の記事をコメント非表示としたい場合は、日記本文中に上記の meta タグ入力してください。

なんてのはとんでもない糞仕様

こんなWeb標準違反ユーザーに強いるのはバカでアホ。低脳でワーキングプア、と言いたいところだけど、何気に月収100万だったりするからワーキングプアは違いますねごめんなさい。

この仕様が糞だと判別するのは刺身タンポポ乗せるよりも容易なので、要するにはてなは解ってて直せないんです。

ここで糞仕様と言ってるのは meta で判別する仕様とか body 内の meta を拾っちゃう仕様とか、ではなく、はてダ仕様のクソさを言ってます。

これまた至る所で指摘されてるけど、普通なら、日記編集フォームに一つ「ブクマページでブコメを表示する」というチェックボックスを付ける。チェックが off なら head に件の meta を入れる。

こんだけあちこちで言われてるアイディアですから、当然スタッフは思いついたでしょう。さすがにそこまで馬鹿じゃないでしょう。

でも実装しませんでした。実装できないんです。

なぜ実装できないか。それは、フォームを増やすと記憶すべきテーブルが変わっちゃうからです。各日記毎に1つ、 BOOL 型を余分に記憶しなきゃいけないからです。

その程度の変更、大した事無いような気がします。でもはてな的にはできません。

はてなは何故か、はてダの個別記事の記憶の仕方を変更できません。実はこれは今回が初めてじゃありません。

はてダには日記モードの他に「ブログモード」などという名前に偽りのあるモードがあります。このモードにすると、日付ではなく個別の記事単位での表示も可能になります。一日に複数の記事を投稿できます。

でも、何故か、編集は日付単位でしかできません。「見出し記法」なる抜け道で、擬似的にブログを実現してるに過ぎません。だからコメントとかトラバはまともに管理できない。

なぜ記事毎の編集にできないか。日付で管理するはてなダイアリー」のシステムを変更できないからです。

はてダトラックバックは実装してます。なぜならトラバは送りっ放しで良いから、何も記憶しなくていいからです。

でも、少なくないブログエンジンは、トラバの送り先も記憶します。「あれ?送ってないっけ?」とか勘違いしないで済みます。

なぜはてダトラバの送り先を記憶しないか。記憶できるようにするには、各記事毎に新たなテーブルを用意することになるからです。

はてなはてダデータベースを弄れない。

記事をカテゴリー(っつーかタグ)毎に分ける機能も、ちゃんとは実装されてません。はてな記法と検索で誤摩化してます。

記事毎にカテゴリー記憶するにはデータベースを弄らなきゃいけないからです。

◯◯記法の多彩さであたかも凄い事をやってるかのように見せかけてますが、実際には、◯◯記法データを読み込んで吐き出すところにフックするだけです。

小手先の技術が巧みなのは認めましょう。

でも、小手先の技術ですべてを実現せざるを得ないから、こうやって筋の悪い仕様があちこちに出てくる。

でもだいじょうぶ。一般人は騙せなくとも、筋の悪さに目を瞑るgeek達相手なら小手先だけで騙せますから。

はてな未来は明るいっス。

2008-08-10

テキストブラウザ化するbookmarkletを作りました【black-out.css

2008.9.28 12:53 追記



★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★


★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★





_________________ここから下は古い情報▼__________________________________________________




上記エントリ執筆した増田です。

上記css2ch宣伝してみたら、こんなのがあるよと、 http://d.hatena.ne.jp/oryzan/20080706 を教えてもらいました。

ここで公開されているbookmarkretを借用してblack-out.cssbookmarkletを作ってみました。

現在Mac版Firefox3と、Mac版Sfari、MacOperaで動作を確認。(ぱっと見だけどね)

bookmarkletなので面倒なアドオンインストールなどもすることなく、お手軽にテキストブラウジングがお楽しみ頂けます。

良かったらドゾー

追記(2008.9.28):


追記(2008.9.22):

追記(2008.9.13):



使い方

  1. テキストサイト化したいサイトを開きます。手始めにwikipediaとか良いです。
  2. サイトを開いたら、urlに下記コードを貼付けてenterしてください
  3. black-out.cssソース内容や概要は http://anond.hatelabo.jp/20080810113624 をご覧下さい


javascript:(function(){var%20css='@import%20url(http://example.com/black-out.css);';var%20d=document.getElementsByTagName('style');for%20(var%20i=0,%20di;%20di=d%5Bi%5D;%20i++){if(di.innerText==css){di.parentNode.removeChild(di);return};};var%20heads=document.getElementsByTagName('head');if(heads.length%20%3E%200){var%20node=document.createElement('style');node.type='text/css';node.appendChild(document.createTextNode(css));heads%5B0%5D.appendChild(node);}})()

2008-07-24

メモ

133 名盤さん [] Date:2008/05/10(土) 00:11:05 ID:uW+7WZgx Be:

NME 年間ベストアルバム1980-2007

1980 Joy Division / Closer

1981 Grace Jones / Nightclubbing

1982 Marvin Gaye / Midnight love

1983 Elvis Costello / Punch The Clock

1984 Bobby Womack / Poet 2

1985 Tom Waits / Rain Dogs

1986 Prince & the Revolution / Parade

1987 Public Enemy / Yo bum rush the show

1988 Public Enemy / It Takes A Nation Of Millions..

1990 De La Soul / 3 Feet high & rising

1990 Happy Mondays / Pills 'n' thrills and bellyaches

1991 Nirvana / Nevermind

1992 Sugar / Copper Blue

1993 Bjork / Debut

1994 Oasis / Definitely Maybe

1995 Tricky / Maxinquaye

1996 Beck / Odelay

1997 Spiritualized / Ladies And Gentleman We Are Floating In Space

1998 Mercury Rev / Deserters Songs

1999 The Flaming Lips / The Soft Bulletin

2000 Queens Of The Stone Age ? Rated R

2001 The Strokes / Is This It

2002 Coldplay / A Rush Of Blood To The Head

2003 The White Stripes / Elephant

2004 Franz Ferdinand / Franz Ferdinand

2005 Bloc Party ? Silent Alarm

2006 Arctic Monkeys / Whatever People Say I Am, That’s What I’m Not

2007 Klaxons / Myths Of The Near Future

134 名盤さん [] Date:2008/05/10(土) 00:12:00 ID:uW+7WZgx Be:

Rolling Stone 年間ベストアルバム1980-2007

1980 The Clash / London Calling

1981 Rolling Stones / Tatoo You

1982 Bruce Springsteen / Nebraska and R. & L. Thompson / Shoot out the lights

1983 R.E.M. / Murmur

1984 Bruce Springsteen / Born In The U.S.A.

1985 Talking Heads / Little Creatures

1986 Paul Simon / Graceland

1987 Bruce Springsteen / Tunnel Of Love

1988 Midnight Oil / Diesel and Dust

1989 Neil Young / Freedom

1990 Sinead O'Connor / I Do Not Want What I Haven't Got

1991 R.E.M. / Out Of Time

1992 R.E.M. / Automatic For The People

1993 Nirvana / In Utero

1994 Hole / Live Through This

1995 PJ Harvey / To Bring You My Love

1996 Beck / Odelay

1997 Bob Dylan / Time Out Of Mind

1998 Lauryn Hill / The Miseducation of Lauryn Hill

1999 Rage Against The Machine / The Battle of Los Angeles

2000 Eminem / The Marshall Mathers LP

2001 Bob Dylan / Love and Theft

2002 Beck / Sea Change

2003 OutKast / Speakerboxxx/The Love Below

2004 Kanye West / The College Dropout

2005 Kanye West / Late Registration

2006 Bob Dylan / Modern Times

2007 MIA / Kala

135 名盤さん [] Date:2008/05/10(土) 00:42:04 ID:uW+7WZgx Be:

おまけ

rockin'on 年間ベストアルバム 2002-2007

2002 Red Hot Chili Peppers / By the Way

2003 Radiohead / Hail to the Thief

2004 Green Day / American Idiot

2005 Oasis / Don't Believe The Truth

2006 Red Hot Chili Peppers / Stadium Arcadium

2007 Radiohead / In Rainbows

SNOOZER 年間ベストアルバム 1997-2007

1997 Radiohead / OK Computer

1998 Elliott Smith / XO

1999 Super Furry Animals / Guerilla

2000 FUMIYA TANAKA / UNKNOWN POSSIBILITY vol.2

2001 Super Furry Animals / Rings Around The World

2002 Beck / Sea Change

2003 Outkast / Speakerboxxx/The Love Below

2004 The Libertines / The Libertines

2005 Hard-Fi / Stars Of CCTV

2006 Arctic Monkeys / Whatever People Say I Am, That’s What I’m Not

2007 Radiohead / In Rainbows

2008-07-22

[]関連エントリーのツリーをたどれるグレモン

結局概要表示機能追加した。unsafeWindow使いまくり大丈夫かいな。

// ==UserScript==
// @name	Hatena Bookmark Tree Expander
// @namespace	http://anond.hatelabo.jp/
// @include	http://b.hatena.ne.jp/entry/*
// ==/UserScript==
// <div class="info">
//   <ul id="similar_entries" class="bookmarklist">
//     <li></li>
//   </ul>
// </div>
// <div class="info">
//   <ul id="referred_entries" class="bookmarklist">
//     <li id="referred-entry-\d+"></li>
//   </ul>
// </div>
// <div class="info">
//   <ul id="relation_diary" class="bookmarklist">
//     <li id="diary-{id}-\d+"></li>
//   </ul>
// </div>
(function() {

function main() {
	loadBookmarkCommentViewer();
	similar.prototype.rootAppend();
	referred.prototype.rootAppend();
}

function HBTM(target) {
	this.target = target;
	this.targetXPath = "//ul[@id='"+target+"']/li";
	this.targetRegExp = new RegExp('<ul id="'+target+'"(.|\\s)*?</ul>');
}
HBTM.prototype = {
	openIcon:
		'<img width="15" height="15" class="icon" style="opacity: 0.6" src="http://anond.hatelabo.jp/images/common/open.gif"/>',
	closeIcon:
		'<img width="15" height="15" class="icon" style="opacity: 0.6" src="http://anond.hatelabo.jp/images/common/close.gif"/>',
	loadingIcon:
		'<img width="13" height="13" class="icon" src="http://anond.hatelabo.jp/images/common/loading.gif"/>',
	commentIcon: function(url) {
		return '<img class="hatena-bcomment-view-icon" src="http://r.hatena.ne.jp/images/popup.gif" onclick="iconImageClickHandler(this, \''+url+'\', event);">'
	},
	create: function() {
		this.comment = document.createElement("span");
		this.comment.innerHTML = this.commentIcon($X("string(descendant::a/@href)", this.node).value());
		this.open = document.createElement("a");
		this.open.href = "javascript:void(0)";
		this.open.innerHTML = this.openIcon;
		this.close = document.createElement("a");
		this.close.href = "javascript:void(0)";
		this.close.innerHTML = this.closeIcon;
		this.close.style.display = "none";
		this.loading = document.createElement("span");
		this.loading.innerHTML = this.loadingIcon;
		this.loading.style.display = "none";
		this.node.appendChild(this.comment);
		this.node.appendChild(document.createTextNode(" "));
		this.node.appendChild(this.open);
		this.node.appendChild(this.close);
		this.node.appendChild(this.loading);
		this.open.addEventListener("click", bind(this.openAct, this), false);
		this.close.addEventListener("click", bind(this.closeAct, this), false);
	},
	openAct: function() {
		this.open.style.display = "none";
		if (this.tree) {
			this.tree.style.display = "block";
			this.close.style.display = "inline";
		} else {
			this.loading.style.display = "inline";
			this.load();
		}
	},
	closeAct: function() {
		if (this.tree) {
			this.tree.style.display = "none";
			this.close.style.display = "none";
			this.open.style.display = "inline";
		}
	},
	load: function() {
		var url = $X("string(descendant::a[starts-with(@href, '/entry/')]/@href)", this.node).value();
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://b.hatena.ne.jp"+url,
			onload: bind(this.loadCallback, this)
		});
	},
	loadCallback: function(result) {
		var match = result.responseText.match(this.targetRegExp);
		if (match) {
			var sandbox = document.createElement("div");
			sandbox.innerHTML = match[0].replace(this.target,"");
			this.tree = sandbox.firstChild;
		} else {
			this.tree = document.createElement("ul");
		}
		this.append();
		this.loading.style.display = "none";
		this.close.style.display = "inline";
	},
	append: function() {
		this.tree.style.backgroundColor = "transparent";
		this.tree.style.listStyleType = "circle";
		this.node.appendChild(this.tree);
		$X("li", this.tree).each(function(n) {
			var a = $X("a",n).node();
			var c = $X("count(//li/a[@href='"+a.href+"'])").value();
			if (c > 1) n.parentNode.removeChild(n);
		});
		$X("li", this.tree).each(bind(function(node){new this.constructor(node)}, this));
	},
	rootAppend: function() {
		$X(this.targetXPath).each(bind(function(node){new this.constructor(node)}, this));
	}
};

function similar(node) {
	this.node = node;
	this.create();
}
similar.prototype = new HBTM("similar_entries");
similar.prototype.constructor = similar;

function referred(node) {
	this.node = node;
	this.create();
}
referred.prototype = new HBTM("referred_entries");
referred.prototype.constructor = referred;

function loadBookmarkCommentViewer() {
	var head = document.getElementsByTagName("head")[0];
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://b.hatena.ne.jp/js/BookmarkCommentViewerAllInOne.1.2.js";
	head.appendChild(script);
	var css = document.createElement("link");
	css.rel="stylesheet";
	css.href="http://d.hatena.ne.jp/css/base.css";
	css.type="text/css";
	css.media="all";
	head.insertBefore(css, head.firstChild);
	window.addEventListener("load",function(){
		var BCV = unsafeWindow.BookmarkCommentViewer;
		BCV.options['screenshot'] = true;
		var asyncCommnetView = BCV.asyncCommnetView;
		BCV.asyncCommnetView = function(url, onCompleteCallback) {
			var div = asyncCommnetView(url, function(){
				onCompleteCallback.apply(this, arguments);
				new unsafeWindow.Ten.XHR("http://b.hatena.ne.jp/entry/rss/"+url, {}, function(result) {
					if (! result.responseText.match(/<description>(.*?)<\/description>/))
						return;
					if (! RegExp.$1)
						return;
//					var desc = document.createTextNode("desc: "+RegExp.$1);
					var desc = document.createElement("li");
					desc.appendChild(document.createTextNode("desc: "+RegExp.$1));
					div.lastChild.insertBefore(desc,div.lastChild.getElementsByTagName("li")[0]);
				});
			});
			return div;
		};
		BCV.asyncCommnetView.origin = asyncCommnetView;
	}, false);
}

function bind(f,o) {return function() {return f.apply(o, arguments)}}

function $X(xpath, context) {
	if (!(this instanceof $X))
		return new $X(xpath, context);
	this.xpath = xpath;
	this.context = context || document;
}
$X.prototype = {
	evaluate: function() {
		var result = document.evaluate(this.xpath, this.context, null, this.type, null);
		switch (result.resultType) {
			case XPathResult.STRING_TYPE : return result.stringValue;
			case XPathResult.NUMBER_TYPE : return result.numberValue;
			case XPathResult.BOOLEAN_TYPE: return result.booleanValue;
			case XPathResult.FIRST_ORDERED_NODE_TYPE: return result.singleNodeValue;
		}
		return result;
	},
	node: function() {
		this.type = XPathResult.FIRST_ORDERED_NODE_TYPE;
		return this.evaluate();
	},
	value: function() {
		this.type = XPathResult.ANY_TYPE;
		return this.evaluate();
	},
	each: function(func) {
		this.type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
		var result = this.evaluate();
		for (var i=0; i<result.snapshotLength; i++)
			func(result.snapshotItem(i));
	}
};

main();

})();

2008-07-17

犯行予告ジェネレータ

サーバーサイドでマジメに作ったら逮捕されるんだろうか…?けーさつこわいから悪用とかしないでね><

ところで2chのどっかの板の名前欄って人名と地名がランダム表示されるけど、どうやってリストを作成してるんだろ?

<html><head><title>反抗予告ジェネレータ</title><script type="text/javascript"><!--

var safe_mode = 1;
var date, place, object, action;

date = get_date();
object = get_object();
action = get_action();
httpRequest("http://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E5%A4%A7%E5%AD%A6%E4%B8%80%E8%A6%A7");

function get_date() {
	var now = new Date();
	now.setTime(now.getTime() + Math.floor(Math.random()*1000*60*60*24*30));

	if (safe_mode != 0) { now.setTime(now.getTime() + 1000*60*60*24*(365*3+366)/4*100); }

	return now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日"+now.getHours()+"時"+now.getMinutes()+"分"+now.getSeconds()+"秒";
}

function get_object() {
	var b = ["小女子", "増田", "ひろゆき", "ぬこ"];
	return b[Math.floor(Math.random()*b.length)];
}

function get_action() {
	var b = ["投", "SATSUGAI", "なでなで", "もふもふ"];
	return b[Math.floor(Math.random()*b.length)];
}

function httpRequest(target_url) {
	try {
		if(window.XMLHttpRequest) {	httpObj = new XMLHttpRequest(); }
		else if(window.ActiveXObject) {	httpObj = new ActiveXObject("Microsoft.XMLHTTP"); }
		else { return; }
	} catch(e) { return; }

	httpObj.open("GET", target_url, true);
	httpObj.onreadystatechange = DataRead;
	httpObj.send("");

	return;
}

function DataRead() {
	if (httpObj.readyState == 4 &amp;&amp; httpObj.status == 200) {

		var res = httpObj.responseText;
		var b = new Array();
		b = res.match(/>([亜-熙]+)大学/g);
		place = b[Math.floor(Math.random()*b.length-1)].replace(">","");

		if (safe_mode != 0) { place = place.replace("大学", "○○"); }

		document.body.innerText = date+"に"+place+"あたりで"+object+"を"+action+"します…!";
	}
}

// --></script></head><body style="color:red; background-color:black; font-size:30px; text-align:center;"></body></html>

2008-07-04

javascript継承

javascriptスーパークラスのメソッドを簡単に呼び出したかった。それだけだった。

思いのほか長くなった。車輪を再発明した気がする。

var Class = inherit(SuperClass, {hoge: ...});

のように使い、スーパークラス継承したクラスを作る。

作ったクラスprototypeに、第二引数オブジェクトコピーされたスーパークラスインスタンスを持つ。

第一引数がnullだと、スーパークラスObjectを用いる。つまり、

var Class = inherit(null, {hoge: ...});

var Class = inherit(Object, {hoge: ...});

と同等となる。

また、第一引数が"prototype"をメンバに持たない普通オブジェクト、つまり、

var Class = inherit({hoge: ...});

だと

var Class = inherit(Object, {hoge: ...});

と同等となる。

var obj = new Class({hoge: ...});

インスタンスを作ると、引数オブジェクトコピーを持つオブジェクトとなる。

また、メソッド"initialize"が自動的に実行される。

ただし、コンストラクタ引数を渡さなかった場合は、initializeは実行されない。

オーバーイドしたメソッド内では

this.superapply(arguments);

としてスーパークラスのメソッドを呼べる。第一引数は呼び出すメソッドの引数配列とする。

このとき、呼び出し側のメソッドはコンストラクタやinheritでオーバーイドしたメソッドでなくてはならない。これは呼び出し側のメソッド名を記録する必要があるためである。

そうでない場合は第二引数にメソッド名を渡す必要がある。

var obj = new Class({});
obj.foo = function(){
        this.superapply(arguments);         // X
        this.superapply(arguments, "foo");  // O
};

<html><head>
<script type="text/javascript">
function inherit(superclass, override) {
	if (!superclass)
		superclass = Object;
	if (! "prototype" in superclass) {
		override = superclass;
		superclass = Object;
	}
	var that;
	var func;
	function superapply(arg, name) {
		var prev = {that: that, func: func};
		try {
			var my = this.superapply;
			if (!arg)
				arg = [];
			if (!name)
				name = arguments.callee.caller.caller.methodName;
			if (that &amp;&amp; func &amp;&amp; (!name || name == func.methodName)) {
				that = that.superapply.obj;
				name = func.methodName;
			} else if (name) {
				that = my.obj;
				func = arguments.callee.caller.caller;
				func.methodName = name;
			} else {
				throw new Error("methodName is null");
			}
			var result;
			if (func === that[name]) {
				result = this.superapply(arg, name);
			} else {
				func = that[name];
				func.methodName = name;
				result = func.apply(this, arg);
			}
		} finally {
			that = prev.that;
			func = prev.func;
		}
		return result;
	};
	var prototype = new superclass();
	prototype.superapply = function(){superapply.apply(this, arguments)};
	prototype.superapply.obj = superclass.prototype;
	if (override)
		for (var i in override) {
			prototype[i] = override[i];
			if (typeof override[i] == "function")
				prototype[i].methodName = i;
		}
	var subclass = function(obj) {
		this.superapply = function(){superapply.apply(this, arguments)};
		this.superapply.obj = prototype;
		if (obj) {
			for (var i in obj) {
				this[i] = obj[i];
				if (typeof obj[i] == "function")
					this[i].methodName = i;
			}
			this.initialize();
		}
	};
	subclass.prototype = prototype;
	subclass.prototype.constructor = subclass;
	return subclass;
}
var C1 = inherit(Object, {
fn: "C1",
initialize:
	function(){
		alert("C1.initialize");
		this.second(this.fn);
	},
second:
	function(a){
		alert("C1.second: "+a);
	}
});
var C2 = inherit(C1, {
fn: "C2",
initialize:
	function(){
		alert("C2.initialize");
		this.superapply();
//	},
//second:
//	function(a){
//		alert("C2.second: "+a);
//		this.superapply([a]);
	}
});
var C3 = new C2({
fn: "C3",
//initialize:
//	function(){
//		alert("C3.initialize");
//		this.superapply();
//	},
second:
	function(a){
		alert("C3.second: "+a);
		this.superapply([a]);
	}
});
</script>
</head><body>
</body><html>

methodNameなんとかならんもんか。

2007-12-12

http://anond.hatelabo.jp/20071212171321

でも俺もmake sureなんていわれたらトドメさしちゃうよ。

make sureなんてこういう場合つかわねぇよな??

べりふぃうんちゃらとかこんしだーとかつかうんじゃねぇの?

それより想像力豊かなおいらは

his eyes are rolled back in his head

これで、寄生獣モード想像してしまったあるよ。

A couple of New Jersey hunters are out in the woods when one of them

falls to the ground. He doesn't seem to be breathing, his eyes are

rolled back in his head. The other guy whips out his cell phone and

calls the emergency services. He gasps to the operator: “My friend is

dead! What can I do?” The operator, in a calm soothing voice says:

“Just take it easy. I can help. First, let's make sure he's dead.”

There is a silence, then a shot is heard. The guy's voice comes back

on the line. He says: “OK, now what?"

2006-11-21

anond pickup of the day

以下の二つに留意、つまり乱用禁止。

取説未満

// ==UserScript==
// @name	anond pickup of the day
// @namespace	http://anond.hatelabo.jp/
// @description	pickup section of the day at Hatelabo::AnonymousDiary
// @include	http://anond.hatelabo.jp/2*
// ==/UserScript==
(function(){
	var trackbackThreshold = 10;
	var ignoreList = {
		"/20070801172335": 33,
		"/20070806163721": 10,
	};

	// only section of the day
	if (! location.pathname.match(/^\/\d{8}$/)) {
		return;
	}

	// regist ancher that kick main routine
	var a = document.createElement("a");
	a.href = "#";
	a.innerHTML = "pickup of the day";
	a.addEventListener("click", grab, false);
	var firstPager_l = document.evaluate("//div[@class='pager-l']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
	firstPager_l.appendChild(a);

	function Outline() {
		this.outline = document.createElement("ul");
		this.text = document.createElement("textarea");
		this.text.style.overflow = "auto";
		this.text.style.width = "100%";
		this.text.style.height = "15em";
		this.text.innerHTML = "</ul><\n><ul>\n";
		this.list = new Array();
	}
	Outline.prototype.setup = function() {
		var parent = document.getElementById("body");
		parent.insertBefore(this.outline, parent.firstChild);
		parent.insertBefore(this.text, parent.firstChild);
	}
	Outline.prototype.append = function(section) {
		var h3 = section.getElementsByTagName("h3")[0];
		var sectionName = h3.firstChild.pathname.replace(/\//,"");
		var sectionText = h3.textContent.replace(/\s*$/,"");
		if (sectionText == "\u25a0") {
			sectionText = sectionName;
		}
		this.text.innerHTML +=
			'<h2>[http://anond.hatelabo.jp/'+sectionName+
			":title="+sectionText.replace(/^\u25a0/,"").replace(/]/g,"&amp;#93;")+"] "+
			'<a href="http://b.hatena.ne.jp/entry/http://anond.hatelabo.jp/'+sectionName+'">'+
			'<img src="http://b.hatena.ne.jp/entry/image/http://anond.hatelabo.jp/'+sectionName+'">'+
			"</a></h2>\n";
		h3.firstChild.name = sectionName;
		var li = document.createElement("li");
		li.innerHTML =
			'<a href="#'+sectionName+'">' +
			sectionText.replace(/&amp;/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;") +
			"</a>";
		var nextSibling = 0;
		for (var i in this.list) {
			if (nextSibling < i &amp;&amp; i < sectionName) {
				nextSibling = i;
			}
		}
		if (nextSibling) {
			this.outline.insertBefore(li, this.list[nextSibling]);
		} else {
			this.outline.appendChild(li);
		}
		this.list[sectionName] = li;
	}
	var outline = new Outline();

	function CC(day) {
		this.li = document.createElement("li");
		this.li.innerHTML = '<a href="/'+day+'" target="_blank">' + day + "</a>";
		this.day = day;
		this.n = new Array();
	}
	CC.prototype.pp = function(id) {
		this.n.push(id);
		if (this.n.length > 10) {
			this.li.innerHTML = '<a href="/'+this.day+'" target="_blank">' + this.day + "</a> " + this.n.length;
		} else {
			this.li.innerHTML += ' <a href="/'+id+'" target="_blank">*</a>';
		}
	}

	function Count() {
		this.count = document.createElement("ul");
		this.list = new Array();
	}
	Count.prototype.setup = function() {
		var parent = document.getElementById("body");
		parent.insertBefore(this.count, parent.firstChild);
	}
	Count.prototype.append = function(day, id) {
		var nextSibling = 0;
		for (var i in this.list) {
			if (nextSibling < i &amp;&amp; i <= day) {
				nextSibling = i;
			}
		}
		if (nextSibling == day) {
			this.list[nextSibling].pp(id);
		} else {
			var cc = new CC(day);
			if (nextSibling) {
				this.count.insertBefore(cc.li, this.list[nextSibling].li);
			} else {
				this.count.appendChild(cc.li);
			}
			this.list[day] = cc;
			cc.pp(id);
		}
	}
	Count.prototype.appendSection = function(section) {
		var id = section.getElementsByTagName("h3")[0].firstChild.pathname.replace(/\//,"");
		var today = id.match(/\d{8}/)[0];
		var anchors = section.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			if (anchors[i].href &amp;&amp; anchors[i].host == "anond.hatelabo.jp" &amp;&amp; anchors[i].pathname.match(/\/(\d{8})\d{6}/) &amp;&amp; RegExp.$1 != today) {
				this.append(RegExp.$1, id);
			}
		}
	}
	var count = new Count();

	function Hide(){}
	Hide.prototype.setup = function() {
		this.style = document.createElement("style");
		this.style.id = "hide";
		this.style.type = "text/css";
		document.getElementsByTagName("head")[0].appendChild(this.style);
		var self = this;
		this.a = new Object();
		this.a.visible = document.createElement("a");
		this.a.visible.id = "visible";
		this.a.visible.href = "#";
		this.a.visible.innerHTML = "visible hide section";
//		this.a.visible.setAttribute("onclick","document.getElementById('hide').innerHTML = 'div.hide {display: block}';document.getElementById('visible').style.display = 'none';document.getElementById('unvisible').style.display = 'inline';");
		this.a.visible.addEventListener("click", function(){self.visible()}, false);
		firstPager_l.parentNode.insertBefore(this.a.visible, firstPager_l);
		this.a.unvisible = document.createElement("a");
		this.a.unvisible.id = "unvisible";
		this.a.unvisible.href = "#";
		this.a.unvisible.innerHTML = "unvisible hide section";
//		this.a.visible.setAttribute("onclick","document.getElementById('hide').innerHTML = 'div.hide {display: none}';document.getElementById('visible').style.display = 'inline';document.getElementById('unvisible').style.display = 'none';");
		this.a.unvisible.addEventListener("click", function(){self.unvisible()}, false);
		firstPager_l.parentNode.insertBefore(this.a.unvisible, firstPager_l);
		this.unvisible();
	}
	Hide.prototype.visible = function() {
		this.style.innerHTML = "div.hide {display: block}";
		this.a.visible.style.display = "none";
		this.a.unvisible.style.display = "inline";
	}
	Hide.prototype.unvisible = function() {
		this.style.innerHTML = "div.hide {display: none}";
		this.a.visible.style.display = "inline";
		this.a.unvisible.style.display = "none";
	}
	Hide.prototype.append = function(section) {
		if (section.className.match(/hide/)) {
			return;
		}
		section.className += " hide";
		count.appendSection(section);
	}
	Hide.prototype.is = function(section) {
		return section.className.match(/hide/);
	}
	var hide = new Hide();

	// main routine
	function grab(){
		if (! document.body.innerHTML.match(/<div class="pager-r">(\d+)/)) {
			return;
		}
		var pages = RegExp.$1 -0;
		if (pages <= 0 || pages > 40) { // check error and limit 1000 entry
			return;
		}
//pages = 2;

		firstPager_l.style.display = "none";
		outline.setup();
		hide.setup();
		count.setup();

		var mainbody = document.evaluate("//div[@class='body']", document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
		mainbody.innerHTML = "\n";
		for (var i=1; i<=pages; i++) {
			cat(mainbody, i);
		}
	}

	// page load and concatenate
	function cat(container, page) {
		container.innerHTML += "<!-- page " + page + " -->\n";
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://anond.hatelabo.jp" + location.pathname + "?page=" + page,
			onload: function(result) {
				result.responseText.match(/<div class="body">((.|\s)*?)\s*<\/div>\s*<\/div>\s*<div class="pager-l">/);
				container.innerHTML = container.innerHTML.replace("<!-- page " + page + " -->", RegExp.$1);
				if (! container.innerHTML.match(/<!-- page \d+ -->/)) {
//					document.documentElement.innerHTML = document.documentElement.innerHTML.replace(/(src|href)=\"\//mg, "$1=\"http://anond.hatelabo.jp/");
					pickup();
				}
			}
		});
	}

	// pickup section at last cat() concatenate after
	function pickup() {
		var target = document.evaluate(
			"//div[@class='section' and child::*[not(@class='sectionfooter') and descendant::a[starts-with(@href,'http://anond.hatelabo.jp/2') or starts-with(@href,'/2') and not(child::span[@class='sanchor'])]]]",
			document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
		for (var i=0; i<target.snapshotLength; i++) {
			hide.append(target.snapshotItem(i));
		}

		var tbs = document.evaluate(
			"//p[@class='sectionfooter']/a[2]",
			document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
		for (var i=0; i<tbs.snapshotLength; i++) {
			var tb = tbs.snapshotItem(i);
			if (tb.innerHTML == "\u30c8\u30e9\u30c3\u30af\u30d0\u30c3\u30af(0)") {
				hide.append(tb.parentNode.parentNode);
			} else if (! hide.is(tb.parentNode.parentNode)) {
				trackback(tb);
			}
		}
	}

	// count trackbacks
	function trackback(tb) {
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://anond.hatelabo.jp/" + tb.pathname.match(/\d{14}/),
			onload: function(result) {
				var link = result.responseText.match(/<a name="tb">(.|\s)*/)[0].match(/<li>\s*<a href="http:\/\/anond.hatelabo.jp\/\d{14}"/g);
				var n = link.length;
				for (var l in link) {
					var m = "/" + link[l].match(/\d{14}/);
					if (m in ignoreList) {
						n -= ignoreList[m];
					}
				}
				if (n < trackbackThreshold) {
					hide.append(tb.parentNode.parentNode);
				} else {
					tb.innerHTML = tb.innerHTML.replace(/\)$/, "/"+n+")");
					outline.append(tb.parentNode.parentNode);
				}
			}
		});
	}

})();

 
ログイン ユーザー登録
ようこそ ゲスト さん