UUID
type_safe
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
UUID
-
Weekly help thread
I'd recommend using either Ramsey/uuid or generating a random number using random_bytes(32) then compressing it. 32 bits of randomness should be sufficient for most programs.
-
eli5 With billions and billions of people over time, how can fingerprints be unique to each person. With the small amount of space, wouldn’t they eventually have to repeat the pattern?
Of course, theoretical math and applied math often work out differently. Here's a thread with a guy claiming his team's software is running into "Several hundred [UUID] collisions per day"
-
weird php results microtime/hrtime
Or just use a library.
-
UUIDs are a wonderful invention
I'll leave this here https://github.com/ramsey/uuid/issues/80
-
What are types of bugs that only show up after thousands or millions of times of the code being run.
Not really in the realm of “thousands” of runs, but UUID collisions are possible and have been observed multiple times after only 1 million generations due to unknown reasons.
- Generating unique key code using PHP
-
Sortable Collision-Free UUIDs
There's also the risk of bad randomness sources and/or bugs.
One popular UUID library got a bug report stating: "We are generating about 1M UUID4 a day, and we are getting several hundred collisions a day". And so they were; turned out to be a bug/weird interaction between the OpenSSL library they were using for randomness and forking. (Details here, although it was all fixed years ago of course: https://github.com/ramsey/uuid/issues/80)
On paper, you should never, ever, ever see a collision when generating a mere million v4 UUIDs a day, much less hundreds of collisions. But that doesn't mean it can't happen!
This is also an interesting bit of analysis; comes from a company that processed a lot of UUIDs generated in browsers, checked, and discovered about 5 collisions per million UUIDs. Again, not what you'd naively expect! (Turned out to be mostly driven by misbehaving crawlers.) https://medium.com/teads-engineering/generating-uuids-at-sca...
-
Things You Should Do Now
just make sure you have everything configured correctly on your system if using UUIDs:
https://github.com/ramsey/uuid/issues/80
In the types of systems that need UUIDs there is probably no easy way to check for collisions. The prospect of mystery data corruption with no ability to trace it down frightens the hell out of me.
The only reason that issue was reported is because someone was actually doing the collision checking. That's not going to be the norm in UUID systems. Think about it.
-
A UUID can have so many combinations that UUIDs are effectively unique. But it's possible to generate the same one twice, however small the chance. Is it best practice to take this chance into account, checking to be sure you haven't used it?
In theory the risk of collision is so small it can be written off, but implementations can have bugs.
type_safe
-
Why is this piece of code compiling with char as c-tor argument?
Yep. And there are some libraries to provide strong-type int, depending on what you need: type_safe or even units.
-
its okay guys they fixed it!
Which programming language has, by default, a float type between 0.0 and 1.0? I think it is solvable with libraries in some languages, sure, but it is there in the type system or the standard library of some mainstream language?
-
Optional output arguments
Consider taking a look at the type_safe library https://github.com/foonathan/type_safe which has an output_parameter type
-
Integer Conversions and Safe Comparisons in C++20
foonathan/type_safe provides wrappers around standard types that prevent most of the unwanted implicit conventions. Also it provides backport of safe comparasions on C++11 and C++14
- How to make "stronger" types in C++ (easily)
-
Things You Should Do Now
I agree, the 'microtype' pattern can be a good way of getting the type-checker to catch silly mistakes.
In Ada it's standard practice. In C++ you really need a library to do it easily, but there's a good one out there ready to go:
https://github.com/foonathan/type_safe/
What are some alternatives?
cuid - Collision-resistant ids optimized for horizontal scaling and performance.
php-ulid - A PHP port of alizain/ulid with some minor improvements.
woo-besluit-broncode-digid-app
ulid - Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3
FizzBuzz Enterprise Edition - FizzBuzz Enterprise Edition is a no-nonsense implementation of FizzBuzz made by serious businessmen for serious business purposes.
ksuid - Java implementation of K-Sortable Globally Unique IDs
mp-units - The quantities and units library for C++
Slugify - Converts a string to a slug. Includes integrations for Symfony, Silex, Laravel, Zend Framework 2, Twig, Nette and Latte.
spec - The canonical spec for ulid
Device Detector - The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.
Mobile-Detect - Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.