Feed aggregator
North Yorkshire Apostrophe Fans Demand Road Signs With Nowt Taken Out
Read more of this story at Slashdot.
Google is Changing How You Set Up 2FA
Read more of this story at Slashdot.
40,000 AI-Narrated Audiobooks Flood Audible
Read more of this story at Slashdot.
Poorer Nations Must Be Transparent Over Climate Spending, Says Cop29 Leader
Read more of this story at Slashdot.
Police Resurrect Lockbit's Site and Troll the Ransomware Gang
Read more of this story at Slashdot.
PlayStation Reverses Course on Helldivers 2 PSN Account Requirement
Read more of this story at Slashdot.
Microsoft Readies New AI Model To Compete With Google, OpenAI
Read more of this story at Slashdot.
More Than 90% of Stablecoin Transactions Aren't From Real Users, Visa Study Finds
Read more of this story at Slashdot.
In Argentina, Facing Surging Inflation, 500K Accept Worldcoin's Offer of $50 for Iris-Scanning
Read more of this story at Slashdot.
Elon Musk's X Launches Grok AI-Powered 'Stories' Feature
Read more of this story at Slashdot.
CodeSOD: Spaced Out Replacement
You have some text, and need to replace every sequence of spaces with a single space. E.g., My text becomes My text. Now, if you're most of us, you ignore the famous quote and reach straight for regexes.
But Samuel's co-worker isn't most of us.
toReturn = toReturn.Replace(" ", " "); toReturn = toReturn.Replace(" ", " ").Replace(" ", " ").Replace(" ", " ").Replace(" ", " ");What I love about this is you can see the programmer gradually understanding the problem better, right here in the code.
Now, this is C#, where Replace replaces all occurences.
They start with one line: if there are two spaces, replace them with one. Oops, except, they can't count, and they actually write instructions to replace one space with one space.
Okay, that didn't work, let's try again. Let's replace two spaces with one space. Hey, that's got us partway there, but if, for example, we've got three or four spaces, this still leaves us with two spaces. Okay, let's just add another replace. Great, but oh wait, what if we have six spaces? The first replace knocks us down to three, the second to two, so we need a third one.
And so this developer kept adding Replace calls until the spaces got down to the count they expected. Here's hoping they never get a string with more contiguous spaces than this block can handle.
Then again, what's the worst that happens? They just need to add another Replace(" ", " "). Easy.
[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.How 'Star Wars' was Influenced by San Francisco - and Architecture
Read more of this story at Slashdot.
Scientists Find a 'Missing Link' Between Poor Diet and Higher Cancer Risk
Read more of this story at Slashdot.
Microsoft's 'Responsible AI' Chief Worries About the Open Web
Read more of this story at Slashdot.
Can Technology Help Reduce Drunk-Driving Deaths?
Read more of this story at Slashdot.
America's Federal Regulators Are Preparing More Lawsuits Against Crypto Companies
Read more of this story at Slashdot.
Could Better Data Protections Reduce Big Tech's Polarizing Power?
Read more of this story at Slashdot.
Some San Francisco Tech Workers are Renting Cheap 'Bed Pods'
Read more of this story at Slashdot.
AI-Operated F-16 Jet Carries Air Force Official Into 550-MPH Aerial Combat Test
Read more of this story at Slashdot.
Will Calls to Scrutinize Digital-Currency Purchases of Oil Bring New Regulations For Crypto?
Read more of this story at Slashdot.