A Pen by Chris Coyier on CodePen.
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
#!/bin/bash | |
search_all_up() { | |
# extended from https://stackoverflow.com/a/19011599/370746 | |
local look=${PWD%/} | |
while [[ -n $look ]]; do | |
for name in $@ ; do | |
[[ -e $look/$name ]] && { | |
printf '%s\n' "$look/$name" | |
return |
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
// regexp group 1: visible text group 2: ansi codes | |
// eslint-disable-next-line no-control-regex | |
const ansiMatcher = new RegExp("([^\u001B\u009B]*)([\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))|$)", "g") | |
function stripAnsi (s) { | |
return s.replace(ansiMatcher, "$1") | |
} | |
function truncateAnsi (s, len) { | |
let total = 0 |
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
// table resize test for tty-table | |
const Table = require("tty-table") | |
const Chalk = require("chalk") | |
let failures = [] | |
function test (width, truncate, marginLeft) { | |
let output = new Table([ | |
{minWidth: 6, shrink: 0}, |
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
function isInViewport (elem, partially) { | |
let box = elem.getBoundingClientRect(), | |
top = box.top, | |
bottom = box.bottom, | |
right = box.right, | |
left = box.left, | |
h = window.innerHeight || document.documentElement.clientHeight, | |
w = window.innerWidth || document.documentElement.clientWidth, | |
fully = (top >= 0 && box.left >= 0 && bottom <= h && box.right <= w); |
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
// save: | |
localStorage.temp = JSON.stringify(Array.from(document.querySelectorAll('input')).map(x => {console.log(x.value); return x.value})) | |
// restore: | |
JSON.parse(localStorage.temp).forEach((x,i) => document.querySelectorAll('input').item(i).value = x) |
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
# for Dreamhost, need to adjust FcgidWrapper path for other hosts | |
AddHandler fcgid-script .html | |
FcgidWrapper "/dh/cgi-system/php72.cgi" .html |
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 encs = {json: 'application/json', text: 'text/plain', url: 'application/x-www-form-urlencoded', form: 'multipart/form-data'}, | |
xhrRequestDefaults = {method: 'POST', encoding: 'url', beforeCallback: function () {}, openedCallback: function () {}}; | |
/** | |
* Make http request to url with object data as body | |
* @param {string} url | |
* @param {(object | string)} [data] - post data, formatting controlled by encoding | |
* @param {object} [options] - object of options | |
* @param {string} [options.encoding] - body encoding 'none', 'url', 'form', 'json', 'text' or mime (content) type, default: 'url' | |
* @param {string} [options.contentType] - override automatic contentType, null disable automatic without sending one | |
* @param {function} [options.method] - 'GET', 'POST', 'PUT', etc, default: 'POST' |
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
#!/bin/bash | |
# clone a user | |
# usage: | |
# if you named this as below then | |
# change to the directory and run this command | |
# sudo bash clone-user.sh | |
# | |
# from: OregonJohn - https://unix.stackexchange.com/questions/204970/clone-linux-user-copy-user-based-on-another-one |
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
function twtInsertAfter(newNode, referenceNode) { | |
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); | |
} | |
setTimeout(function () { | |
var d = document, $q = d.querySelector.bind(d), $g = d.getElementById.bind(d); | |
if (!$q('#twt-engagement-tool-widget, .twt-engagement-tool-widget-container')) { | |
var i, e = document.createElement('div'); | |
e.id = 'twt-engagement-tool-widget'; | |
var paras = d.querySelectorAll('[itemprop="articleBody"] p'); |