duplicates

Java - How to check for duplicate characters in a string?

爷,独闯天下 提交于 2019-12-05 16:07:25
I need to write a function that checks a string for duplicate values and returns the count of unique characters. If the count is greater than 3, it should return true. If the count is less than 3, it should be false. Here is what I have been trying (notice I'm new to java) private boolean isFormatValid(String password) { CharSequence inputStr = password; int length = inputStr.length(); int numberDups = 0; for(int i=0; i < length; ++i) { Pattern pattern = Pattern.compile("(.)(?=.*?\1){1,20}"); Matcher matcher = pattern.matcher(inputStr); numberDups += 1; } if (numberDups < 3) { return false; }

Unique assignment of closest points between two tables

随声附和 提交于 2019-12-05 12:22:04
In my Postgres 9.5 database with PostGis 2.2.0 installed, I have two tables with geometric data (points) and I want to assign points from one table to the points from the other table, but I don't want a buildings.gid to be assigned twice. As soon as one buildings.gid is assigned, it should not be assigned to another pvanlagen.buildid . Table definitions buildings : CREATE TABLE public.buildings ( gid numeric NOT NULL DEFAULT nextval('buildings_gid_seq'::regclass), osm_id character varying(11), name character varying(48), type character varying(16), geom geometry(MultiPolygon,4326), centroid

replace duplicate values with NA in time series data using dplyr

你。 提交于 2019-12-05 10:46:06
My data seems a bit different than other similar kind of posts. box_num date x y 1-Q 2018-11-18 20.2 8 1-Q 2018-11-25 21.23 7.2 1-Q 2018-12-2 21.23 23 98-L 2018-11-25 0.134 9.3 98-L 2018-12-2 0.134 4 76-GI 2018-12-2 22.734 4.562 76-GI 2018-12-9 28 4.562 Here I would like to replace the repeated values with NA in both x and y columns. The code I have tried using dplyr : (1)df <- df %>% group_by(box_num) %>% arrange(box_num,date) %>% mutate(df$x[duplicated(df$x),] <- NA) It creates a new column with all NA's instead of just replacing a repeated value with NA (2)df <- df %>% group_by(box_num) %>%

Is there a way to do symbolic links to the blob data when using Azure Storage to avoid duplicate blobs?

混江龙づ霸主 提交于 2019-12-05 10:25:17
I have a situation where a user is attaching files within an application, these files are then persisted to Azure Blob storage, there is a reasonable likelihood that there are going to be duplicates and I want to put in place a solution where duplicate blobs are avoided. My first thought is to just name the blob as filename_hash but that only captures a subset of duplicates, then filesize_hash was then next thought. In doing this though it seems like I am losing some of the flexibility of the blob storage to represent the position in a hierarchy of the file, see: Windows Azure: How to create

Finding all rows with unique combination of two columns

女生的网名这么多〃 提交于 2019-12-05 10:09:04
I have this table messages ; sender_id recipient_id 1 2 1 3 1 3 2 1 3 1 2 3 I wish to select rows such that: Either sender_id or receiver_id = current_user.id . The other field should be unique. I.e. I want to select unique from table where sender_id = 2 or recipient_id = 2 and I need this result: sender_id recipient_id 2 1 2 3 How to do it? Why? Because I wish to build a facebook-like inbox in which sent and received messages are aggregated, and this query is the bottleneck so far. I am using rails 3.2 and Postgres 9.3. SELECT sender_id AS user_id, recipient_id AS other_user_id FROM messages

Transpose duplicated rows to column in R

三世轮回 提交于 2019-12-05 09:39:16
I have a large data.frame (20000+ entries) in this format: id D1 D2 1 0.40 0.21 1 0.00 0.00 1 0.53 0.20 2 0.17 0.17 2 0.25 0.25 2 0.55 0.43 Where each id may be duplicated 3-20 times. I would like to merge the duplicated rows into new columns, so my new data.frame looks like: id D1 D2 D3 D4 D5 D6 1 0.40 0.21 0.00 0.00 0.53 0.20 2 0.17 0.17 0.25 0.25 0.55 0.43 I've manipulated data.frames before with plyr, but I'm not sure how to approach this problem. Any help would be appreciated.Thanks. The best option would be to just use melt and dcast from "reshape2". But before we jump to that option,

Near duplicate detection in Solr

若如初见. 提交于 2019-12-05 09:28:14
问题 Solr is being used to search through a database of user-generated listings. These listings are imported into Solr from MySQL via the DataImportHandler. Problem: Quite often, users report the same listing to the database, sometimes with minor changes to their listing post to avoid being easily detected as a duplicate post. How should I implement a near-duplication detection with Solr? I do not mind having near-duplicate listings in the Solr index as long as the search results do not contain

Deal with duplicate entries in azure notification hub for the same device

偶尔善良 提交于 2019-12-05 08:50:40
I am using windows azure notification hub in my application to provide notifications to the user. Below is the code of the API that registers the devices on notification hub. var platform = registrationCall["platform"].ToString(); var installationId = registrationCall["instId"].ToString(); var channelUri = registrationCall["channelUri"] != null ? registrationCall["channelUri"].ToString() : null; var deviceToken = registrationCall["deviceToken"] != null ? registrationCall["deviceToken"].ToString() : null; string RegistrationID = registrationCall["RegistrationID"] != null ? registrationCall[

Hibernate + “ON DUPLICATE KEY” logic

我是研究僧i 提交于 2019-12-05 08:08:49
I am looking for a way to save or update records, according to the table's unique key which is composed of several columns). I want to achieve the same functionality used by INSERT ... ON DUPLICATE KEY UPDATE - meaning to blindly save a record, and have the DB/Hibernate insert a new one, or update the existing one if the unique key already exists. I know I can use @SQLInsert( sql="INSERT INTO .. ON DUPLICATE KEY UPDATE") , but I was hoping not to write my own SQLs and let Hibernate do the job. (I am assuming it will do a better job - otherwise why use Hibernate?) This doesn't really sound like

Automated-refactoring tool to find similar duplicate source code for Java/Javascript?

二次信任 提交于 2019-12-05 05:55:05
I'm looking for a tool to find duplicate or similar code of Java/Javascript. I can't tell the exact definition of " similar ", but I wish the tool is smart enough and give me advices to refactor the code, e.g., (1) class A and class B have imilar methods (e.g., there 5 methods have same method name, arguments and similar implementation appearing in both classes), then it should advise to move these similar methods into a base class. (2) class A has similar code lines at different places multiple times, the tool should advise to move these similar code lines into a single method. I tried PMD