How to generate time based UUIDs?
FasterXML Java Uuid Generator (JUG) https://github.com/cowtowncoder/java-uuid-generator UUID uuid = Generators.timeBasedGenerator().generate();
FasterXML Java Uuid Generator (JUG) https://github.com/cowtowncoder/java-uuid-generator UUID uuid = Generators.timeBasedGenerator().generate();
Here is an example doing everything in one single migration thanks to a RunPython call. # -*- coding: utf-8 -* from __future__ import unicode_literals from django.db import migrations, models import uuid def create_uuid(apps, schema_editor): Device = apps.get_model(‘device_app’, ‘Device’) for device in Device.objects.all(): device.uuid = uuid.uuid4() device.save() class Migration(migrations.Migration): dependencies = [ (‘device_app’, ‘XXXX’), ] operations … Read more
Store it as VARCHAR(36) if you’re looking to have an exact fit, or VARCHAR(255) which is going to work out with the same storage cost anyway. There’s no reason to fuss over bytes here. Remember VARCHAR fields are variable length, so the storage cost is proportional to how much data is actually in them, not … Read more
Almost there: uuid.UUID(int=rd.getrandbits(128)) This was determined with the help of help: >>> help(uuid.UUID.__init__) Help on method __init__ in module uuid: __init__(self, hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None) unbound uuid.UUID method Create a UUID from either a string of 32 hexadecimal digits, a string of 16 bytes as the ‘bytes’ argument, a string of 16 bytes … Read more
I can’t say about the web side of your question. But uuids are great for n-tier applications. PK generation can be decentralized: each client generates it’s own pk without risk of collision. And the speed difference is generally small. Make sure your database supports an efficient storage datatype (16 bytes, 128 bits). At the very … Read more
If I understand correctly, you’re using UUIDs in your primary column? People will say that a regular (integer) primary key will be faster , but there’s another way using MySQL’s dark side. In fact, MySQL is faster using binary than anything else when indexes are required. Since UUID is 128 bits and is written as … Read more
Although GCC does provide __int128, it is supported only for targets (processors) which have an integer mode wide enough to hold 128 bits. On a given system, sizeof() intmax_t and uintmax_t determine the maximum value that the compiler and the platform support.
how safe if is to remove the “-” in the generated UUID It’s 100% safe since the dashes aren’t part of the value. The String UUID is a hex representation of a 128 bit value. The dashes are there just for display purposes so UUIDs will be a bit easier on the eyes. Just be … Read more
Project persistence block in a solution file has the following format: Project(“{project type GUID}”) = “<Project name>”, “<project file location>”, “{<Unique project GUID>}” EndProject So it’s expected that first GUID is non-unique, it uniquely identifies Visual Studio package that handles this type of projects. The GUID you posted is interesting – it looks like mangled … Read more
Updated Answer This is now something you can do natively in JavaScript/TypeScript with crypto.randomUUID(). Here’s an example generating 20 UUIDs. for (let i = 0; i < 20; i++) { let id = crypto.randomUUID(); console.log(id); } Original Answer There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: … Read more