Feed aggregator
UnitedHealth Now Has 1,000 AI Applications In Production
Read more of this story at Slashdot.
Messaging App Used by Mike Waltz, Trump Deportation Airline GlobalX Both Hacked in Separate Breaches
Read more of this story at Slashdot.
Hundreds of E-Commerce Sites Hacked In Supply-Chain Attack
Read more of this story at Slashdot.
Microsoft Shuts Down Skype
Read more of this story at Slashdot.
OpenAI Reverses Course, Says Its Nonprofit Will Remain in Control of Its Business Operations
Read more of this story at Slashdot.
Microsoft Cracks Down On Bulk Email With Strict New Outlook Rules
Read more of this story at Slashdot.
Beijing's 'Made in China' Plan Is Narrowing Tech Gap, Study Finds
Read more of this story at Slashdot.
Apple Will Appeal Contempt Ruling in Epic Games Case Over App Store
Read more of this story at Slashdot.
UAE Rolls Out AI for Schoolkids
Read more of this story at Slashdot.
A Look at the NYC Subway's Archaic Signal System
Read more of this story at Slashdot.
Budget Titles Dominate 2025's Top-Rated Games as AAA Prices Climb To $80
Read more of this story at Slashdot.
Majority in UK Now 'Self-Identify' as Neurodivergent
Read more of this story at Slashdot.
Has Meta Figured Out How to Monetize AI - By Using It For Targeted Advertising?
Read more of this story at Slashdot.
Class Action Accuses Toyota of Illegally Sharing Drivers' Data
Read more of this story at Slashdot.
CodeSOD: A Double Date
Alice picked up a ticket about a broken date calculation in a React application, and dropped into the code to take a look. There, she found this:
export function calcYears(date) { return date && Math.floor((new Date() - new Date(date).getTime()) / 3.15576e10) }She stared at it for awhile, trying to understand what the hell this was doing, and why it was dividing by three billion. Also, why there was a && in there. But after staring at it for a few minutes, the sick logic of the code makes sense. getTime returns a timestamp in milliseconds. 3.15576e10 is the number of milliseconds in a year. So the Math.floor() expression just gets the difference between two dates as a number of years. The && is just a coalescing operator- the last truthy value gets returned, so if for some reason we can't calculate the number of years (because of bad input, perhaps?), we just return the original input date, because that's a brillant way to handle errors.
As bizarre as this code is, this isn't the code that was causing problems. It works just fine. So why did Alice get a ticket? She spent some more time puzzling over that, while reading through the code, only to discover that this calcYears function was used almost everywhere in the code- but in one spot, someone decided to write their own.
if (birthday) { let year = birthday?.split('-', 1) if (year[0] != '') { let years = new Date().getFullYear() - year[0] return years } }So, this function also works, and is maybe a bit more clear about what it's doing than the calcYears. But note the use of split- this assumes a lot about the input format of the date, and that assumption isn't always reliable. While calcYears still does unexpected things if you fail to give it good input, its accepted range of inputs is broader. Here, if we're not in a date format which starts with "YYYY-", this blows up.
After spending hours puzzling over this, Alice writes:
I HATE HOW NO ONE KNOWS HOW TO CODE
[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.After Reddit Thread on 'ChatGPT-Induced Psychosis', OpenAI Rolls Back GPT4o Update
Read more of this story at Slashdot.
'Star Wars Day' Celebrations Hit Fortnite, Disney+, X.com - and Retailers Everywhere
Read more of this story at Slashdot.
The UN Ditches Google for Form Submissions, Opts for Open Source 'CryptPad' Instead
Read more of this story at Slashdot.
'Harassed by Assasin's Creed Gamers, A Professor Fought Back With Kindness'
Read more of this story at Slashdot.
Disneyland Imagineers Defend New Show Recreating Walt Disney as a Robot
Read more of this story at Slashdot.