Irregular Expressions have your stack for lunch

I love me some regular expressions (problems), but have you ever seen one crash Apache? Well I have! This regex is part of YUI-CSS-compressor-PHP-port, the external CSS minification component in Autoptimize, my WordPress JS/CSS optimization plugin:
/(?:^|\})(?:(?:[^\{\:])+\:)+(?:[^\{]*\{)/)/
yo regex dawgExecuting that on a large chunk of CSS (lots of selectors for one declaration block, which cannot be ripped apart) triggers a stack overflow in PCRE, which crashes Apache and shows up as a “connection reset”-error in the browser.
Regular expression triggered segfaults are no exception in the PHP bugtracker and each and every of those tickets gets labeled “Not a bug” while pointing the finger at PCRE, which in their man-pages and in their bug tracker indeed confirm that stack overflows can occur. This quote from that PCRE bug report says it all, really;

If you are running into a problem of stack overflow, you have the
following choices:
  (a) Work on your regular expression pattern so that it uses less
      memory. Sometimes using atomic groups can help with this.
  (b) Increase the size of your process stack.
  (c) Compile PCRE to use the heap instead of the stack.
  (d) Set PCRE's recursion limit small enough so that it gives an error
      before the stack overflows.

Are you scared yet? I know I am. But this might be a consolation; if you test your code on xampp (or another Apache on Windows version), you’re bound to detect the problem early on, as the default threadstacksize there is a mere 1MB instead of the whopping 8MB on Linux.
As for the problem in YUI-CSS-compressor-PHP-port; I logged it on their Github issue-list and I think I might just have a working alternative which will be in Autoptimize 1.8.

Android battery drain no more!

Battery drain is a known problem for us smartphonista’s, especially if you’ve got multiple applications (sometimes secretly) connecting to the internet to get and/or push data.
Although the battery of my Samsung Galaxy SII lasted approximately 1 day (which I considered a success, after having battled Firefox Sync, Soundcloud and Exchange mail fetching), a couple of weeks ago I started to manually disable the data network mode at night. Who needs their phones online all of the time after all? This worked like a charm, which made me start thinking about an application that could automate toggling of the data connection. I did a quick search on the web and found this article on Stack Overflow with sample code to access the (hidden) dataconnection API’s.
While reading the comments I understood I didn’t need to find me someone to build such an application; Juice Defender does just that. The basic version is free and although it allows only limited configuration, just activating it with default settings almost doubled my SGS II’s battery life. So if you want your Android phone’s battery to last longer, you really should try out Juice Defender.