uuid

Generating a UUID in Postgres for Insert statement?

妖精的绣舞 提交于 2019-11-26 16:52:32
My question is rather simple. I'm aware of the concept of a UUID and I want to generate one to refer to each 'item' from a 'store' in my DB with. Seems reasonable right? The problem is the following line returns an error: honeydb=# insert into items values( uuid_generate_v4(), 54.321, 31, 'desc 1', 31.94); ERROR: function uuid_generate_v4() does not exist LINE 2: uuid_generate_v4(), 54.321, 31, 'desc 1', 31.94); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. I've read the page at: http://www.postgresql.org/docs/current/static/uuid-ossp

利用uuid生成8位随机数

霸气de小男生 提交于 2019-11-26 16:24:39
public static void test(){ String[] chars = new String[] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; for(int i=0;i<10;i++){ StringBuffer shortBuffer = new StringBuffer(); String uuid = UUID.randomUUID().toString().replace("-",""); for (int j=0;j<8;j++) { String str=uuid.substring(j*4,j*4+4); int par=Integer.parseInt(str,16); shortBuffer.append(chars[par % 36]); } System.out.println(shortBuffer.toString()); } }    来源: https://www.cnblogs.com/DreamFather/p

Python写一个自动点餐程序

烈酒焚心 提交于 2019-11-26 16:07:30
Python写一个自动点餐程序 为什么要写这个 公司现在用meican作为点餐渠道,每天规定的时间是早7:00-9:40点餐,有时候我经常容易忘记,或者是在地铁/公交上没办法点餐,所以总是没饭吃,只有去楼下711买点饭团之类的玩意儿,所以这是促使我写点餐小程序的原因。 点餐的流程 登录 ---> 点餐 ---> 提交 哈哈,是不是很简单,其实这个还好,说白了,就是登录上去,然后拿到cookie,保持一个登录状态,然后再去点餐,点餐就是构造请求,发送到指定的点餐URL上就可以了。 登录 首先我们点开 https://meican.com/ 上面要求我们登录,我们这里输入自己的账号密码,登录上去之后可以看见一个请求. 这个请求就是登录的请求,我们看下需要传什么参数,然后我们去完全构造这个请求,也就是参数一致,并且带浏览器头,这里我们也需要去保存cookie,也就是说,我们需要自己的账号时刻保持online状态,所以需要保存cookie,需要时候调用 所以我们需要实现如下功能 登录请求构造 保持登录状态 保存cookies 使得后来的访问都带cookie 代码如下 import json import requests import http.cookiejar as HC session = requests.session() session.cookies = HC

How to Create Deterministic Guids

混江龙づ霸主 提交于 2019-11-26 15:45:48
In our application we are creating Xml files with an attribute that has a Guid value. This value needed to be consistent between file upgrades. So even if everything else in the file changes, the guid value for the attribute should remain the same. One obvious solution was to create a static dictionary with the filename and the Guids to be used for them. Then whenever we generate the file, we look up the dictionary for the filename and use the corresponding guid. But this is not feasible because we might scale to 100's of files and didnt want to maintain big list of guids. So another approach

Creating a UUID from a string with no dashes

﹥>﹥吖頭↗ 提交于 2019-11-26 15:34:34
问题 How would I create a java.util.UUID from a string with no dashes? "5231b533ba17478798a3f2df37de2aD7" => #uuid "5231b533-ba17-4787-98a3-f2df37de2aD7" 回答1: Clojure's #uuid tagged literal is a pass-through to java.util.UUID/fromString. And, fromString splits it by the "-" and converts it into two Long values. (The format for UUID is standardized to 8-4-4-4-12 hex digits, but the "-" are really only there for validation and visual identification.) The straight forward solution is to reinsert the

海康相机IP搜索协议研究

余生长醉 提交于 2019-11-26 15:21:47
项目中使用了海康相机用于拍照功能,要访问海康相机就需要知道相机的IP,一般我们通过配置文件将IP地址传入程序中,在调用其官方SDK进行拍照。每次都需要手工配置IP地址,每次现场安装实施都要配置,非常容易配置错误。所以如果软件能够自动搜索相机,并自动配置,免去手工配置的麻烦和易出错,可以增强软件的可靠性,降低部署复杂度。 分析之后想到,海康官方有提供一个相机IP修改的工具,功能强大,只要在局域网中,即使不在一个IP段也能搜索到相机。如果我们的程序也能够实现该功能,能否实现前面的设想? 根据这个想法,我觉得可以分析下其IP搜索通信协议。 通过使用wireshark抓包工具,发现其IP搜索使用了两种通信方式,一种是UDP广播,另一种是更加底层的通信方式,直接通过网卡发送广播包。实测时发现,两种通信方式功能基本相同,都能够所搜IP,修改配置。直接使用网卡发包的方式比UDP广播的方式貌似兼容相机多些。 UDP广播: UDP广播通信方式,搜索工具会向IP:239.255.255.250,端口号:37020进行广播,通信内容为xml格式字符串,例如以下内容。各个字段含义已经比较清晰了。 /* 以下是海康相机UDP协议 * 用于搜索相机和修改IP * 广播地址:239.255.255.250 * 端口号:37020 */ 搜索相机广播请求 <?xml version="1.0" encoding=

Using a UUID as a primary key in Django models (generic relations impact)

ε祈祈猫儿з 提交于 2019-11-26 15:18:58
问题 For a number of reasons^, I'd like to use a UUID as a primary key in some of my Django models. If I do so, will I still be able to use outside apps like "contrib.comments", "django-voting" or "django-tagging" which use generic relations via ContentType? Using "django-voting" as an example, the Vote model looks like this: class Vote(models.Model): user = models.ForeignKey(User) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() object = generic

How to test valid UUID/GUID?

陌路散爱 提交于 2019-11-26 15:01:31
How to check if variable contains valid UUID/GUID identifier ? I'm currently interested only in validating types 1 and 4, but it's not limit for your answer. Gambol Currently, UUID's are as specified in RFC4122. Therefore to validate a UUID... /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i ...ensures you have a canonically formatted UUID that is Version 1 through 5 and is the appropriate Variant as per RFC4122. NOTE: Braces { and } are not canonical. They are an artifact of some systems and usages. Easy to modify the above regex to meet the requirements of the

Persisting UUID in PostgreSQL using JPA

感情迁移 提交于 2019-11-26 13:47:12
问题 I'm trying to persist an entity in PostgreSQL that uses UUID as primary key. I've tried persisting it as a plain UUID: @Id @Column(name = "customer_id") private UUID id; With the above, I get this error: ERROR: column "customer_id" is of type uuid but expression is of type bytea Hint: You will need to rewrite or cast the expression. Position: 137 I also tried persisting the UUID as byte[] to no avail: @Transient private UUID id; @Id @Column(name = "customer_id") @Access(AccessType.PROPERTY)

What range of Bluetooth UUIDs can be used for vendor defined profiles?

大城市里の小女人 提交于 2019-11-26 13:21:01
问题 I want to build a simple Bluetooth Low Energy -based application using a custom profile. The adopted profiles / services / characteristics / descriptors use 16-bit UUIDs as seen on the official site. The 16-bit UUIDs are shortcuts for a corresponding 128-bit UUID and is translated as 128-bit UUID = 16-bit Attribute UUID * 2^96 + Bluetooth_Base_UUID with Bluetooth_Base_UUID being 00000000-0000-1000-8000-00805F9B34FB . (Source: Bluetooth Core Specification Vol 3 Part F Section 3.2.1) Since I am