MG reveals its stylish new 4 EV - but Britons won't be able to buy it
Wildly popular Taiwanese bubble tea brand to launch two new stores in border Essex towns
Ethically Sourced 'Spare' Human Bodies Could Revolutionize Medicine
Read more of this story at Slashdot.
James Packer splurges a whopping $174million on an enormous seven bedroom mansion in Los Angeles that was once the home of supermodels Gigi and Bella Hadid
Representative Line: Time for Identification
If you need a unique ID, UUIDs provide a variety of options. It's worth noting that variants 1, 2, and 7 all incorporate a timestamp into the UUID. In the case of variant 7, this has the benefit of making the UUID sortable, which can be convenient in many cases (v1/v2 incorporate a MAC address which means that they're sortable if generated with the same NIC).
I bring this up because Dave inherited some code written by a "guru". Said guru was working before UUIDv7 was a standard, but also didn't have any problems that required sortable UUIDs, and thus had no real reason to use timestamp based UUIDs. They just needed some random identifier and, despite using C#, didn't use the UUID functions built in to the framework. No, they instead did this:
string uniqueID = String.Format("{0:d9}", (DateTime.UtcNow.Ticks / 10) % 1000000000);A Tick is 100 nanoseconds. We divide that by ten, mod by a billion, and then call that our unique identifier.
This is, as you might guess, not unique. First there's the possibility of timestamp collisions: generating two of these too close together in time would collide. Second, the math is just complete nonsense. We divide Ticks by ten (converting hundreds of nanoseconds into thousands of nanoseconds), then we mod by a billion. So every thousand seconds we loop and have a risk of collision again?
Maybe, maybe, these are short-lived IDs and a thousand seconds is plenty of time. But even if that's true, none of this is a good way to do that.
I suppose the saving grace is they use UtcNow and not Now, thus avoiding situations where collisions also happen because of time zones?
Yet another tourist is wheeled out of a Bali sports bar in a trolley as Australia's favourite holiday destination continues to be plagued by series of troubling incidents
ALISON BOSHOFF: The jaw-dropping details that mean Jeff Bezos's wedding to Lauren Sanchez in Venice will make George Clooney's look like a modest affair
The Essex farm shop with humble beginnings that's now residents' favourite place
Elementary school teacher arrested for 'exposing himself to students and peeing in can in classroom'
Married teacher gets prison makeover after asking underage boys in Scream masks to 'gangbang' her
Trump considers shock reparations plan for hundreds that were 'treated very unfairly' under Biden
Famous Essex singer was 'hurt' when he lost out on winning a prestigious award
Famous Essex singer was 'hurt' when he lost out on winning a prestigious award
Police respond after businesses outraged at youth crime in Witham
Fire at waste recycling site caused by battery, fire service says
Woman lost 11 stone by making 'little changes' after doctor warned her she wouldn't lead a full life'
The huge change made to royal portrait of Queen Mary and King Frederik: 'It's never been done before'
Oprah Winfrey dragged into major hip-hop star's rape case
Married With Children actress dies suddenly at 58
Open Source Devs Say AI Crawlers Dominate Traffic, Forcing Blocks On Entire Countries
Read more of this story at Slashdot.