unique

Replace specific elements (unique or duplicates) from a string in JS

强颜欢笑 提交于 2019-12-11 10:56:25
问题 My code automatically search the string for /d+d/d+ elements (roll dices) and adds random number suffixes and stores them as elements in an array. I want to create a new string with the new modified elements of my array. (I don't want to split string in Array, replace the same elements with the other array in a brand new one and then join it to a string. I need to modify it and save it in a new string) Example: String changes through user input so if i have: str = ' I roll 1d3 and 2d4+3 and

PHP Random String Generator without Repeats

偶尔善良 提交于 2019-12-11 10:43:23
问题 I'm trying to write a PHP function which will generate "supposedly" random strings which need to be unique regardless of the number of times it is run. Well, it can run more than once in order to generate but preferably not many many times. For example, when you upload an image to imgur, it generates a random 5-letter [a-zA-Z] string. If I want to duplicate this (store the string with a Unique KEY in a MySQL database), without having to repeating select and ensure that the key does not

Issue in setting unique ID in Domino designer

雨燕双飞 提交于 2019-12-11 10:37:38
问题 I am new to Domino designer and lotus script, following my second question, I have some issue in setting unique ID (for id field in form). My formula for Id field value : T_List:=@DbColumn("" : "NoCache"; "Local"; "DBintro";"testview"; 1); @If(@IsNewDoc & @Elements(T_List)=0;1;@IsNewDoc & !@IsError(T_List);@Subset(T_List;1) + 1;id) I'm having DB in local (nothing shared). referred this link an Answer by AndrewB Server : Local DBname : DBintro view name : testview id - field in the form (which

How to fill an array with distinct values

无人久伴 提交于 2019-12-11 09:47:02
问题 I want my array input such that it cannot have the same number twice: this however will have an output of "value exist please re enter: "; two times. how do i check if it is unique and only display once if it has been initialised before? int main(){ int arr_size = 10; int value; int aArray[10]; for(int i=0;i<arr_size;i++) { cout<<"enter value of slot"<<i+1<<": "; cin>>value; for(int j=0;j<arr_size;j++){ if(value == aArray[j]) { cout<<"value exist please re enter: "; cin>>value; } else{ aArray

XSLT select only last version element in rowset

£可爱£侵袭症+ 提交于 2019-12-11 09:18:35
问题 My xml is: <RowSet> <Row> <msg_id>1</msg_id> <doc_id>1</doc_id> <doc_version>1</doc_version> </Row> <Row> <msg_id>2</msg_id> <doc_id>1</doc_id> <doc_version>2</doc_version> </Row> <Row> <msg_id>3</msg_id> <doc_id>1</doc_id> <doc_version>3</doc_version> </Row> <Row> <msg_id>4</msg_id> <doc_id>2</doc_id> <doc_version>1</doc_version> </Row> <RowSet> What I need to do: If there are Rows with the same doc_id , I need to select only node with the bigger doc_version number. Expected output: <RowSet>

MongoDB: Insert multiple documents into collection with unique index even if some violate the index

让人想犯罪 __ 提交于 2019-12-11 07:55:58
问题 I am trying to insert an array of documents into a MongoDB collection. The collection has a unique index on one of the fields. I am inserting all the documents at once as such: const mongojs = require('mongojs'); const db = mongojs('mongodb://username:password@address.mlab.com:37230/database'); // documents is an array of documents db.items.insert(documents, (err, task) => { if (err) { console.log(err); } }) Now there is one document that violates the unique index and I receive this error:

Finding duplicate keys across hashes?

天涯浪子 提交于 2019-12-11 07:36:20
问题 To simplify things let's say I have the hashes below. I would like to find the keys that are in multiple hashes and the name of the hashes. So ideally I would like to end up with A is also in a A is also in b B is also in a B is also in b D is also in b D is also in c E is also in b E is also in c The only way I can think of is: putting all keys in an array, sort it, remove unique elements, search each hash that contain the remaing array elements. It is somewhat complicated and hacky I guess.

Count unique values in R and display in column

房东的猫 提交于 2019-12-11 07:36:04
问题 I have this dataframe, and I would like to count the unique values in column A and display them in Column D So the if else function should look at column A and ad 1 for each new unique user > DF_Have <- data.frame(A=c(1,2,2,3,3), B=1:5*10, C=1:5*100) > DF_Have A B C 1: 1 10 100 2: 2 20 200 3: 2 30 300 4: 3 40 400 5: 3 50 500 > DF_Want A B C D 1: 1 10 100 1 2: 2 20 200 2 3: 2 30 300 2 4: 3 40 400 3 5: 3 50 500 3 回答1: library(data.table) DF_Have$D <- rleid(DF_Have$A) DF_Have # A B C D #1 1 10

Add new columns to a pandas df after filtering

社会主义新天地 提交于 2019-12-11 07:32:00
问题 I have a df that contains information about various places. import pandas as pd d = ({ 'C' : ['08:00:00','XX','08:10:00','XX','08:41:42','XX','08:50:00','XX', '09:00:00', 'XX','09:15:00','XX','09:21:00','XX','09:30:00','XX','09:40:00','XX'], 'D' : ['Home','','Home','','Away','','Home','','Away','','Home','','Home','','Away','','Home',''], 'E' : ['Num:','','Num:','','Num:','','Num:','','Num:', '','Num:','','Num:','','Num:', '','Num:', ''], 'F' : ['1','','1','','1','','1','','1', '','2','','2',

Count number of occurrences of a string from a column inside another column, with conditions

故事扮演 提交于 2019-12-11 07:05:39
问题 I would like to count the number of times the words from a string in column animals.1 occur in the column animals.2 within the past five years: > df = data.frame(animals.1 = c("cat; dog; bird", "dog; bird", "bird", "dog"), animals.2 = c("cat; dog; bird","dog; bird; seal", "bird", ""),year= c("2001","2005","2010","2018"), stringsAsFactors = F) > df animals.1 animals.2 year 1 cat; dog; bird cat; dog; bird 2001 2 dog; bird dog; bird; seal 2005 3 bird bird 2010 4 dog 2018 Desired Output > df