Check if one list contains element from the other

If you just need to test basic equality, this can be done with the basic JDK without modifying the input lists in the one line !Collections.disjoint(list1, list2); If you need to test a specific property, that’s harder. I would recommend, by default, list1.stream() .map(Object1::getProperty) .anyMatch( list2.stream() .map(Object2::getProperty) .collect(toSet()) ::contains) …which collects the distinct values in … Read more

How to get asp.net client id at external javascript file

I can suggest 2 ways. First way define your variables before call the javascript, inside the .aspx file that can be compiled. var ButtonXXXID = <%=buttonXXX.ClientID%> // and now include your javascript and use the variable ButtonXXXID Second way in the external javascript file, write your code as: function oNameCls(ControlId1) { this.ControlId1 = ControlId1; this.DoYourWork1 … Read more

jquery, find next element by class

In this case you need to go up to the <tr> then use .next(), like this: $(obj).closest(‘tr’).next().find(‘.class’); Or if there may be rows in-between without the .class inside, you can use .nextAll(), like this: $(obj).closest(‘tr’).nextAll(‘:has(.class):first’).find(‘.class’);

Combine/merge lists by elements names

You can do: keys <- unique(c(names(lst1), names(lst2))) setNames(mapply(c, lst1[keys], lst2[keys]), keys) Generalization to any number of lists would require a mix of do.call and lapply: l <- list(lst1, lst2, lst1) keys <- unique(unlist(lapply(l, names))) setNames(do.call(mapply, c(FUN=c, lapply(l, `[`, keys))), keys)

Get the string representation of a DOM node

You can create a temporary parent node, and get the innerHTML content of it: var el = document.createElement(“p”); el.appendChild(document.createTextNode(“Test”)); var tmp = document.createElement(“div”); tmp.appendChild(el); console.log(tmp.innerHTML); // <p>Test</p> EDIT: Please see answer below about outerHTML. el.outerHTML should be all that is needed.

Checking if array is multidimensional or not?

Use count() twice; one time in default mode and one time in recursive mode. If the values match, the array is not multidimensional, as a multidimensional array would have a higher recursive count. if (count($array) == count($array, COUNT_RECURSIVE)) { echo ‘array is not multidimensional’; } else { echo ‘array is multidimensional’; } This option second … Read more