uuid

Generating a globally unique identifier in Java

泄露秘密 提交于 2019-11-26 12:26:01
问题 Summary: I\'m developing a persistent Java web application, and I need to make sure that all resources I persist have globally unique identifiers to prevent duplicates. The Fine Print: I\'m not using an RDBMS, so I don\'t have any fancy sequence generators (such as the one provided by Oracle) I\'d like it to be fast, preferably all in memory - I\'d rather not have to open up a file and increment some value It needs to be thread safe (I\'m anticipating that only one JVM at a time will need to

Generating v5 UUID. What is name and namespace?

蓝咒 提交于 2019-11-26 12:20:07
问题 I\'ve read the man page, but I do not undestand what name and namespace are for. For version 3 and version 5 UUIDs the additional command line arguments namespace and name have to be given. The namespace is either a UUID in string representation or an identifier for internally pre-defined namespace UUIDs (currently known are \"ns:DNS\", \"ns:URL\", \"ns:OID\", and \"ns:X500\"). The name is a string of arbitrary length. The namespace: The namespace is either a UUID in string representation or

Map构造器模式 map builder pattern

拥有回忆 提交于 2019-11-26 12:18:46
maven引入依赖 <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>20.0</version> </dependency> java代码 ImmutableMap<String, Object> jsonObject = ImmutableMap.<String, Object>builder() .put("duration", duration) .put("uuid", uuid) .put("meta", MediaService.toJsonObject(meta)) .build(); 注意事项:map的value值不能为null, ImmutableMap是不可再修改的集合,使用过程中不可以更改其中的值,不可修改也就线程安全了。相关的框架还有一个叫Immutables的,由于IDE支持不好,笔者没有去研究。 来源: https://www.cnblogs.com/passedbylove/p/11319671.html

How should I store GUID in MySQL tables?

£可爱£侵袭症+ 提交于 2019-11-26 11:58:39
Do I use varchar(36) or are there any better ways to do it? My DBA asked me when I asked about the best way to store GUIDs for my objects why I needed to store 16 bytes when I could do the same thing in 4 bytes with an Integer. Since he put that challenge out there to me I thought now was a good time to mention it. That being said... You can store a guid as a CHAR(16) binary if you want to make the most optimal use of storage space. I would store it as a char(36). KCD Adding to the answer by ThaBadDawg, use these handy functions (thanks to a wiser collegue of mine) to get from 36 length string

Is there any difference between a GUID and a UUID?

此生再无相见时 提交于 2019-11-26 11:56:54
I see these 2 acronyms thrown around, and I was wondering if there are any differences between a GUID and a UUID? Hoylen The simple answer is: no difference , they are the same thing. Treat them as a 16 byte (128 bits) value that is used as a unique value. In Microsoft-speak they are called GUIDs, but call them UUIDs when not using Microsoft-speak. Even the authors of the UUID specification and Microsoft claim they are synonyms: From the introduction to IETF RFC 4122 " A Universally Unique IDentifier (UUID) URN Namespace ": "a Uniform Resource Name namespace for UUIDs (Universally Unique

Collisions when generating UUIDs in JavaScript?

痞子三分冷 提交于 2019-11-26 11:52:26
问题 This relates to this question. I am using the code below from this answer to generate UUID in JavaScript: \'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); }); This solution appeared to be working fine, but I am getting collisions. Here\'s what I have: A web-app running in Google Chrome. 16 users. about 4000 UUIDs have been generated in the past 2 months by these users. I got about 20

Storing UUID as base64 String

走远了吗. 提交于 2019-11-26 11:49:00
问题 I have been experimenting with using UUIDs as database keys. I want to take up the least amount of bytes as possible, while still keeping the UUID representation human readable. I think that I have gotten it down to 22 bytes using base64 and removing some trailing \"==\" that seem to be unnecessary to store for my purposes. Are there any flaws with this approach? Basically my test code does a bunch of conversions to get the UUID down to a 22 byte String, then converts it back into a UUID.

linux知识扫盲

爱⌒轻易说出口 提交于 2019-11-26 11:45:34
一、磁盘分区的配置   mbr与gpt的区别: 参考资料网站 https://zhidao.baidu.com/question/457998790987659965.html 二、什么是LVM   LVM(逻辑卷管理程序),是Linux环境下对 磁盘分区 进行管理的一种机制。    参考资料网站 https://baike.baidu.com/item/LVM/6571177?fr=aladdin 三、什么是挂载点   一棵大树(根目录/)有很多树枝(目录,挂载点),每个树枝上都挂着一个箱子(分区,存储空间)。 四、基础命令   0.改变文件属性与权限:     chgrp:改变文件所属群组 chgrp 群组名 目录或文件     chown:改变文件拥有者 chown 账号名[账号名:群组名] 目录或文件     chmod:改变文件的权限 chmod xyz[ugoa +-= rwx] 目录或文件   1.文件与目录的监视: ls [-adl] [--full-time] [--time=atime,ctime] 文件名或目录名称     -a : 全部文件,连同隐藏文件     -d : 仅列出目录     -l : 包含属性和权限。     full-time : 显示完整时间     atime(access time),ctime(change time),mtime

How to get a unique device ID in Swift?

自闭症网瘾萝莉.ら 提交于 2019-11-26 11:33:09
How can I get a devices unique ID in Swift? I need an ID to use in the database and as the API-key for my web service in my social app. Something to keep track of this devices daily use and limit its queries to the database. Thanks! You can use this (Swift 3): UIDevice.current.identifierForVendor!.uuidString For older versions: UIDevice.currentDevice().identifierForVendor or if you want a string: UIDevice.currentDevice().identifierForVendor!.UUIDString There is no longer a way to uniquely identify a device after the user uninstalled the app(s). The documentation says: The value in this

How to read a .NET Guid into a Java UUID

做~自己de王妃 提交于 2019-11-26 11:16:51
问题 I need to communicate a Guid that was generated in .NET to a Java application. I use Guid.ToByteArray() to store it on disk as a byte[] , then read it into Java and convert it to a UUID. For this purpose I copied the implementation of the (private) constructor of UUID that takes a byte[] : private UUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16; for (int i=0; i<8; i++) msb = (msb << 8) | (data[i] & 0xff); for (int i=8; i<16; i++) lsb = (lsb << 8) | (data[i] & 0xff);