Regex to split “){” to two lines, retaining indenting

I was quite proud to come up with this, so here’s my first blog post for a while:

Search:
^([^\S\n]*)(.+))\s*{

Replace:
$1$2)\n$1{

and as a bonus:
^([^\S\n]*)}\s*else\s*{
$1}\n$1else\n$1{

NB (2013-09): it seems that the escaping slashes in this post were lost  at some point, I’ve put them back, but not tested!

JavaScript Bug – Modulo of small numbers

It seems that there is a problem with the modulo function, ‘%’, in JavaScript.

For example: 10 % 0.1 should equate to zero but comes out as 0.09999999999999945 probably due to some internal floating-point rounding errors.

Easy solution (a hack really): Multiply both numbers by 1000 before using the modulo function.

IE7 Tip – Reload

IE7 Tip - ReloadWhen IE7 was designed they took the peculiar decision to split the navigation buttons into three places (if you include the home button).

If you find yourself up in the top left wanting to reload, just click the drop-down button and select the current page (will be highlighted and have a tick-mark on the left), as shown in the picture.

Bizarrely and unfortunately, this only works if you’re not looking at the last page in your navigation history for this tab. This suggests that it’s only through poor programming logic that it works at all.

[tags]IE,IE7,Microsoft,tip,tips,browser,flaw,bug[/tags]