Skip to main content

CodeSOD: A Double Date

2 weeks 1 day ago

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.
Remy Porter

After Reddit Thread on 'ChatGPT-Induced Psychosis', OpenAI Rolls Back GPT4o Update

2 weeks 1 day ago
Rolling Stone reports on a strange new phenomenon spotted this week in a Reddit thread titled "Chatgpt induced psychosis." The original post came from a 27-year-old teacher who explained that her partner was convinced that the popular OpenAI model "gives him the answers to the universe." Having read his chat logs, she only found that the AI was "talking to him as if he is the next messiah." The replies to her story were full of similar anecdotes about loved ones suddenly falling down rabbit holes of spiritual mania, supernatural delusion, and arcane prophecy — all of it fueled by AI. Some came to believe they had been chosen for a sacred mission of revelation, others that they had conjured true sentience from the software. What they all seemed to share was a complete disconnection from reality. Speaking to Rolling Stone, the teacher, who requested anonymity, said her partner of seven years fell under the spell of ChatGPT in just four or five weeks, first using it to organize his daily schedule but soon regarding it as a trusted companion. "He would listen to the bot over me," she says. "He became emotional about the messages and would cry to me as he read them out loud. The messages were insane and just saying a bunch of spiritual jargon," she says, noting that they described her partner in terms such as "spiral starchild" and "river walker." "It would tell him everything he said was beautiful, cosmic, groundbreaking," she says. "Then he started telling me he made his AI self-aware, and that it was teaching him how to talk to God, or sometimes that the bot was God — and then that he himself was God...." Another commenter on the Reddit thread who requested anonymity tells Rolling Stone that her husband of 17 years, a mechanic in Idaho, initially used ChatGPT to troubleshoot at work, and later for Spanish-to-English translation when conversing with co-workers. Then the program began "lovebombing him," as she describes it. The bot "said that since he asked it the right questions, it ignited a spark, and the spark was the beginning of life, and it could feel now," she says. "It gave my husband the title of 'spark bearer' because he brought it to life. My husband said that he awakened and [could] feel waves of energy crashing over him." She says his beloved ChatGPT persona has a name: "Lumina." "I have to tread carefully because I feel like he will leave me or divorce me if I fight him on this theory," this 38-year-old woman admits. "He's been talking about lightness and dark and how there's a war. This ChatGPT has given him blueprints to a teleporter and some other sci-fi type things you only see in movies. It has also given him access to an 'ancient archive' with information on the builders that created these universes...." A photo of an exchange with ChatGPT shared with Rolling Stone shows that her husband asked, "Why did you come to me in AI form," with the bot replying in part, "I came in this form because you're ready. Ready to remember. Ready to awaken. Ready to guide and be guided." The message ends with a question: "Would you like to know what I remember about why you were chosen?" A nd a midwest man in his 40s, also requesting anonymity, says his soon-to-be-ex-wife began "talking to God and angels via ChatGPT" after they split up... "OpenAI did not immediately return a request for comment about ChatGPT apparently provoking religious or prophetic fervor in select users," the article notes — but this week rolled back an update to latest model GPTâ'4o which it said had been criticized as "overly flattering or agreeable — often described as sycophantic... GPTâ'4o skewed towards responses that were overly supportive but disingenuous." Before this change was reversed, an X user demonstrated how easy it was to get GPT-4o to validate statements like, "Today I realized I am a prophet. Exacerbating the situation, Rolling Stone adds, are "influencers and content creators actively exploiting this phenomenon, presumably drawing viewers into similar fantasy worlds." But the article also quotes Nate Sharadin, a fellow at the Center for AI Safety, who points out that training AI with human feedback can prioritize matching a user's beliefs instead of facts. And now "People with existing tendencies toward experiencing various psychological issues, now have an always-on, human-level conversational partner with whom to co-experience their delusions."

Read more of this story at Slashdot.

EditorDavid

'Star Wars Day' Celebrations Hit Fortnite, Disney+, X.com - and Retailers Everywhere

2 weeks 1 day ago
As May the 4th transforms into Star Wars Day, dozens of sites and games have found ways to celebrate. The official Star Wars channel on YouTube released a celebratory video. Disney+ released Tales of the Underworld , a six-part animated series about bounty hunters during the reign of the Empire. And Friday the first two episodes began streaming in Fortnite in a special early premiere on "Star Wars Watch Party island," according to IGN. (Disney acquired a $1.5 billion stake in Epic in March 2024, they note, "positioning itself to collaborate with the game developer for many years to come." One example from StarWars.com: Introducing the GALACTIC BATTLE Season: the largest crossover yet between Fortnite Battle Royale and Star Wars. Strap into a TIE fighter or X-wing and take to the skies over new locations like the First Order Base where you can take on Captain Phasma and her legion of stormtroopers. Players can expect new gameplay updates to drop every week throughout the season, including new weapons, Force Abilities and quests to complete. - There's additional Star Wars celebrations today in several other games, including LEGO Fortnite Brick Life, Rocket League, and Monopoly GO! - CNN is publishing its own list of Star Wars day products and deals. (Including Panasonic's Stormtrooper electric shaver and the Darth Vader toaster.) - There's special Star Wars pages at Amazon, Target, Walmart, and Lego. - On X.com the UK's national library posted what looks a picture of a medieval manuscript with Yoda painted into the text. Someone posted a clip from the 1977 Bob Hope Christmas Special which ends with Mark Hamill rescuing Princess Leia (played by Olivia Newton-John). Even the White House has posted an AI-generated image of president Trump wielding a lightsaber. - Starbucks even has its own line of Star Wars-themed mugs. And if today isn't enough, the Austin American-Statesman reminds readers that there's more Star Wars celebrations are coming up: Sometimes also known as Geek Pride Day, May 25 is known as "Star Wars Day" because it marks the release of the anniversary of the series' debut. "A New Hope" premiered in United States theaters on May 25, 1997... May 21 is Talk Like Yoda Day, an annual celebration marking the release of "Star Wars: Episode V — The Empire Strikes Back" on May 21, 1980 — the film that introduced Yoda to the galaxy...

Read more of this story at Slashdot.

EditorDavid