image

  • フォト Amazonギフト券
    ※この時計の時刻は、閲覧しているパソコンのものであり、必ずしも正確な時間とは限りません

検索

最近のトラックバック

無料ブログはココログ

« 2007-09-08 | トップページ | 2007-09-10 »

2007-09-09

2007-09-09

ピックアップ: Ruby1.9は1.8より平均5倍速いらしい, Googleの面接試験 一体どのような質問をされるのか, etc...

- http://fnya.cocolog-nifty.com/blog/2007/09/ruby1918_0a98.html
> > あるSEのつぶやき: 次期バージョンのRuby1.9は1.8より平均5倍速いらしい

- http://return-to-forever.cocolog-nifty.com/blog/2007/09/selected_by_16e3.html
> > Return to Forever: 星の王子様--selected by 小川洋子

- http://web-marketing.zako.org/web-tools/igoogle-gadgetigoogle/igoogle-gadgets-for-web-worker.html
> > WEB担当者が仕事でiGoogleを効率よく使うための15のガジェット|WEBマーケティングブログ

- http://gigazine.net/index.php?/news/comments/20070909_google_job_interview/
> > Googleの面接試験、一体どのような質問をされるのか? - GIGAZINE

- http://mozilla-remix.seesaa.net/article/54501267.html
> > Mozilla Re-Mix: Firefoxに悪影響を及ぼす可能性のあるアドオンリスト。

- http://www.moongift.jp/2007/09/watir/
> > MOONGIFT: » ブラウザテストをRubyで自動化「Watir」:オープンソースを毎日紹介

- http://www.moongift.jp/2007/09/zk/
> > MOONGIFT: » JavaでリッチUIを実現「ZK」:オープンソースを毎日紹介

- http://www.popxpop.com/archives/2007/09/name_that_color.html
> > この色の名前はなに?を教えてくれる『Name That Color』 | P O P * P O P

- http://d.hatena.ne.jp/jitte/20070906/1189079040
> > jitteの日記 - RubyでGoogleMapsするメモ

- http://itpro.nikkeibp.co.jp/article/Research/20070829/280609/
> > RSS配信状況、自治体サイトは10%突破、上場企業は7.4%:ITpro

xfy/xvcd の svg でタイマーイベントを扱う

Svgtimer

xfy のダウンロードサイト
https://www.xfytec.com/community/modules/mydownloads/singlefile.php?lid=131
にある "xfy での MP3 プレーヤ" では、SVG での文字表示を タイマーを使って表示更新しているようだ。

これを参考にして、単純なストップタイマーを作ってみた。
(本当に単純で、単に現在の時間を 0.1 秒単位で表示更新するのを Stop/Start できるだけのもの)

これで マウスイベントも、タイマーも扱う実験ができたことになる。
簡単なゲームをつくれるようになるかな?

$ cat 4.xml
<?xml version="1.0" encoding="UTF-8" ?>
<?com.xfy vocabulary-connection href="4.xvcd" ?>
<sample:item xmlns:sample="http://xmlns.xfy.com/sample/pry">10</sample:item>

$ cat 4.xvcd
<?xml version="1.0" encoding="UTF-8"?>
<xvcd:xvcd
  version="1.0"
  xmlns:xvcd="http://xmlns.xfy.com/xvcd"
  xmlns:function="http://xmlns.xfy.com/function"
  xmlns:ctrl="http://xmlns.xfy.com/controls"
  xmlns:instruction="http://xmlns.xfy.com/instruction"
  xmlns:sample="http://xmlns.xfy.com/sample/pry"
  xmlns:svg="http://www.w3.org/2000/svg"
  xmlns="http://www.w3.org/1999/xhtml">

<xvcd:vocabulary name="timer" match="sample:item" call-template="root"/>

<xvcd:variable name="time-format" select="'yyyy-MM-dd HH:mm:ss:'"/>
<xvcd:variable name="time-interval" select="'100'"/>
<xvcd:variable name="style" select="'fill:blue;font-size:24.0'"/>

<xvcd:user-data name="timer" value="start"/>
<xvcd:user-data name="time" value="{function:now($time-format)}000"/>

<xvcd:template name="root">
  <html>
    <head>
      <title>time-event</title>
    </head>
    <body>

      <ctrl:trigger>
        <ctrl:label><xvcd:value-of select="xvcd:user-data('timer')"/></ctrl:label>
        <xvcd:action event="ctrl:triggered">
          <instruction:choose>
            <instruction:when test="xvcd:user-data('timer') = 'stop'">
              <xvcd:set-user-data name="timer" value="start"/>
            </instruction:when>
            <instruction:otherwise>
              <xvcd:set-user-data name="timer" value="stop"/>
              <xvcd:set-user-data name="time"
                value="{concat(function:now($time-format), function:now('SSS', $time-interval))}" />
            </instruction:otherwise>
          </instruction:choose>
        </xvcd:action>
      </ctrl:trigger>

      <div>
        <xvcd:call-template name="svg-timer"/>
      </div>
    </body>
  </html>
</xvcd:template>

<xvcd:template name="svg-timer">
  <xvcd:variable name="text-val">
    <xvcd:choose>
      <xvcd:when test="xvcd:user-data('timer') = 'stop'">
        <xvcd:value-of select="concat(function:now($time-format), function:now('SSS', $time-interval))"/>
      </xvcd:when>
      <xvcd:otherwise>
        <xvcd:value-of select="xvcd:user-data('time')"/>
      </xvcd:otherwise>
    </xvcd:choose>
  </xvcd:variable>

  <svg:svg width="400" height="60">
    <svg:g>
      <svg:text x="5" y="25" style="{$style}">
        <xvcd:value-of select="$text-val"/>
      </svg:text>
    </svg:g>
  </svg:svg>
</xvcd:template>

</xvcd:xvcd>

ピラミッドを作る (xvcd)

Pry

昨日の ピラミッドを作る (xslt) を xfy/xvcd 用に、変更してみた。
もっと記述は簡潔にできるとは思う。
でも xslt, xvcd いずれにしても ruby を始めとした他のスクリプト言語での回答のように短くかくことは無理だなぁ...
xvcd でループを書く場合は、ruby で書いて 結果だけ xvcd から呼び出すのが実用的とおもう。

$ cat 3.xml
<?xml version="1.0" encoding="UTF-8" ?>
<?com.xfy vocabulary-connection href="3.xvcd" ?>
<sample:item xmlns:sample="http://xmlns.xfy.com/sample/pry">10</sample:item>

$ cat 3.xvcd
<?xml version="1.0" encoding="UTF-8"?>
<xvcd:xvcd
  version="1.0"
  xmlns:xvcd="http://xmlns.xfy.com/xvcd"
  xmlns:sample="http://xmlns.xfy.com/sample/pry"
  xmlns="http://www.w3.org/1999/xhtml">

<xvcd:vocabulary name="pyr" match="sample:item" call-template="root"/>

<xvcd:template name="root">
  <html>
    <head><title>ピラミッド</title></head>
    <body>
      ピラミッドの高さは?:<xvcd:text-of select="./text()" filler="0"/>
      <pre>
    <xvcd:variable name="stars">
      <xvcd:call-template name="stars-str">
        <xvcd:with-param name="n" select="./text()"/>
      </xvcd:call-template>
    </xvcd:variable>
        <xvcd:call-template name="pyr">
          <xvcd:with-param name="n" select="./text()" />
          <xvcd:with-param name="padding" select="''" />
          <xvcd:with-param name="stars" select="$stars" />
        </xvcd:call-template>
      </pre>
    </body>
  </html>
</xvcd:template>

<!-- 再帰処理のルーチン  -->
<xvcd:template name="stars-str">
  <xvcd:param name="n" />
  <xvcd:if test="$n = 1">
    <xvcd:text>*</xvcd:text>
  </xvcd:if>
  <xvcd:if test="$n &gt; 1">
    <xvcd:call-template name="stars-str">
      <xvcd:with-param name="n" select="$n - 1"/>
    </xvcd:call-template>
    <xvcd:text>**</xvcd:text>
  </xvcd:if>
</xvcd:template>

<!-- 再帰処理のルーチン  -->
<xvcd:template name="pyr">
  <xvcd:param name="n" />
  <xvcd:param name="padding" />
  <xvcd:param name="stars" />

  <xvcd:if test="$n &gt;= 1">
    <xvcd:call-template name="pyr">
      <xvcd:with-param name="n" select="$n - 1"/>
      <xvcd:with-param name="padding" select="concat($padding,' ')" />
      <xvcd:with-param name="stars" select="substring($stars, 1, string-length($stars) -2)" />
    </xvcd:call-template>
<!-- '&#xa' -->
    <xvcd:value-of select="concat($padding, $stars, $padding)"/>
    <br/>
  </xvcd:if>
</xvcd:template>

</xvcd:xvcd>

« 2007-09-08 | トップページ | 2007-09-10 »

mokuji

2013年12月
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 31        

google

  • twitter
  • __
  • _
    Googleボットチェッカー

合わせて読む

  • 合わせて読む
    フィードメーター - katoy: cocolog あわせて読みたい

リンク