unique

Should I check for DB constraints in code or should I catch exceptions thrown by DB

Hi, I have an application that saves data into a table called Jobs. The Jobs table has a column called Name which has a UNIQUE constraint. The Name column is not PRIMARY KEY. I wonder if I should check for duplicate entries myself before I try to save/update a new entry or if it's better to wait for an exception thrown by the data acces...

Ideas on making a javascript object name unique in ASP.Net?

I've created an ASP.Net user control that will get placed more than once inside of web page. In this control I've defined a javascript object such as: function MyObject( options ) { this.x = options.x; } MyObject.prototype.someFunction=function someFunctionF() { return this.x + 1; } In the code behind I've created MyObject in a s...

What can C++ do that is too hard or messy in any other language?

I still feel C++ offers some things that can't be beaten. It's not my intention to start a flame war here, please, if you have strong opinions about not liking C++ don't vent them here. I'm interested in hearing from C++ gurus about why they stick with it. I'm particularly interested in aspects of C++ that are little known, or underut...

Identifying unique hits with javascript

Could you suggest an efficient way to identify a unique user with javascript (e.g. calculate an hash to send to the server side)? EDIT: The point is that I can't 'intrude' into the browser (e.g. send cookies). And IPs are also not the option. And it has to be a client-side solution (therefore javascript). ...

How do I print unique elements in Perl array?

I'm pushing elements into an array during a while statement. Each element is a teacher's name. There ends up being duplicate teacher names in the array when the loop finishes. Sometimes they are not right next to each other in the array, sometimes they are. How can I print only the unique values in that array after its finished getting...

What's the right pattern for unique data in columns?

I've a table [File] that has the following schema CREATE TABLE [dbo].[File] ( [FileID] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](256) NOT NULL, CONSTRAINT [PK_File] PRIMARY KEY CLUSTERED ( [FileID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS...

Creating a unique alphanumeric 10-character string

I'm looking to create a simple short-lived reservation system, and I'd like to generate confirmation numbers that are unique random-looking alphanumeric short-ish, at least much shorter than 32 character-long strings returned by sha1 I'm only looking to have ~500 reservations, so I don't imagine high likelyhood of collissions. One i...

deleting rows of a numpy array based on uniqueness of a value

let's say I have a bi-dimensional array like that numpy.array([[0,1,1.2,3],[1,5,3.2,4],[3,4,2.8,4], [2,6,2.3,5]]) I want to have an array formed eliminating whole rows based on uniqueness of values of last column, selecting the row to keep based on value of third column. e.g. in this case i would like to keep only one of the rows with ...

How do you remove duplicates from a list in Python?

Given a list of strings, I want to sort it alphabetically and remove duplicates. I know I can do this: from sets import Set [...] myHash = Set(myList) but I don't know how to retrieve the list members from the hash in alphabetical order. I'm not married to the hash, so any way to accomplish this will work. Also, performance is not an...

How do you remove duplicates from a list in Python whilst preserving order?

Is there a built-in that removes duplicates from list in Python, whilst preserving order? I know that I can use a set to remove duplicates, but that destroys the original order. I also know that I can roll my own like this: def uniq(input): output = [] for x in input: if x not in output: output.append(x) return output ...

unique fields with size issue

I've got a mysql database and I'm trying to put a url and unique id into two seperate fields. One of the urls are sometimes more than 800 characters long. I tried to create a UNIQUE index of the id and url, so that I'm not linking to the same url/id combo more than once, but I get an error regarding field length for the index. I'm cur...

ASP.NET Multiple controls with the same ID 'x' were found. FindControl

Hey Guys, Getting the following error Multiple controls with the same ID 'ltlItemCode' were found. FindControl requires that controls have unique IDs. This Error does not happen on page loads but when I change the value of a drop down which has AutoPostBack="true". Code is `//Number of Services numberofServices = Int32.Pa...

uniq in C#

Is there an easy way to get only the unique values out of a list of strings in C#? My google-fu is failing me today. (I know I can put them in another structure and pull them out again. I'm looking for stupidly-easy, like Ruby's .uniq method. C# has bloody well everything else, so I'm probably just using the wrong synonym.) Specific...

Remove non-unique ids rows

From a database backup I have records without unique Ids. Some records have unique IDs. Some records with duplicated IDs contains different DateCreated values. Some records with duplicated IDs contains the same DateCreated values. I'm trying to get a MSSql 2005 query will leave only unique ID values with the most recent DateCreated v...

Providing a feature only once to each unique visitor

I have written a message board as my first ASP.NET project. It seems to work well so far. However, one of the features I have is that each message has a spam rating. It is simply the number of times that viewers have marked the message as spam divided by the total number of times the message has been viewed. The idea is to allow users to...

Select unique or distinct values from a list in UNIX shell script

I have a ksh script that returns a long list of values, newline separated, and I want to see only the unique/distinct values. It is possible to do this? For example, say my output is file suffixes in a directory: tar gz java gz java tar class class I want to see a list like: tar gz java class ...

Select only unique rows in mysql

I want to select only rows that are unique according to the column userid from a mysql table. So if I have two rows with the same userid none of them gets selected but if its only one it gets selected. I use the following code: SELECT T.id,T.name,T.userid FROM tbltest T WHERE userid NOT IN (SELECT userid FROM tbltest WHERE tbltest.id<>...

Unique, numeric, incremental identifier

I need to generate unique, incremental, numeric transaction id's for each request I make to a certain XML RPC. These numbers only need to be unique across my domain, but will be generated on multiple machines. I really don't want to have to keep track of this number in a database and deal with row locking etc on every single transaction...

Rails: How do I find() all records unique in certain fields?

I have a list of 'request' objects, each of which has fairly normal activerecord qualities. The requests table is related to the games table with a join table, 'games_requests,' so that a request has a request.games array. The question is, is there a way to do a find for the last n unique requests, where uniqueness is defined by the ga...

MySQL: Retrieve Unique Values and Counts For Each

Is there a simple way to retrieve a list of all unique values in a column, along with how many times that value appeared? Example dataset: A A A B B C ... Would return: A | 3 B | 2 C | 1 Thanks! ...