This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Derived from | |
// https://gist.github.com/taufansena/4d198d5a836c7a319e4b3ca3bbce27dc | |
if ( ! function_exists('make_pipeline') ) | |
{ | |
function make_pipeline(...$funcs) | |
{ | |
return function($arg) use ($funcs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if passed element or any of its ancestors match | |
* the passed CSS selector string or validation function. | |
* | |
* @param {Element} elm - the element whose DOM tree path will be compared against the selector or callback | |
* @param {string|function} selectorOrCallback - either a DOM selector string or a callback that returns a boolean | |
* @returns {boolean} true if an element is found to match the selector; false otherwise | |
*/ | |
function hasAncestor(elm, selectorOrFn) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure you pip install xmltodict | |
import xmltodict | |
import json | |
# https://stackoverflow.com/a/20725965 | |
def is_json(maybe_json): | |
try: | |
json_object = json.loads(maybe_json) | |
except ValueError as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// REFERENCE UNICODE TABLES: | |
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | |
// http://www.tamasoft.co.jp/en/general-info/unicode.html | |
// | |
// TEST EDITOR: | |
// http://www.gethifi.com/tools/regex | |
// | |
// UNICODE RANGE : DESCRIPTION | |
// | |
// 3000-303F : punctuation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const windowScrollBtm = elm => { | |
if (typeof window.scrollTo === 'function') | |
{ | |
// scroll to bottom of output log | |
const stats = elm.getBoundingClientRect() | |
const top = stats.top; | |
const height = stats.height; | |
const bottom = top + height; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/a/667706 | |
import time | |
# ##################################################################### # | |
# If interval is set to False (default), then then the limit is the # | |
# rate of execution calls per second to the provided function. # | |
# Example: @throttle(2.5, False) = function is limited to 2.5x/second # | |
# ##################################################################### # | |
# If interval is set to True, then the limit is the time in seconds # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data_to_search = ['stuff', 'yes', 'this', 'is', 'sweet' ] | |
most_wanted = [ 'sweet', 'stuff' ] | |
[ print(w) for w in data_to_search if w in most_wanted ] | |
# Output: | |
# stuff | |
# sweet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const onScreen = elm => { | |
const getViewportY = () => { | |
const top = window.pageYOffset || document.documentElement.scrollTop; | |
const bottom = top + document.documentElement.clientHeight; | |
return { top, bottom } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<script src="lib/yourlib.js"></script> | |
<script> | |
window.onload = function () { | |
EntryPoint.run(); | |
}; | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const debounce = (fn, time) => { | |
let timeout; | |
return function() { | |
const functionCall = () => fn.apply(this, arguments); | |
clearTimeout(timeout); | |
timeout = setTimeout(functionCall, time); | |
} |
NewerOlder