British schoolboy, 14, killed in skiing accident in northern Italy
Was licence fee payers' cash given to Hamas? Kemi Badenoch writes to BBC boss demanding action over Gaza documentary scandal
Putin 'SACRIFICED his sailors to protect his nuclear secrets' in when Russian submarine sinking killed 118: Then-US President Bill Clinton reveals all about Kursk disaster for the first time
Colin Farrell thanks sister Claudine for the first time EVER in sweet bonding moment with 2025 SAG Awards win
Body found by police looking for missing runner Jenny Hall on sixth day of the search
Royal aide at centre of Meghan Markle 'bullying' allegations finally breaks his silence
A12 delays after incident partially blocks road- recap
Timothee Chalamet's grief-stricken girlfriend Kylie Jenner skips SAG Awards and his mom steps in as date
Naked Patrick Schwarzenegger creeps out White Lotus fans again with 'happy ending' massage and incest storyline
Jane Fonda savages Trump during SAG Life Achievement Award speech
Daniel Craig cuts a seriously sharp figure in a black satin tuxedo as he makes a dapper arrival at the SAG Awards after Best Actor nomination
Truth about Jane Fonda's 'uncomfortable' SAG Awards 2025 red carpet moment as 'dazed' actress sparks concern
2025 SAG Awards WINNERS: Demi Moore triumphs as Timothee Chalamet has shock win but Conclave takes top honor
Political guru predicts Trump White House will COLLAPSE within 30 days
We're getting a Hooters but we don't care about feminist complaints over the scantily-clad waitresses - we'll give anything a go in our city!
Millie Bobby Brown exudes elegance in peach satin gown as she puts on a loved-up display with husband Jake Bongiovi at the 2025 SAG Awards
Migrant powder keg: Turmoil in Ireland amid 300% rise in asylum seekers with violence as machete attacks and drug-fuelled brawls become the new normal on the streets of Dublin
RFK Jr.'s comments about black people and vaccines sparks warning from top doctors
CodeSOD: Uniquely Expressed
Most of us, when generating a UUID, will reach for a library to do it. Even a UUIDv4, which is just a random number, presents challenges: doing randomness correctly is hard, and certain bits within the UUID are reserved for metadata about what kind of UUID we're generating.
But Gretchen's co-worker didn't reach for a library. What they did reach for was… regular expressions?
function uuidv4() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8; return v.toString(16); }); }At a glance, this appears to be a riff on common answers on Stack Overflow. I won't pick on this code for not using crypto.randomUUID, the browser function for doing this, as that function only started showing up in browsers in 2021. But using a format string and filling it with random data instead of generating your 128-bits as a Uint8Buffer is less forgivable.
This solution to generating UUIDs makes a common mistake: confusing the representation of the data with the reality of the data. A UUID is 128-bits of numerical data, with a few bits reserved for identification (annoyingly, how many bits are reserved depends on which format we're talking about). We render it as the dash-separated-hex-string, but it is not a dash-separated-hex-string.
In the end, this code does work. Awkwardly and inefficiently and with a high probability of collisions due to bad randomness, but it works. I just hate it.
Maps of terrestrial fibre networks aren’t great. The Internet Society wants to fix that
APRICOT 2025 The Internet Society wants to help improve maps that depict terrestrial optic fibre networks by having regulators and carriers alike promote and adopt the Open Fibre Data Standard it helped to create.…