Skip to content

Instantly share code, notes, and snippets.

View stephenorem's full-sized avatar

Stephen Orem stephenorem

View GitHub Profile
@stephenorem
stephenorem / searchDepth.js
Created February 5, 2018 18:57
searchDepth - find the depth of nested html elements; for example, ul/ol - uses jQuery
function searchDepth() {
var maxDepth = 0,
d,
parents,
myselector = 'ul, ol';
$(myselector).each( function(i) {
parents = $(this).parents(myselector);
d = parents ? parents.length + 1 : 1;
maxDepth = d > maxDepth ? d : maxDepth;
@stephenorem
stephenorem / Palindrome.java
Created February 5, 2018 19:08
evaluate whether or not a string is a palindrome; for example, 'red rum, sir, is murder'
/*
* Palindrome
*/
package palindrome;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Palindrome {
@stephenorem
stephenorem / elementsPlayerLoad.js
Created February 5, 2018 19:23
Load parameters into html elements on page load, for later use as user interacts with page/video player. Handle player when user interacts.
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
var els = document.getElementsByClassName("vidlink");
// assign attributes needed for actions, self invoking on page load
(function () {
Array.prototype.forEach.call(els, function(el, i){
var newAtts = ["data-vidname", "data-vidlect"];
var newNames = ["vidname", "vidlect"];
Array.prototype.forEach.call(newAtts, function(newAtt, j){