Posts
-
Test data for date formatting unit tests
The other day I was looking over some unit tests for a date formatting code that handles both US and Australian locales, and noticed the test data being used - January 1. Not exactly a good choice, because even if your code is broken, the output looks the same as if it was working! My solution was to change it to use January 31 instead - because there’s no such thing as a 31st month! 😄 -
Debugging a timezone issue on a LAMP stack server
Dealing with timezones is the bane of my life as a developer, but on the other hand, I didn’t exactly make life easy for myself - when I setup my server a decade ago, I left it configured to run on the local timezone it was running it, which doesn’t match my local time or UTC time, causing all kinds of drama. The most recent one occured today, when I upgraded the PHP version, and all of a sudden my code is now mangling the time because it’s somehow confused about the timzeone. In this case “28/04/2024 16:15:02” should actually be showing 20:15 - my code runs on ‘Australia/Melbourne’ timezone but server had been configured on ‘America/New_York’, but for some reason it’s switched over to UTC, and now everything is a few hours out of whack. 😭 On first encountering the issue, I swore I’ve seen it before, but unforutnatly I didn’t document it - but then I realised what was going on - each version of PHP has it’s own copy of php.ini, and that has a ‘date.timezone’ directive against it. So you need to update the timezone directive in each file, and I happen to be using both CLI and FPM favours. With that lead, I made the change - but unfortunately updating the php.ini timezone config for the FPM flavour then restarting Apache web server hasn’t fixed the display of times. My next theory was that FastCGI Process Manager (FPM) mode in PHP doesn’t care about Apache being restarted - so time to reboot the server instead. And tada - then it worked. 🎉 Moral of the story - run your server on UTC time and convert to local time on the way out to the user. -
Fixing a 'Packages with upgradable origin but kept back' error on Ubuntu
After a recent upgrade of my Ubuntu server, every time I tried to run apt-get upgrade I ran into a mysterious error - "Packages with upgradable origin but kept back". So how to fix it? -
Caught out by Web.Config Inheritance
When I’m doing web development in the ASP.NET ecosystem, Web.Config files are something I’m aware of, but have been lucky enough to avoid becoming an expert on. However after a recent clean up task broke our staging environment immediately after I landed it, I ended up deep in the details of how Web.Config values are used by the framework, and a feature I had hazy recollections of - Web.Config inheritance. -
PagerDuty Incident Responder Training
I recently added a session on “Incident Responder Training” by PagerDuty - a company who runs a SaaS incident response platform. So what did I get out of it?
subscribe via RSS