Category: Code
-
Going Mac – Part 1
Part of documenting my transition to web dev on Mac is to record what needs to be set up & configured. Should things ever go awry, this post could be a shortcut to getting back to a work-ready state. Apps etc installed The following needed to be installed manually. Xcode – via AppStore PHPStorm…
-
Going Mac – Part 0
I’ll soon be starting a new job, still in web development (as I have been for disturbingly more than a decade), though this time it’ll be in-house and for a huge company. I’ve been persuaded to go over to what I’ve long considered the dark side; Apple. I still don’t believe I’ll ever pay for…
-
WordPress config snippet for dynamic domains
Quite why this isn’t how WordPress works by default, I’ll probably never know. $domain = ‘http’ . (false ? ‘s’ : ”) . ‘://’ . $_SERVER[‘HTTP_HOST’]; define( ‘WP_SITEURL’, $domain ); define( ‘WP_HOME’, $domain ); If anything, this snippet is for my own reference. Prevents redirects on development / staging sites without changing the wp-config.php
-
Google Sheets Formula – show an age from a DOB
in CodeI couldn’t find a decent formula to show an age from a Date Of Birth, so I wrote this: =CONCAT(FLOOR((TODAY() – B2)/365),CONCAT(“y “,CONCAT(FLOOR((((TODAY() – B2)/365) – FLOOR(((TODAY() – B2)/365))) * 12), “m”))) Shows an age in years and months; e.g. “10y 6m”.
-
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!
-
CSS3: Rounded Table Corners (No images)
You cannot give a whole table (<table>) rounded corners using CSS, browsers will ignore it, you must round the corners of the cells (<td>) inside. The following uses CSS2 selectors (:first-child etc) and CSS3’s corner-rounding border-radius to selectively round the outer corners of the cells in the corners. This will work for any size table.…
-
PHP Bug: json_encode() misleading warning on object with private properties
I have found a peculiar issue with PHP’s json_encode() function. If you have an instance object with private properties and use json_encode() it will give you a very misleading warning. class ExampleObject { private $privateProperty; … } $obj = new ExampleObject(); json_encode($obj); results in Warning: json_encode() … recursion detected … There are two workarounds in…
-
BBC Homepage Beta Using jQuery
The BBC Beta Homepage is using jQuery, but unfortunately it’s ugly. I should qualify that – I think it’s a good move to make the homepage more personalisable, but does it have to look so Web2.0? Big text was a fad a year ago, but it’s too informal for an internationally recognised and respected news…