SCOPE_IDENTITY() for GUIDs?

You can get the GUID back by using OUTPUT. This works when you’re inserting multiple records also. CREATE TABLE dbo.GuidPk ( ColGuid uniqueidentifier NOT NULL DEFAULT NewSequentialID(), Col2 int NOT NULL ) GO DECLARE @op TABLE ( ColGuid uniqueidentifier ) INSERT INTO dbo.GuidPk ( Col2 ) OUTPUT inserted.ColGuid INTO @op VALUES (1) SELECT * FROM … Read more

Generating a unique machine id

I had the same problem and after a little research I decided the best would be to read MachineGuid in registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography, as @Agnus suggested. It is generated during OS installation and won’t change unless you make another fresh OS install. Depending on the OS version it may contain the network adapter MAC address … Read more

How to choose the id generation strategy when using JPA and Hibernate

The API Doc are very clear on this. All generators implement the interface org.hibernate.id.IdentifierGenerator. This is a very simple interface. Some applications can choose to provide their own specialized implementations, however, Hibernate provides a range of built-in implementations. The shortcut names for the built-in generators are as follows: increment generates identifiers of type long, short … Read more

.NET Short Unique Identifier

This one a good one – http://www.singular.co.nz/blog/archive/2007/12/20/shortguid-a-shorter-and-url-friendly-guid-in-c-sharp.aspx and also here YouTube-like GUID You could use Base64: string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); That generates a string like E1HKfn68Pkms5zsZsvKONw==. Since a GUID is always 128 bits, you can omit the == that you know will always be present at the end and that will give you a 22 … Read more

How to generate unique id in Dart

1. There is a UUID pub package: http://pub.dartlang.org/packages/uuid example usage: import ‘package:uuid/uuid.dart’; // Create uuid object var uuid = Uuid(); // Generate a v1 (time-based) id uuid.v1(); // -> ‘6c84fb90-12c4-11e1-840d-7b25c5ee775a’ // Generate a v4 (random) id uuid.v4(); // -> ‘110ec58a-a0f2-4ac4-8393-c866d813b8d1’ // Generate a v5 (namespace-name-sha1-based) id uuid.v5(uuid.NAMESPACE_URL, ‘www.google.com’); // -> ‘c74a196f-f19d-5ea9-bffd-a2742432fc9c’ 2. This src has … Read more

Hash function that produces short hashes?

You can use any commonly available hash algorithm (eg. SHA-1), which will give you a slightly longer result than what you need. Simply truncate the result to the desired length, which may be good enough. For example, in Python: >>> import hashlib >>> hash = hashlib.sha1(“my message”.encode(“UTF-8”)).hexdigest() >>> hash ‘104ab42f1193c336aa2cf08a2c946d5c6fd0fcdb’ >>> hash[:10] ‘104ab42f11’

How to get a unique device ID in Swift?

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 property remains the same while the app (or another app from the same … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)