Archive for January, 2009

WatchThis: Let the Right One In

Must see, really cool take on the topic. Complete with disturbing images of a north-european distopian, snowcovered town ;)

Far better than the twilight movie, which sucked (i liked the book though, i read all four).

xslt sample: factorial (named template)

Currently learning for an exam and freshing up my XSLT knowledge … ;)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!--
    ! Small XSLT prog that calculates the faculty of one or more
    ! numbers by recursively calling a named template
    ! numbers are expected to be in a tree:
    ! <nums><num>1</num><num>2</num>...</nums>
   -->

  <xsl:output method="text"/>

  <xsl:template match="num">
      <xsl:text>fak(</xsl:text>
      <xsl:value-of select="."/>
      <xsl:text>) is </xsl:text>
      <xsl:call-template name="fak">
          <xsl:with-param name="number" select="."/>
      </xsl:call-template>
  </xsl:template>

  <xsl:template name="fak">
      <xsl:param name="number"/>
      <xsl:choose>
          <xsl:when test="$number = 1">
              <xsl:value-of select="$number"/>
          </xsl:when>
          <xsl:otherwise>
              <xsl:variable name="recursefak">
                  <xsl:call-template name="fak">
                      <xsl:with-param name="number" select="$number - 1"/>
                  </xsl:call-template>
              </xsl:variable>
              <xsl:value-of select="$number * $recursefak"/>
          </xsl:otherwise>
      </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

Expected XML looks like this (with DTD even! ;P):

<?xml version="1.0" ?>
<!DOCTYPE numbers [
  <!ELEMENT nums (num+)>
  <!ELEMENT num (#PCDATA)>
]>
<nums>
  <num>3</num>
  <num>12</num>
</nums>

… better than vista

i seldomly laugh out loud when reading something … but this made my day ;)

Windows 7
XKCD 528 <img alt=“Disclaimer: I have not actually tried the beta yet. I hear it’s quite pleasant and hardly Hitler-y at all.”>

ps) i saw the (leaked) beta in vmware and it actually was quite nice ;)
pps) the horde on webspace (no shell) guide will be delayed until my host decides to fix his PHP installation (imap_open() is broken…)