Mobile-Detect
UUID
Our great sponsors
Mobile-Detect | UUID | |
---|---|---|
6 | 9 | |
10,459 | 12,326 | |
- | - | |
8.3 | 7.5 | |
about 1 month ago | 7 days ago | |
PHP | PHP | |
MIT License | MIT License |
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.
Mobile-Detect
-
Is there a way to chose different number of posts for différent for pc and responsive using the post widget without the hassle of duplicating the section and hiding on desktop etc?
You can use PHP projects like https://github.com/serbanghita/Mobile-Detect to make checks on your server but it will generate false positives in some cases. I've implemented that in custom widgets to deliver different content. Until know no complaints :-) But it is not implemented in Elementor by default so you'll need PHP knowledge to create a custom widget. Then you can output different posts for different devices. If you can't do that: you have to use the switches
-
Detect if it is an iOS device
I've been using this: http://mobiledetect.net/
-
How to show a column only on mobile?
This challenge is commonly tackled with a device detection library on the backend like MobileDetect (this one is in PHP, but ports exist to a variety of backend languages).
-
Best way to redirect users to desktop version or mobile version website based on their device on my PHP coded website?
If you really can’t make your website responsive, then there’s a great php library here http://mobiledetect.net
-
How enable Google AdSense Auto Ads for desktop (web) only
I personally use mobiledetect to detect the visitor's device type.
-
What's the best way to NOT load a chunk of code on mobile devices? I don't just want to hide it with CSS, I want this bit to not load at all on mobile devices.
Use composer require mobiledetect/mobiledetectlibto use MobileDetect.
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.
What are some alternatives?
Tailwind CSS - A utility-first CSS framework for rapid UI development.
cuid - Collision-resistant ids optimized for horizontal scaling and performance.
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.
php-ulid - A PHP port of alizain/ulid with some minor improvements.
UA Parser
ulid - Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3
Agent - 👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
ksuid - Java implementation of K-Sortable Globally Unique IDs
Jieba-PHP - "結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件。 / "Jieba" (Chinese for "to stutter") Chinese text segmentation: built to be the best PHP Chinese word segmentation module.
Slugify - Converts a string to a slug. Includes integrations for Symfony, Silex, Laravel, Zend Framework 2, Twig, Nette and Latte.
Russian metaphone phonetic algorithm implementation for PHP - Russian metaphone algorithm implementation