search

Better file search algorithm than creating a list of files

情到浓时终转凉″ 提交于 2019-12-24 02:42:31
问题 For a project I'm doing I made a java program that searches for a file specified by user input. The code starts searching in a base directory specified by the user (ie: C:). It loops through all the files in this directory checking if the filename matches the search term given by the user, if it does match, the files absolute path is added to a string. If the file is a directory it is added to a list to be dealt with later. When the base folder is finished being searched it will search/remove

Increment and decrements numbers

﹥>﹥吖頭↗ 提交于 2019-12-24 02:26:07
问题 I have this text with numbers: My numbers are 04, and 0005 My numbers are 05, and 0006 My numbers are 06, and 0035 My numbers are 07, and 0007 My numbers are 08, and 0009 This is the code I always used to increment or decrement numbers in a selection/block selection/column: p.e. increment the last 4 numbers in above text with 8: '<,'>s/\%V\<\d\{4}\>/\=submatch(0)+8/g but I noted today that it does strange things. This is the output: My numbers are 04, and 13 My numbers are 05, and 14 My

Live search localstorage (search in array)

若如初见. 提交于 2019-12-24 01:44:42
问题 this is what I what I have: And now I want to make the live search. The point is when you type in the textbox you automatically have to search in the localstorage with something that equals the text in the search box. All the data that doesn't matches dissapears. $("#searchbox").keyup(function(){ // Retrieve the input field text var searchtext = $(this).val(); // Loop through the local storage var a = {}; a = JSON.parse(localStorage.getItem('session')); alert(a); }); As you can see I make an

Search and replace only specific lines in R

≡放荡痞女 提交于 2019-12-24 01:36:16
问题 I would like to search and replace in my database some characters but not in all the lines. Here's my data base : 1. 41 R JEAN JAURES 93170 2. 42 AV DE STALINGRAD 93170 3. 51 57 R JULES FERRY 93170 4. 1 R DU HAVRE 93170 I would like to replace to have : 5. 41 RUE JEAN JAURES 93170 6. 42 AVENUE DE STALINGRAD 93170 7. 51 57 RUE JULES FERRY 93170 8. 1 RUE DU HAVRE 93170 So, I try the sub() function, but in 2. it will replace the first R so it will be STALING RUE AD instead of STALING R AD. I

How to find sum of node's value for given depth in binary tree?

社会主义新天地 提交于 2019-12-24 01:16:55
问题 I've been scratching my head for several hours for this... problem: Binary Tree (0) depth 0 / \ 10 20 depth 1 / \ / \ 30 40 50 60 depth 2 I am trying to write a function that takes depth as argument and return the sum of values of nodes of the given depth. For instance, if I pass 2, it should return 180 (i.e. 30+40+50+60) I decided to use breath first search and when I find the node with desired depth, sum up the value, but I just can't figure out how to find out the way which node is in what

Rails: How to use facets with search results

こ雲淡風輕ζ 提交于 2019-12-24 00:58:56
问题 I have a rails application where I am searching for repair shops. The search class method looks like this: def self.search(params) if params repairshop = Repairshop.where(:approved => true) if params[:radius].present? repairshop = repairshop.near(params[:location], params[:radius]) if params[:location].present? else repairshop = repairshop.near(params[:location], 200) if params[:location].present? end if params[:keywords].present? repairshop = repairshop.joins(:specializations).joins(:brands

Having a map with paths how to compare tham to given path?

▼魔方 西西 提交于 2019-12-24 00:51:33
问题 We have map of boost path to string pairs like name:location (absolute location paths a la usr/myfolder/ ). We are given with some location a la usr/myfolder/mysubfolder/myfile . How to find which of maps location fit to given url most? Example we have a map like which we can resort if we need: service1:myfolder/ service2:myfolder/mysubfolder/ service3:myfolder/myothersubfolder/ service4:myfolder/mysubfolder/myfile We are given value myfolder/mysubfolder/myfile/blablabla/ (path). We want to

Getting most similar rows in MySQL table and order them by similarity

浪尽此生 提交于 2019-12-24 00:49:20
问题 I have a database table that holds user's vehicles (cars, motorcycles). I want to get the most similar vehicles out of that table. Lets say the table holds the following columns (with some context to get the idea): table: vehicles vehicle_id (pk, auto-increment) model_id (BMW 3er, Honda Accord) fuel_type (gasoline, diesel) body_style (sedan, coupe) year engine_size (2.0L) engine_power (150hp) So in short I want to select N (usually 3) rows that have the same make_id (at least) and rank them

Trying to implement scoped autosuggestions with solr

前提是你 提交于 2019-12-24 00:48:41
问题 I am trying to implement scoped autosuggestions like in ecommerce websites like amazon etc. eg. if i type Lego , the suggestions should come like Lego las in Names Lego in Toys where Names and Toys are solr field names. closest aid i got is from this discussion: solr autocomplete with scope is it possible? Which informed me that it isn't possible with the suggester which I am currently using. Until now, using the suggester I am able to achieve autosuggestions from a single solr field. [the

Ignore empty textboxes while searching in database

本小妞迷上赌 提交于 2019-12-24 00:43:50
问题 This code is able to search and load data to DataGridView based on values provided in search form text boxes. If I left any text box blank, there is no search result since the SQL query is combined with "AND". How can I ignore the empty textboxes while searching (from SQL query or C# code)? private void btnSearch_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); String select = "SELECT DocumentNo, Revision, DocumentTitle, DocumentType FROM DocumentLog WHERE DocumentNo Like '%" +