find

Get or set element in a Javascript ES6 Map?

纵然是瞬间 提交于 2019-12-11 12:41:14
问题 Is it possible to find or add an element in one step in a Javascript Map? I would like to do the following in one step (to avoid looking twice for the right place of the key): // get the value if the key exists, set a default value otherwise let aValue = aMap.get(aKey) if(aValue == null) { aMap.set(aKey, aDefaultValue) } Instead I would like to search for the key only once. In c++, one can use std::map::insert() or std::map::lower_bound() In javascript the code could look like this: let

jQuery .find() in server response

三世轮回 提交于 2019-12-11 11:09:48
问题 I am trying to get the text inside a specific div in a server response. I used Firebug to see what the response was, and I can see my element in the returned code, but for some reason I can get jQuery to capture it. Here is what I am using: var response = $('<div />').html(serverData); $('#uploadedFiles').html($(response).find("#created").text()); alert($(response).find("#created").text()); Trying that just returns nothing, not text or anything. Am I doing this correctly? Note: The server

'find' (command) finds nothing with -wholename

邮差的信 提交于 2019-12-11 10:54:44
问题 Why does this command work: /home/user1/tmp $ find ./../.. -wholename '.*/tmp/file.c' -exec echo '{}' \; ./../../user2/tmp/file.c /home/user1/tmp $ And this command does not work? (finds nothing) /home/user1/tmp $ find /home -wholename '.*/tmp/file.c' -exec echo '{}' \; /home/user1/tmp $ 回答1: The first command generates file names starting with ./../.. . Thus the wholename pattern will match because they start with . . The second command generates filenames starting with /home . However, the

How do I position a datagridview to the searched text input

♀尐吖头ヾ 提交于 2019-12-11 10:41:04
问题 Using Windows forms and linq to Sql, I bound a datagridview to Products Table, I added to the form 1 Textbox to input the searched text. I wonder how to position the datagridview according to the text entered to find a given ProductName. Here I do not want to filter rows, I only want to reposition datagrid after each character entered, the used code: private void textBox1_TextChanged(object sender, EventArgs e) { var searchValue = textBox1.Text.Trim().ToUpper(); var qry = (from p in dc

Bash: Moving multiple files into subfolders

一曲冷凌霜 提交于 2019-12-11 10:24:36
问题 I have a folder with a couple thousand files and I want to move them into subfolders according to a string in the filename. The files all have a structure like something-run1_001.txt something-run22_1243.txt So I tried the following script in order to move all files with "run1" in it into a subfolder r1 and all "run22" files in a subfolder r22 (and so on) but it does no work that way and I get a message "File X is the same as file X". #!bin/bash for i in {1..39} do foldername=r$i #echo "

Cake PHP 3 needs limit option for find all method

拟墨画扇 提交于 2019-12-11 10:16:26
问题 Inside a cell I need to access the TreeOptions model. So I've wrote this : $this->loadModel( 'TreeOptions' ); $i = $this->TreeOptions->find( 'all' ); But when I do the foreach like this : foreach( $i as $row ) debug( $row->description ); It only returns the last record of the result. The only way I've found to make it work as desired is adding the limit clause : $i = $this->TreeOptions->find( 'all', [ 'limit' => 200 ] ); And then, I can get the whole set of records. What am I missing ? Thanks

How to grep query all files for two strings

萝らか妹 提交于 2019-12-11 10:10:05
问题 Here we go: I need to query php files which both have a TODO statement as well as my name . Both strings could be anywhere in the document (ie. line) and be positioned anywhere on 0-infinite lines (position 0-n). How to grep query for my name: find -name '*.php' -exec grep -in "fincken" {} + output: ./some/file.php:51: ramon fincken ./somefile.php:2: rfincken How to grep query for the TODOs find -name '*.php' -exec grep -n "TODO" {} + output: ./some/file.php:53: // TODO: foobar! ./some

find and cat to merge csv files

让人想犯罪 __ 提交于 2019-12-11 10:02:47
问题 I have thousands of files in sub-directories of ~/data. I wish to merge all those csv files with a certain extension say .x and save the merged file to ~/data/merged.x I know I need to use find,cat and >> with the option -iname, but I'm finding it hard to do. Thanks in advance 回答1: find ~/data -name "*.x" | while read file do cat $file >> ~/data/merged.x done 回答2: find ~/data -type f ! -name 'merged.x' -a -name '*.x' -exec cat {} \+ >> ~/data/merged.x 回答3: find ./data/ -type f -name "*.c*" |

Find function in HIVE

◇◆丶佛笑我妖孽 提交于 2019-12-11 10:01:34
问题 I want to check if a field contains a string. I want a function that would look like this: FIND("string_to_find",field_to_search) My data looks like this: field_to_search --------------- "no match in this string" "record 2 has no matches" "ahh finally xxxstring_to_findxxx is here" I am looking for a function that identifies that the specified string is contained and at what position the string starts. return ------ -1 -1 15 回答1: The built in locate function does nearly exactly what you need

Search text with Content.Find object in Word with VBA and recover the text found

[亡魂溺海] 提交于 2019-12-11 09:42:21
问题 I want to search an entire MSWord document for a text with wildcards and recover the strings found. something like that: Sub Macro1() Dim c As Range Set c = ActiveDocument.Contentsdf c.Find.ClearFormatting c.Find.Replacement.ClearFormatting With c.Find .Text = "start[abcde]end" .Replacement.Text = "" .Forward = True .wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False ' End With c.Find.Execute