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
| # 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'); |
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
| parseEmails: function (emailStr) { | |
| // remove RFC-822 adornments & normalize delimiters | |
| var rfc822Cleaner = /(?:"[^@"'<>]*?"|(?:^|\n| |,|;)(?:[^@"'<>])+?)\s*?<([-a-z0-9_.%+]+?@[-a-z0-9.]+?.[-a-z0-9]{2,63}?)>/gi, | |
| exchangeCleaner = /"(?:[^@"()])*?\(([-a-z0-9_.%+]+?@[-a-z0-9.]+?.[-a-z0-9]{2,63})\)(?:[^@"()])*?"\s*?<\1>/gi, | |
| cleanedStr = emailStr.replace(rfc822Cleaner, ' $1 ').replace(exchangeCleaner, ' $1 ').replace(/(\n|[;, ])+/g, ';'), | |
| emailList = _.split(cleanedStr, ';'); | |
| var re = /(?:^|\s|\n|[;,<"'(])([-a-z0-9_.%+]+@[-a-z0-9.]+?.[-a-z0-9]{2,63})(?:^|\s|\n|[;,>"')])/gi, | |
| emails = [], | |
| dummy = emailStr.replace(re, function (match, email) { emails.push(email); return '[' + email + ']';}); |
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
| #!/usr/bin/env python3 | |
| import os, sys, re | |
| skip = re.compile(sys.argv[3] if len(sys.argv) > 3 else '$.') | |
| def compare_dirs(d1: "old directory name", d2: "new directory name"): | |
| def print_local(a, msg): | |
| print('DIR ' if a[2] else 'FILE', a[1], msg) | |
| # ensure validity |
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 geti (value, prop) { | |
| if (_.isPlainObject(value)) { | |
| if (_.isString(prop) && prop !== '') { | |
| return geti(value, prop.split('.')); | |
| } else if (_.isArray(prop) && prop.length) { | |
| const key = _.toLower(prop.shift()), | |
| val = Object.keys(value).reduce(function (a, k) { | |
| if (a !== undefined) { | |
| return a; | |
| } |
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 humanizeDuration ($secs) { | |
| $secs = ($secs<1)? 1 : $secs; | |
| $tokens = array ( | |
| 31536000 => 'year', | |
| 2592000 => 'month', | |
| 604800 => 'week', | |
| 86400 => 'day', | |
| 3600 => 'hour', | |
| 60 => 'minute', | |
| 1 => 'second' |