Find index of last occurrence of a sub-string using T-SQL

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

What .NET collection provides the fastest search

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.

How to search by key=>value in a multidimensional array in PHP

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

Elastic search, multiple indexes vs one index and types for different data sets?

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)