Can I grep only the first n lines of a file?
The magic of pipes; head -10 log.txt | grep <whatever>
The magic of pipes; head -10 log.txt | grep <whatever>
Straightforward way? No, but I’ve used the reverse. Literally. In prior routines, to find the last occurence of a given string, I used the REVERSE() function, followed CHARINDEX, followed again by REVERSE to restore the original order. For instance: SELECT mf.name ,mf.physical_name ,reverse(left(reverse(physical_name), charindex(‘\’, reverse(physical_name)) -1)) from sys.master_files mf shows how to extract the actual … Read more
I dont think you can escape characters for github From searching code doc: You can’t use the following wildcard characters as part of your search query: . , : ; / \ ` ‘ ” = * ! ? # $ & + ^ | ~ < > ( ) { } [ ]. The … Read more
There is a similar question here: Control-r reverse-i-search in bash: how do you “reset” the search in Cygwin? Found another similar question on Super User: (reverse-i-search) in Bash Apparently, both mention Ctrl+s, which may do the trick. Hope that helps. I myself am trying to find a piece of code that does the reverse-i-search in … Read more
In the most general case, consider System.Collections.Generic.HashSet as your default “Contains” workhorse data structure, because it takes constant time to evaluate Contains. The actual answer to “What is the fastest searchable collection” depends on your specific data size, ordered-ness, cost-of-hashing, and search frequency.
$(‘*[id*=mytext]:visible’).each(function() { $(this).doStuff(); }); Note the asterisk ‘*’ at the beginning of the selector matches all elements. See the Attribute Contains Selectors, as well as the :visible and :hidden selectors.
Here a more mathematical way of seeing it, though not really complicated. IMO much clearer as informal ones: The question is, how many times can you divide N by 2 until you have 1? This is essentially saying, do a binary search (half the elements) until you found it. In a formula this would be … Read more
If you’re searching only for the filename, use: svn list -R file:///subversion/repository | grep filename Windows: svn list -R file:///subversion/repository | findstr filename Otherwise checkout and do filesystem search: egrep -r _code_ .
Code: function search($array, $key, $value) { $results = array(); if (is_array($array)) { if (isset($array[$key]) && $array[$key] == $value) { $results[] = $array; } foreach ($array as $subarray) { $results = array_merge($results, search($subarray, $key, $value)); } } return $results; } $arr = array(0 => array(id=>1,name=>”cat 1″), 1 => array(id=>2,name=>”cat 2″), 2 => array(id=>3,name=>”cat 1″)); print_r(search($arr, ‘name’, … Read more
There are different implications to both approaches. Assuming you are using Elasticsearch’s default settings, having 1 index for each model will significantly increase the number of your shards as 1 index will use 5 shards, 5 data models will use 25 shards; while having 5 object types in 1 index is still going to use … Read more