Computer
$42 Billion Broadband Grant Program May Scrap Biden Admin's Preference For Fiber
Read more of this story at Slashdot.
Red Hat Plans to Add AI to Fedora and GNOME
Read more of this story at Slashdot.
Amazon, King of Online Retail, Can't Seem To Make Its Physical Stores Work
Read more of this story at Slashdot.
Cruise To Slash Workforce By Nearly 50% After GM Cuts Funding To Robotaxi Operations
Read more of this story at Slashdot.
Panasonic To Cut Costs To Support Shift Into AI
Read more of this story at Slashdot.
Americans Kiss Job Hopping Goodbye
Read more of this story at Slashdot.
Microsoft Quietly Makes It Harder To Install Windows 11 on Old PCs Ahead of Windows 10's End of Support
Read more of this story at Slashdot.
Lung Cancer Diagnoses On the Rise Among Never-Smokers Worldwide
Read more of this story at Slashdot.
Chris Anderson Is Giving TED Away To Whoever Has the Best Idea for Its Future
Read more of this story at Slashdot.
Microsoft Veteran Ponders World Where Toothbrushes Need Reboots
Read more of this story at Slashdot.
China Launches Antitrust Investigation Into Google
Read more of this story at Slashdot.
Popular Linux Orgs Freedesktop, Alpine Linux Are Scrambling For New Web Hosting
Read more of this story at Slashdot.
AI Systems With 'Unacceptable Risk' Are Now Banned In the EU
Read more of this story at Slashdot.
CodeSOD: Device Detection
There are a lot of cases where the submission is "this was server side generated JavaScript and they were loading constants". Which, honestly, is a WTF, but it isn't interesting code. Things like this:
if (false === true) { // do stuff }That's absolutely the wrong way to do that, and I hate it, but there's just so many times you can say, "send server-side values to the client as an object, not inline".
But Daniel's electrical provider decided to come up with an example of this that really takes it to the next level of grossness.
var isMobile = "" === "true"; var isAndroid = "" === "true"; var isIPad = "" === "true"; var isIPhone = "" === "true";For starters, they're doing device detection on the server side, which isn't the worst possible idea, but it means they're relying on header fields or worse: the user agent string. Maybe they're checking the device resolution. The fact that they're naming specific devices instead of browser capabilities hints at a terrible hackjob of reactive webdesign- likely someone wrote a bunch of JavaScript that alters the desktop stylesheet to cram the desktop site onto a mobile device. But that's just background noise.
Look at that code.
First, we've got some lovely order-of-operations abuse: === has higher precedence than =, which makes sense but hardly makes this code readable. The first time I saw this, my brain wanted the assignment to happen first.
But what's really special to me is the insistence on making this stringly typed. They control both sides of the code, so they could have just done booleans on both sides. And sure, there's a world where they're just dumb, or didn't trust their templating engine to handle that well.
I've seen enough bad code, though, to have a different suspicion. I can't confirm it, but c'mon, you know in your hearts this is true: the function which is doing device detection returns a string itself, and that string isn't always a boolean for some reason. So they needed to wrap the output in quotes, because that was the only way to make sure that the JavaScript actually could be executed without a syntax error.
I can't be sure that's true from this little snippet. But look at this code, and tell me that someone didn't make that mistake.
.comment { border: none; } [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.Salesforce Cutting 1,000 Roles While Hiring Salespeople for AI
Read more of this story at Slashdot.
CERN's Mark Thomson: AI To Revolutionize Fundamental Physics
Read more of this story at Slashdot.
Bonobos Can Tell When They Know Something You Don't
Read more of this story at Slashdot.
Senator Hawley Proposes Jail Time For People Who Download DeepSeek
Read more of this story at Slashdot.
TSA's Airport Facial-Recognition Tech Faces Audit Probe
Read more of this story at Slashdot.
Judge Denies Apple's Attempt To Intervene In Google Search Antitrust Trial
Read more of this story at Slashdot.