4
голосов
10ответов
4665 просмотров

Filtering lists

I want to filter repeated elements in my list for instance foo = ['a','b','c','a','b','d','a','d'] I am only interested with: ['a','b','c','d'] What would be the efficient way to do achieve this ? Cheers

0
голосов
2ответов
2533 просмотров

n-values UUID generator, reusable IDs

I need a simple UUID generator. The ID is required to be unique for this single instance. Another requirement is, that it has n hashes coexisting at a time, and being releasable. I don't know wether this fits the UUID concept or not. I allrdy thought about a Stack with n-values using pop and push...

37
голосов
3ответов
74439 просмотров

How to make "No Duplicates" column in SQL Server 2008?

I have a simple table in my SQL Server database. This table contains two columns: ID int, Name nvarchar(50). The ID column is the primary key for my table. I want the "Name" column to be "(No Duplicates)", like in Microsoft Access, But this column isn't the primary column. How could I do this?

4
голосов
3ответов
1543 просмотров

PHP Image uploading - uniqueness via microtime()

If I make the filename of each uploaded file PHPs microtime(), are the risks of a collision realistic? And is there a way to further randomize the filenames? I'm expecting about 20,000 uploads in about a week. That's 2800/day or 119/hour (assuming even distribution). Does anyone have any experie...

2
голосов
4ответов
2796 просмотров

std::unique analogue in Qt?

I have browsed the documentation, but didn't find one. Any ideas?

1
голосов
2ответов
479 просмотров

mysql 7columns pk vs. 1 column md5 unique constraint

i have a very large table which is currently approx 70M rows and growing daily by the thousands , this schema is tipping over every day now so i'm moving to a partitioned table and redesigning the ddl . the table is basicly a collection of NOT NULL INTEGERS(some medium some INT some tiny) which ...

2
голосов
6ответов
783 просмотров

Extending uniq method

This is Ruby 1.8 Question: We all know how to use Array#uniq : [1,2,3,1].uniq #=> [1,2,3] However I'm wondering if we can monkey patch it in a way to work with complex objects. The current behavior is like this: [{"three"=>"3"}, {"three"=>"4"}, {"three"=>"3"}].uniq #=> [{"thr...

0
голосов
2ответов
2332 просмотров

XML Schema - Key in sequence

I'm trying to put a key in sequence and am being bombarded with errors. It seems I can't do this. Additionally, I am being told my key needs a field and selector, which I have been able to find very little documentation on. (In fact, in desperation, I downloaded Liquid XML Studio [vs. Notepad] an...

5
голосов
8ответов
3201 просмотров

How to enforce DB integrity with non-unique foreign keys?

I want to have a database table that keeps data with revision history (like pages on Wikipedia). I thought that a good idea would be to have two columns that identify the row: (name, version). So a sample table would look like this: TABLE PERSONS: id: int, name: varchar(30), ...

0
голосов
4ответов
6485 просмотров

Get element by id via regex jQuery

Html element contains complex & unique id, composed from namespace as prefix and incremented index - as postfix. I try do it with wildcard expression for id. If to use simple way without namespace, that it works fine: $j("[id*=service_selected_]").click(function(){ ... In order to keep u...

4
голосов
7ответов
1407 просмотров

Most Efficient Way to... Unique Random String

I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over. Is th...

1
голосов
4ответов
2192 просмотров

Mysql Unique Query

I have a programme listing database with all the information needed for one programme packed into one table (I should have split programmes and episodes into their own) Now since there are multiple episodes for any given show I wish to display the main page with just the title names in ascending ...

8
голосов
7ответов
629 просмотров

What's the most pythonic way to ensure that all elements of a list are different?

I have a list in Python that I generate as part of the program. I have a strong assumption that these are all different, and I check this with an assertion. This is the way I do it now: If there are two elements: try: assert(x[0] != x[1]) except: print debug_info raise Exception("...

0
голосов
5ответов
302 просмотров

Make MySQL table unique

Hay, I created a spider to crawl through a PDF document and log every word in the document into a table in a MySQL database. Obviously words like 'the', 'and', 'or' etc appear in a book many, many times. I'm just wondering what's the quickest method to remove dupe values from a table?

0
голосов
1ответов
1172 просмотров

SimpleModal Basic Modal Dialog: how to open unique windows within the same page?

I'm using the SimpleModal Basic Modal Dialog and am having trouble using it to open more than one unique window on a page (I don't need them to open at the same time or on top of one another). I tried adding another class and calling out that class in my js file, but I'm not getting it. Here is ...

2
голосов
4ответов
6032 просмотров

Java ( Counting Distinct Integers )

how do you return number of distinct/unique values in an array for example int[] a = {1,2,2,4,5,5};

1
голосов
3ответов
6340 просмотров

SQL Select Entire Row by Distinct Columns

I need an sql statement which will allow me to select an entire row from oracle database, but by distinct columns. Here is a simplified database: Project_Num Title Category 0 Project 1 Admin 0 Project 1 Development 1 Project...

1
голосов
3ответов
590 просмотров

MySQL: grab one row from each category, but remove duplicate rows posted in multiple categories

I have a database of articles, which are stored in categories. For my homepage, I want to grab an article from each category (I don't care which). However, some articles are crossposted to multiple categories, so they come up twice. I have a table called tblReview with the article fields (revie...

35
голосов
11ответов
44539 просмотров

How to make elements of vector unique? (remove non adjacent duplicates)

I have a vector containing few non-adjacent duplicates. As a simple example, consider: 2 1 6 1 4 6 2 1 1 I am trying to make this vector unique by removing the non-adjacent duplicates and maintaining the order of elements. Result would be: 2 1 6 4 The solutions I tried are: Inserting ...

3
голосов
1ответов
2059 просмотров

How make univoque my enumeration by xs:unique

Can anyone point me as to why the unique element in my XSD is not forcing unique-ness? This should throw an error because the last ScreenResult element does not contain a unique value for the Type attribute. I should also note that I'm truly after forcing one of each Type within ScreenResults (...

3
голосов
2ответов
1469 просмотров

Httpruntime cache keys not unique?

Although i have specified a unique key, it seems the following code will return one value for 5 requests, then another for the next couple, then revert back to the value saved in the original request and just continue until there are 10's of different objects all stored under the same key. It the...

0
голосов
2ответов
2554 просмотров

PHP MYSQL multiple or single DISTINCT/UNIQUEvalues

Currently I have this query: SELECT column1,column2 FROM table column1 needs to be distinct, column2 does not. SELECT DISTINCT column1, NON-DISTINCT column2 FROM table Now I know that doesn't make sense but I need column1 to be distinct and column2 to be anything. How would I do that.

0
голосов
1ответов
1660 просмотров

How to find where I have a duplicate control ID (C#)

I am creating huge amounts of dynamic controls, and for everything that must have an ID assigned, I assign it using a guaranteed unique variable(unless 64bits overflows from just controls). Now, I have a problem though. I have a duplicate control somewhere and I can not discover where it is adde...

3
голосов
4ответов
4512 просмотров

strange behavior of php array_unique

I'm using following peace of code to output an array: echo "======output without array_unique====="; var_dump($selected); echo "=====output with array_unique====="; var_dump(array_unique($selected));die; And the output is: ======output without array_unique===== array 0 =&gt...

1
голосов
6ответов
1222 просмотров

C# non-persistent `static` keyword?

I come from a C/C++ background and am having trouble doing some things in C#. My problem right now is that I need a static keyword that works like in C++. So that the property is global to all instances of the class, which is what C#'s does. But what I don't want is the persistence in C#(/ASP.NET...

97
голосов
5ответов
178503 просмотров

Getting unique items from a list

What is the fastest / most efficient way of getting all the distinct items from a list? I have a List<string> that possibly has multiple repeating items in it and only want the unique values within the list.

1
голосов
2ответов
320 просмотров

Unique Constraint on two fields and their reverse

The problem is the following, I have a table of friendships in my database, the friendship table has two foreign keys to the users table. I want to set a unique key on the two foreign keys so that I will have no duplicates, but I want more, I want that if user A added user B, then B won't be ab...

0
голосов
2ответов
838 просмотров

Hibernate - renaming objects with a unique constraint

Say you have a bunch of Article objects, with a "title" property. Then there's an ARTICLE table with a TITLE column. The TITLE column has a unique constraint. The UI shows all the articles on one page, with a text field for editing the title. Imagine a situation where you have two articles X &a...

7
голосов
2ответов
44561 просмотров

Is it possible to set a unique constraint as a foreign key in another table?

Is it possible to set a unique constraint as a foreign key in another table? If yes, how would you go about declaring it? How would you go about assigning a candidate key? Is it possible? Example: I have a product table that consists of: prod_id, prod_name, prod_price, QOH Where I want prod_...

0
голосов
5ответов
228 просмотров

What is the most performant way to check for existence with a collection of integers?

I have a large list of integers that are sent to my webservice. Our business rules state that these values must be unique. What is the most performant way to figure out if there are any duplicates? I dont need to know the values, I only need to know if 2 of the values are equal. At first I wa...