<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/xml.xsl" type="text/xsl"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>nulog, NULL::something : out of the headphone &gt; 2004 &gt; December &gt; 12</title>
  <link href="http://lowreal.net/logs/2004/12/12"/>
  <icon>http://lowreal.net/img/banner.png</icon>
  <link rel="self" type="application/atom+xml" href="http://lowreal.net/logs/2004/12/12.atom"/>
  <link rel="alternate" type="application/xhtml+xml" href="http://lowreal.net/logs/2004/12/12.xhtml"/>
  <updated>2004-12-12T20:01:44+09:00</updated>
  <author>
    <name>cho45(砂糖)</name>
  </author>
  <id>http://lowreal.net/2004/12/12</id>
  <entry>
    <title>ua.indexOf("MSIE") != -1 ?</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2004/12/12/1.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2004/12/12/1.xhtml"/>
    <updated>2004-12-12T00:40:50+09:00</updated>
    <published>2004-12-12T00:40:50+09:00</published>
    <id>http://lowreal.net/2004/12/12/1</id>
    <category term="prog"/>
    <category term="web"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><abbr title="User Agent">UA</abbr> 文字列を Javascript から得るにあたり検索をかけてみたのだけど、<abbr title="User Agent">UA</abbr> 文字列に<em class="point">ある文字列 (eg. “MSIE”) </em> があるか調べるときに String.prototype.indexOf の結果が -1 であるかを調べているのが多かった。これはやっぱ String.prototype.match だと遅いとかそういう問題があるからなのだろうか……なんかダサいので今回自分は String.prototype.match を使ったけど、どうなんだろ。</p>
        <pre title="indexOf で調べる例" class="ECMAScript">if (navigator.userAgent.indexOf("MSIE") != -1)
    // do something for MSIE</pre>
        <pre title="match で調べる例" class="ECMAScript">if (navigator.userAgent.match(/MSIE/))
    // do something for MSIE</pre>
        <p>さらに <code>&amp;&amp;</code> とか使おうとすると演算子の優先順位 (よく忘れる) とか考えることになって面倒臭い……</p>
      </div>
    </content>
  </entry>
  <entry>
    <title>code をクライアント側で着色</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2004/12/12/2.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2004/12/12/2.xhtml"/>
    <updated>2004-12-12T03:00:30+09:00</updated>
    <published>2004-12-12T03:00:30+09:00</published>
    <id>http://lowreal.net/2004/12/12/2</id>
    <category term="prog"/>
    <category term="web"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>pre に現れるコードを Javascript で着色 (Javascript でやってるのはマークアップ) してみる。重い？</p>
        <p>少し前からこれがやってみたかったので class 属性に使用してる言語を書いていたりした。言語ごとにトークンを使いわけたようと思ってたわけだけど、実際そこまでやるのってどうなのよ、とか思い始めた。そのうちやってみて、いけそうだったら採用してみよう。</p>
        <ins datetime="2004-12-12T03:05:35+09:00">
          <p>現状でもかなり重い気が……長くとれるトークンを増やせば (ループ量が減って) 軽くなるかもしれないけど微妙。実際一文字ずつループまわしてるからなぁ。やりすぎか。</p>
        </ins>
        <ins datetime="2004-12-12T03:42:25+09:00">
          <p>Ruby と ECMAScript は別のトークンテーブル使うようにしてみた。別にパースしてるわけじゃない (スキャンだけ) なので微妙にアレな状況が既にいくつか思いつくわけですが……例えば式展開の引数で括ってるクオーテーションつかっちゃうとかが絶対おかしくなる。</p>
          <p>それとループ回数を減らすために <code class="Regexp">/[a-z][a-z0-9]*/i</code> は identifer ってことにしてスキップしてる。</p>
        </ins>
        <ins datetime="2004-12-12T05:33:42+09:00">
          <p>Lisp と <abbr title="Extensible Markup Language">XML</abbr> もすっごい適当に加えた。</p>
        </ins>
        <p><a href="/2004/color-code">サンプル</a> 重いので移した。</p>
        <p>正規表現はブラウザ毎の違いが殆どない気もする。気付いてないだけかもしれないけど。</p>
        <p><abbr title="Mozilla Firefox | Final Fantasy">FF</abbr> で右クリックから View Selection Source すると内部 <abbr title="Document Object Model">DOM</abbr> の内容もソースとして出てくるのが役に立った……</p>
        <ins datetime="2004-12-14T13:54:12+09:00">
          <p>そもそもスキャナの実装が激しく間違ってたので修正。根本的な部分を変えたのでバグがあるかもしれない。</p>
        </ins>
      </div>
    </content>
  </entry>
  <entry>
    <title>Audioscrobbler で他人のやつ混ざる</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2004/12/12/3.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2004/12/12/3.xhtml"/>
    <updated>2004-12-12T20:01:44+09:00</updated>
    <published>2004-12-12T20:01:44+09:00</published>
    <id>http://lowreal.net/2004/12/12/3</id>
    <category term="web"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Audioscrobbler で最近 Recent Tracks に聞いてない曲が混ざることがある。<abbr title="BUMP OF CHICKEN">バンプ</abbr> が車輪の唄のシングルカットしてたなんてそもそも知らないのに、それのカップリングのやつが Recent Tracks に混ざっていたりする。</p>
        <p>無作為に混ざっているわけじゃないらしく？同じアーティスト聞いてると混ざるみたい？</p>
      </div>
    </content>
  </entry>
</feed>
