Skip to content

Instantly share code, notes, and snippets.

View pklauzinski's full-sized avatar

Philip Klauzinski pklauzinski

View GitHub Profile
@pklauzinski
pklauzinski / sumTwoMatch.js
Last active November 28, 2016 01:18
Returns true if any two numbers in given array add up to given integer. This was a "live" coding question I was given in an interview.
/**
* Returns true if any two numbers in list add up to num
*/
function sumTwoMatch(list, num) {
var i = 0,
match = false,
list2;
for (; i < list.length; i++) {
list2 = list.slice();
@pklauzinski
pklauzinski / jquery.icontains.js
Created June 24, 2015 20:08
Custom jQuery :icontains selector for finding element based on text in a page, case-insensitive
/**
* Example use:
* $('div:icontains("Text in page")');
* Will return jQuery object containing any/all of the following:
* <div>text in page</div>
* <div>TEXT in PAGE</div>
* <div>Text in page</div>
*/
$.expr[':'].icontains = $.expr.createPseudo(function(text) {
return function(e) {