uuid

Web框架之Django【进阶篇】- Form验证

て烟熏妆下的殇ゞ 提交于 2019-12-05 06:47:56
Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 小试牛刀 1、创建Form类 from django.forms import Form from django.forms import widgets from django.forms import fields class MyForm(Form): user = fields.CharField( widget=widgets.TextInput(attrs={'id': 'i1', 'class': 'c1'}) ) gender = fields.ChoiceField( choices=((1, '男'), (2, '女'),), initial=2, widget=widgets.RadioSelect ) city = fields.CharField( initial=2, widget=widgets.Select(choices=((1,'上海'),(2,'北京'),)) ) pwd = fields.CharField( widget=widgets.PasswordInput(attrs={'class': 'c1'}, render_value=True) ) 2、View函数处理 from

How to create a 64 bit Unique Integer in Java

╄→гoц情女王★ 提交于 2019-12-05 04:07:30
问题 I need to create a 64 bit unique integer in Java so that collision chances are low. The system is not distributed, so collisions between different computers are not a problem. Is there any way, we can create a 64 bit integer in Java which is always Unique? As of now I am using - long number = System.nanoTime(); Is this the right way to generate 64 bit Unique Integer in Java or is there anything else I can try? UPDATE:- How about doing this way? Will this be unique? UUID number = UUID

How to use uuid with postgresql gist index type?

与世无争的帅哥 提交于 2019-12-05 03:29:42
I can't use directly uuid with gist index CREATE INDEX idx_leaderboads_values_gist ON leaderboard_entry USING gist (id_leaderboard , value); And I got this error: ERROR: data type uuid has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type. Postgres 10 or newer btree_gist now also covers the data type uuid , like Paul commented . (And some other data types, remarkably all enum types.) Now all you need to do: install the extension once per database: CREATE EXTENSION btree_gist; Then your

How to save a UUID as binary(16) in java

无人久伴 提交于 2019-12-05 02:29:31
问题 I have a table TestTable with columns ID as binary(16) and name as varchar(50) I've been trying to store an ordered UUID as PK like in this article Store UUID in an optimized way I see the UUID is saved in database as HEX (blob) So I want to save this ID from java but I am getting this error Data truncation: Data too long for column 'ID' at row 1 I am currently using the library sql2o to interact with mysql So basically this is my code String suuid = UUID.randomUUID().toString(); String

局域网上传大文件的解决方案

匆匆过客 提交于 2019-12-05 02:25:20
关键部分 前端用file.slice()分块 前端用FileReader获取每一分块的md5值 后端用MultipartFile接受分块文件 后端用FileOutputStream拼装分块文件 话不多说,直接上代码,我想这是你们最喜欢的 工程截图 <%@ page language = "java" import = "java.util.*" pageEncoding = "UTF-8" %><% String path = request.getContextPath(); String basePath = request.getScheme()+ "://" +request.getServerName()+ ":" +request.getServerPort()+path+ "/" ; String clientCookie = request.getHeader( "Cookie" ); %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < html > < head > < meta http-equiv = "Content-Type" content =

Cast or extract timestamptz from v1 uuid in postgresql

自作多情 提交于 2019-12-05 02:07:24
I'm trying to extract the timestamp from a V1 uuid, naively wished this worked: select '3efe0a20-f1b3-11e3-bb44-14109fec739e'::uuid::timestamp; Here is a quick example showing how to extract the time in go, but I'm hoping postgresql has something built-in rather than creating a one-off pl/pgSql function. http://play.golang.org/p/XRCooLgfaG I've tested this with uuid's from my database and it seems to work very well, even without the unsigned bigints CREATE FUNCTION uuid_timestamp(id uuid) RETURNS timestamptz AS $$ select TIMESTAMP WITH TIME ZONE 'epoch' + (((('x' || lpad(split_part(id::text, '

Rails + Postgres migration - why am I receiving the error “PG::UndefinedFunction: ERROR: function gen_random_uuid() does not exist”?

眉间皱痕 提交于 2019-12-05 01:53:22
One of my Rails migrations uses a uuid as the primary key. The Postgres extension gen_random_uuid() should solve this issue, but I continue to get the error after installing the relevant extension ( uuid-ossp ). The issue was that the uuid-ossp extension was being blown away with the database each time I dropped the db as part of a reset and migration (e.g. rake db:drop db:create db:migrate ). The fix is to create a migration that's run before all other migrations which enables the relevant extension(s). Like so ( db/migrate/0_enable_extensions.rb ): class EnableExtensions < ActiveRecord:

How to generate a GUID in C?

耗尽温柔 提交于 2019-12-05 01:20:45
问题 I want to generate guids to insert into a SQLite database (i.e. no support from the db itself). However, I would like to have control over certain properties: Orderedness for generating increasing guid values. Computer independence. The db is public and may/may not want guids to allow someone to trace data back to a specific machine. 'Enough' randomness. The guids are keys in the db which is going to be merged with a lot of other dbs and can get quite large, meaning that faking a guid like

UUID primary key in Eloquent model is stored as uuid but returns as 0

馋奶兔 提交于 2019-12-05 01:19:43
I have a mysql table in which I'm using a UUID as the primary key. Here's the creation migration: Schema::create('people', function (Blueprint $table) { $table->uuid('id'); $table->primary('id'); ... $table->timestamps(); } Which generates the following MySQL schema: CREATE TABLE `people` ( `id` char(36) COLLATE utf8_unicode_ci NOT NULL, ... `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; In my Eloquent model I have a method for creating an instance which calls a method for

How to create programmatically an A2DP connection or how can I emulate an Android phone to be an A2DP sink?

我们两清 提交于 2019-12-05 00:47:49
问题 I have two android phones (Samsung Galaxy Tab and HTC Desire). Both 2.2. The Galaxy Tab should be an A2DP sink and the Desire the source. My aim is to route the sound of the Desire to the Galaxy. I just saw in the API that it is possible to establish a RFCOMM connection. But I want to establish an A2DP connection. My requirements to the solution is that none of the phones should be rooted. I found in the source code the Bluetooth UUID class. And I tried to open a A2DP Connection with the