IPv6 validation - more caveats
Last week I was taking a nice hot bath while reading the Regular Expression Cookbook by Jan Goyvaerts and Steven Levithan. Really, there is no better way of relaxing
But then chapter 7.17 made me jump out of the tub, rush to my computer, and - while still wet - start typing the regular expression printed on page 387. The chapter was called 'Matching IPv6 Addresses'.
Read more »
Read more »
IPv6 validation (and caveats)
Recently we got a request to also match IPv6 addresses as a host-part for our auto-links. Basically this seemed pretty straight-forward, but it proved that actually validating an IPv6 address is quite difficult.
Read more »
Read more »
A new javascript minifier: JSMin+
For some time we have been looking for ways to minify the javascript and CSS files for Tweakers.net but were unable to find the right tool for this. If finding the right tool takes too much time there is only one other option: create your own tool, which is exactly what we did. Even better: we are releasing this tool to the public so you can use it too!
Read more »
Read more »
Formatting a multi-level menu using only one query
In the programming forum (dutch) on Gathering of Tweakers I often see people struggeling with multi-level menu's stored in a database and the formatting of such menu in HTML.
This is actually quite a common programming problem that can be solved using some kind of recursion or stack-based processing in order to create a tree out of a flat datastructure containing parent-child relations. However, in most cases the final solution that is presented involves seperate queries being executed inside a loop or inside a function that is called recursively which retrieves the child-elements for a specific parent. In situations where the menu has many items and/or has many levels this could easily result in dozens of queries being executed only to generate something simple as a treelike-output.
I would like to show you how this can be done using only a single query.
Read more »
This is actually quite a common programming problem that can be solved using some kind of recursion or stack-based processing in order to create a tree out of a flat datastructure containing parent-child relations. However, in most cases the final solution that is presented involves seperate queries being executed inside a loop or inside a function that is called recursively which retrieves the child-elements for a specific parent. In situations where the menu has many items and/or has many levels this could easily result in dozens of queries being executed only to generate something simple as a treelike-output.
I would like to show you how this can be done using only a single query.
Read more »
Is 100.000 times match() enough for you?
PHP 5.2 now comes with 2 new .ini directives:
code:
Although default disabled PHP will still force these defaults onto PCRE which will cause failure on common regular expressions fed on content that has more than 100.000 bytes.
Actually these settings map to PCRE's MATCH_LIMIT and MATCH_LIMIT_RECURSION directives, none of which have actually anything to do with backtracking in particular and which within PCRE are set to 10.000.000 by default...
update 23/12/2007: http://bugs.php.net/bug.php?id=40846 is the filed bugreport and this problem is still current.
code:
1
2
3
| [Pcre] ;pcre.recursion_limit=100000 ;pcre.backtrack_limit=100000 |
Although default disabled PHP will still force these defaults onto PCRE which will cause failure on common regular expressions fed on content that has more than 100.000 bytes.
Actually these settings map to PCRE's MATCH_LIMIT and MATCH_LIMIT_RECURSION directives, none of which have actually anything to do with backtracking in particular and which within PCRE are set to 10.000.000 by default...
update 23/12/2007: http://bugs.php.net/bug.php?id=40846 is the filed bugreport and this problem is still current.