unique

How to remove duplicate values from an associative array based on a specific value?

Hi there! I have an array that looks just like that: array(3) { ["fk_article_id"]=> string(1) "4" ["first_name"]=> string(6) "Ulrike" ["last_name"]=> string(10) "Grasberger" } array(3) { ["fk_article_id"]=> string(1) "9" ["first_name"]=> string(5) "Frank" ["last_name"]=> string(9) "Neubacher" } array(3) { ["fk_article_id"]=> string(3...

Using "unique()" on a vector of vectors in C++

I hope this is not a duplicate question, but if it is, feel free to point me in the right direction. I have a vector<vector<int> >. Is it possible to use unique() on this? Something like: vector<vector<int> > myvec; //blah blah do something to myvec vector<vector<int> >::interator it = unique(myvec.begin(), myvec.end()); Would the r...

Generating sequence of unique strings with the length of 7 or 8 characters

It's so much nice to track a user file with a nice string like "JES9-99S" instead of file no 3992 Suppose at most we have 10MIL files, i need a uniqid generator algorithm that can generate unique id's with length of 7 or 8 characters. ...

Enforcing Unique Constraint in GAE

I am trying out Google App Engine Java, however the absence of a unique constraint is making things difficult. I have been through this post and this blog suggests a method to implement something similar. My background is in MySQL.Moving to datastore without a unique constraint makes me jittery because I never had to worry about duplicat...

finding unique values from a list

Suppose you have a list of values x <- list(a=c(1,2,3), b = c(2,3,4), c=c(4,5,6)) I would like to find unique values from all list elements combined. So far, the following code did the trick unique(unlist(x)) Does anyone know a more efficient way? I have a hefty list with a lot of values and would appreciate any speed-up. ...

MySQL get only rows with a unique value for a certain field

Hi, I want to get only the rows with a unique value for a certain field (2 actually). My table is like this: id senderID receiverID ... ... ... _________________________________________________ 0 0 1 ... ... ... 1 2 1 ... ... ... 2 1 0 ...

gettimeofday clock_gettime solution to generate unique number

My process runs multiple instances (processes) and multiple threads and all of them write to the same database. As soon as the request is placed, a unique req id is generated for the record to be added to the proprietary db. Here are our limitations: It cannot be more than 9 char length, needs to have hhmmss as the first 6 chars. We deci...

Django, auto generating unique model fields and recursively calling auto generator if not unique

I am working on a Django project where a Thing would have a unique 10 digit Key, in addition to the standard auto incrementing ID integerfield. I use a simple random number function to create it. [I'm sure there's a better way to do this too] When a Thing is created, a 10 digit Key is created. I use the .validate_unique() to check th...

Detecting a "unique" anonymous users

It is impossible to identify a user or request as unique since duping is trivial. However, there are a handful of methods that, combined, can hamper cheating attempts and give a user quasi-unique status. I know of the following: IP Address - store the IP address of each visitor in a database of some sort Can be faked Multiple comput...

Generate random string from 4 to 8 characters in PHP

Hi guys!! I need to generate a string using PHP, it need to be unique and need to be from 4 to 8 characters (the value of a variable). I thought I can use crc32 hash but I can't decide how many characters, but sure it will be unique. In the other hand only create a "password generator" will generate duplicated string and checking the v...

Is this a bug in the CPAN Uniq module?

use Uniq; my @test1 = ("0","0","A"); my @test2 = ("1","1","A"); @test1 = uniq sort @test1; @test2 = uniq sort @test2; print "$_" for @test1; print "\n"; print "$_" for @test2; print "\n"; returns : 00A 1A It should be 0A or not?! Thank you ...

why does the uniq! method work but sort! not on this array in rails?

Here is how I created an array: @companies_with_email = Company.contact_emails_date_sent_gt(@monday). contact_emails_date_sent_lt(@friday). find(:all, :select => "distinct companies.* ") || [] @companies_with_call = Company.contact_calls_date_sent_gt(@monday). ...

smallest checksum on a string

scratching my head over this. i have 350 strings average 90 chars long, all strings are unique. Now, i wanna generate a unique id for each string. i tried the sum of chars in the string wich gave two doubles, the returned sum is not unique enough. Anybody any idea how to approach this? I thought of hash(), is that the best solution? a...

How can I make short random unique keys, like YouTube video IDs, in PHP?

is any ability to create keys like in youtube (nWChTnkVdKE)? ...

Right way to force uniqueness on a join model? (has_many :through)

I have a parent/child relationship via our users table, with models as such: class User < ActiveRecord::Base # Parents relationship has_many :children_parents, :class_name => "ParentsChild", :foreign_key => "child_id", :dependent => :destroy has_many :parents, :through => :children_parents # Children relatiopnship has_many :...

removing duplicates from array in objective c

I have an array with custom objects. Each array item has a field named "name". Now I want to remove duplicate entries based on this name value. How should I go about achieving this. Thanks in advance. ...

Randomness vs Uniqueness ?

In a web application if a user check the Remember Me box I'm gonna create a cookie and save it in database and assign it to user (long-life cookie). On any page request (page_load) I check this cookie (if session is null) and ask DAL for user object. If I use GUID it would be unique but the question is if a user can guess the pattern may...

Query all rows and return most recent of each duplicate

Hey guys, I've got a model that has an id that isn't unique. Each model also has a date. I would like to return all results but only the most recent of each row that shares ids. The model looks something like this: class MyModel(models.Model): my_id = models.PositiveIntegerField() date = models.DateTimeField() title = model...

How to check if all fields are unique in oracle?

Hi guys simple question, but can't find anything. Thanks ...

unique column constraint in Apache ddlutils

Is there any possibility to create unique column constraint using DDLUtils ? I have not found it in API. Is there other solution then altering table (add unique) just a second after its creation on my own ? ...