2012-07-30

Using The PHP 5.4 Webserver On Windows

Starting a server from the command line
PHP 5.4 has an built-in webserver. For local development it is not necessary to install Apache Httpd or another webserver anymore. You can just start an server from the command line.

Change the directory to your project directory. The argument -S starts the webserver. You need to specify a host and a port. All requests are shown in the console window.

A Shortcut

To make things a little easier you can create a windows shortcut. This allows you to change the console window size, font and color, too. The following pictures show the particular steps:
Step 1: Create A Shortcut
Step 2: Select the PHP binary
Step 3: Name the shortcut
Step 4: Change command and working directory
Step 5: Change the window size

2012-07-14

Matching Classes In XSLT

A while ago (well 2 years) I posted an entry about the differences between CSS selectors and Xpath expressions. An simple ".classname" in CSS is a noisy "contains(concat(' ', normalize-space(@class), ' '), ' first ')" in Xpath.

In XSLT this adds a lot of overhead. But if your XSLT processor supports EXSLT you are able to encapsulate it into a function.

I put this into a file "contains-token.xsl".


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:func="http://exslt.org/functions"
  extension-element-prefixes="func"
>
<func:function name="func:contains-token">
  <xsl:param name="haystack">
  <xsl:param name="needle">
  <xsl:variable name="normalizedHaystack" select="concat(' ', normalize-space($haystack), ' ')"/>
  <xsl:variable name="normalizedNeedle" select="concat(' ', normalize-space($needle), ' ')"/>
  <func:result select="$needle != '' and contains($haystack, $needle)"/>
</func:function>

</xsl:stylesheet>


You need to declare the func namespace and define it as an extension prefix. The function definition is not unlike an normal template definition. You just have to use the "func:function" and "func:result" elements. Function always need to be inside an namespace. If in doubt, just use the "func" namespace itself.

In this case I normalize both parameters first and just validate if the haystack contains the needle.

Now it is possible to import the function and use it.


...
<xsl:import href="../functions/contains-token.xsl"/>

<xsl:template match="/">
  ...
  <xsl:value-of select=".//div[func:contains-token(@class, 'classname')]"/>
  ...
</xsl:template>
...


It is still longer then the CSS version but it is a lot more readable.


2012-04-19

Twin Stem Adapters

I don't like the standard Brompton handlebar. They are to short and to flexible. They are so short that I had to cut of a considerable amount of the right grip to fit the brake lever and the shifter. Not an ideal situation. The S Type is to low for me. One of the users in the German Bromptonauten forum posted an image of his modification. An M Type stem with a stem adapter raising a standard flat handlebar.

So I replaced the M Type stem on my Brompton with an H Type. It is 6cm higher, but the hinge is higher, too. I tested three stem adapters.



TranzX double clamp adapter SATORI Aberhallo Adjustable Stem GUB G-80 folding bike stem
Images
Distance 50 mm 50 mm 55 mm
Weight 188g 198g 141g
Colors black black red, silver, blue, black, gold
Remove Grip and break lever for assembly No No Yes


H Type stem, GUB G-80 adapter and flat handle bar
The major disadvantage of the TranzX adapter are the clamps above the handle bar. The GUB adapter is similiar but the clamps are at the bottom and smaller. The Aberhallo adapter has a different design - it is the most flexible. TranxZ and Aberhallo use plastic barends, but the GUB has threaded aluminium barends, providing a small storage space.

For now I am using the GUB G-80. The 5mm more make a difference (no conflict with the mudguard stay) and I like the look of the bands at the handle bar.

The handle bar is 1 meter from the ground and 8 cm lower then the saddle.
x