Unique model field in Django and case sensitivity (postgres)

You could define a custom model field derived from models.CharField. This field could check for duplicate values, ignoring the case. Custom fields documentation is here http://docs.djangoproject.com/en/dev/howto/custom-model-fields/ Look at http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/files.py for an example of how to create a custom field by subclassing an existing field. You could use the citext module of PostgreSQL https://www.postgresql.org/docs/current/static/citext.html If you … Read more

SQL Server : does NEWID() always gives a unique ID?

Both NEWID() and NEWSEQUENTIALID() give globally unique values of type uniqueidentifier. NEWID() involves random activity, thus the next value is unpredictable, and it’s slower to execute. NEWSEQUENTIALID() doesn’t involve random activity, thus the next generated value can be predicted (not easily!) and executes faster than NEWID(). So, if you’re not concerned about the next value … Read more

Unique hardware ID in Mac OS X

For C/C++: #include <IOKit/IOKitLib.h> void get_platform_uuid(char * buf, int bufSize) { io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, “IOService:/”); CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); IOObjectRelease(ioRegistryRoot); CFStringGetCString(uuidCf, buf, bufSize, kCFStringEncodingMacRoman); CFRelease(uuidCf); }

Get only unique elements from two lists

UPDATE: Thanks to @Ahito: In : list(set(x).symmetric_difference(set(f))) Out: [33, 2, 22, 11, 44] This article has a neat diagram that explains what the symmetric difference does. OLD answer: Using this piece of Python’s documentation on sets: >>> # Demonstrate set operations on unique letters from two words … >>> a = set(‘abracadabra’) >>> b = … Read more