uuid

A TypeScript GUID class? [closed]

南楼画角 提交于 2019-11-27 04:20:29
Does anyone know of a good, solid, implementation of C# like GUID (UUID) in TypeScript? Could do it myself but figured I'd spare my time if someone else done it before. Fenton There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: class Guid { static newGuid() { 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); }); } } // Example of a bunch of GUIDs for (var i = 0; i < 100; i++) { var id = Guid.newGuid(); console.log(id); }

Cassandra UUID vs TimeUUID benefits and disadvantages

陌路散爱 提交于 2019-11-27 04:18:13
问题 Given that TimeUUID handily allows you to use now() in CQL, are there any reasons you wouldn't just go ahead and always use TimeUUID instead of plain old UUID? 回答1: UUID and TIMEUUID are stored the same way in Cassandra, and they only really represent two different sorting implementations. TIMEUUID columns are sorted by their time components first, and then by their raw bytes, whereas UUID columns are sorted by their version first, then if both are version 1 by their time component, and

Storing MySQL GUID/UUIDs

本小妞迷上赌 提交于 2019-11-27 04:13:30
问题 This is the best way I could come up with to convert a MySQL GUID/UUID generated by UUID() to a binary(16): UNHEX(REPLACE(UUID(),'-','')) And then storing it in a BINARY(16) Are there any implications of doing it this way that I should know of? 回答1: Not many implications. It will slow down the queries a little, but you will hardly notice it. UNIQUEIDENTIFIER is stored as 16-byte binary internally anyway. If you are going to load the binary into a client and parse it there, note the bit order

Is there a way to generate a random UUID, which consists only of numbers?

心已入冬 提交于 2019-11-27 03:57:13
问题 Java's UUID class generates a random UUID. But this consists of alphabets and numbers. For some applications we need only numbers. Is there a way to generate random UUID that consists of only numbers in Java ? UUID.randomUUID(); 回答1: If you dont want a random number, but an UUID with numbers only use: String lUUID = String.format("%040d", new BigInteger(UUID.randomUUID().toString().replace("-", ""), 16)); in this case left padded to 40 zeros... results for: UUID : b55081fa-9cd1-48c2-95d4

How to generate a random UUID which is reproducible (with a seed) in Python

狂风中的少年 提交于 2019-11-27 03:43:40
问题 The uuid4() function of Python's module uuid generates a random UUID, and seems to generate a different one every time: In [1]: import uuid In [2]: uuid.uuid4() Out[2]: UUID('f6c9ad6c-eea0-4049-a7c5-56253bc3e9c0') In [3]: uuid.uuid4() Out[3]: UUID('2fc1b6f9-9052-4564-9be0-777e790af58f') I would like to be able to generate the same random UUID every time I run a script - that is, I'd like to seed the random generator in uuid4() . Is there a way to do this? (Or achieve this by some other means)

Generating 8-character only UUIDs

帅比萌擦擦* 提交于 2019-11-27 03:31:23
UUID libraries generate 32-character UUIDs. I want to generate 8-character only UUIDs, is it possible? Cephalopod It is not possible since a UUID is a 16-byte number per definition. But of course, you can generate 8-character long unique strings (see the other answers). Also be careful with generating longer UUIDs and substring-ing them, since some parts of the ID may contain fixed bytes (e.g. this is the case with MAC, DCE and MD5 UUIDs). Anton Purin You can try RandomStringUtils class from apache.commons : import org.apache.commons.lang3.RandomStringUtils; final int SHORT_ID_LENGTH = 8; //

Get the generated uuid after insert php

喜你入骨 提交于 2019-11-27 02:52:38
问题 i have a table field type varchar(36) and i want to generate it dynamically by mysql so i used this code: $sql_code = 'insert into table1 (id, text) values (uuid(),'some text');'; mysql_query($sql_code); how can i retrieve the generated uuid immediately after inserting the record ? 回答1: char(36) is better you cannot. The only solution is to perform 2 separated queries: SELECT UUID() INSERT INTO table1 (id, text) VALUES ($uuid, 'text') where $uuid is the value retrieved on the 1st step. 回答2:

UUID collision risk using different algorithms

坚强是说给别人听的谎言 提交于 2019-11-27 02:38:33
问题 I have a database where 2 (or maybe 3 or 4) different applications are inserting information. The new information has IDs of the type GUID/UUID, but each application is using a different algorithm to generate the IDs. For example, one is using the NHibernate's "guid.comb", other is using the SQLServer's NEWID(), other might want to use .NET's Guid.NewGuid() implementation. Is there an above normal risk of ID collision or duplicates? Thanks! 回答1: The risk of collisions is elevated slightly but

Django migration with uuid field generates duplicated values

五迷三道 提交于 2019-11-27 02:02:43
问题 I have a uuid field (not a primary key). The generated migration is: from __future__ import unicode_literals from django.db import migrations, models import uuid class Migration(migrations.Migration): dependencies = [ .... ] operations = [ ... migrations.AddField( model_name='device', name='uuid', field=models.UUIDField(default=uuid.uuid4, unique=True), ), ... ] But when doing python manage.py migrate it is crashing with: django.db.utils.IntegrityError: could not create unique index

Is Oracle's SYS_GUID() UUID RFC 4122 compliant?

萝らか妹 提交于 2019-11-27 01:49:06
问题 I wonder if Oracle's SYS_GUID() function returns a RFC 4122 compliant UUID. For example: SQL> select sys_guid() from dual; SYS_GUID() -------------------------------- A6C1BD5167C366C6E04400144FD25BA0 I know, that SYS_GUID() returns a 16 byte RAW datatype. Oracle uses RAWTOHEX() and probably TO_CHAR() to print out the above ID. Is it correct to interpret this as a UUID compliant string format like: A6C1BD51-67C3-66C6-E044-00144FD25BA0 I think it's not compliant to the RFC 4122 standard,