Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View davidhund's full-sized avatar

David Hund davidhund

View GitHub Profile
@davidhund
davidhund / wp-permissions.sh
Created November 26, 2020 11:02
Set Wordpress File/Folder Permissions in shell
# From: https://www.smashingmagazine.com/2014/05/proper-wordpress-filesystem-permissions-ownerships/
# CAREFULL! This searches from current path (.)
# Files: 644
sudo find . -type f -exec chmod 644 {} +
# Folders: 755
sudo find . -type d -exec chmod 755 {} +
@davidhund
davidhund / imapsync.sh
Created November 16, 2020 08:01
Sync IMAP mail through Docker imapsync - example
# imapsync - https://imapsync.lamiral.info/
# Sync IMAP mailboxes between hosts
# Run through Docker
# Some Documentation: https://imapsync.lamiral.info/doc/TUTORIAL_Unix.html
# --dry —> DRY-RUN, NO ACTUAL CHANGES (YET)
# --search —> "SENTSINCE 1-Jan-2021", Get new-ish mail only
docker run gilleslamiral/imapsync imapsync \
--dry \
--host1 mail.HOST1.com \
--user1 USER_HOST1 \
@davidhund
davidhund / writeEl.js
Created November 22, 2018 20:55
test js
// Test (ignoreme)
(function(win,doc){
var sc = doc.getElementById('myScript');
if (sc) {
var el = doc.createElement('p');
el.innerHTML = 'Yo, this is from the <b>SCRIPT</b> include! :-)';
el.style.color = 'green';
@davidhund
davidhund / getSiblings.js
Created September 6, 2018 15:44
getSiblings in ES
/**
* getSiblings(element)
*
* @param {HTMLElement} HTML Element to find siblings of
* @returns {Array} HTML sibling elements of `element`
*
* Based on: https://twitter.com/ChrisFerdinandi/status/1037350582887927809
*/
const getSiblings = (elem) => {
// Return empty Array when given Element is not given or not a HTML Element
@davidhund
davidhund / log-highest-zIndex.js
Last active August 15, 2018 12:11
Log the highest used z-index
/**
* Log highest z-index used on page
* @author: davidhund / @valuedstandards
*
* Do not use this in (production) JS code!
* To be used as e.g. a Chrome Devtools snippet, bookmarklet etc..
*/
(function(w,d,z) {
console.log(`Highest z-index in use is: %d`,
Math.max(...
@davidhund
davidhund / getJSON.js
Created December 15, 2017 09:40
getJSON AJAX response, IE11 compat
/**
* Make AJAX call for JSON resource
* Supports IE11 and browsers that do not allow responseType='json'.
* https://mathiasbynens.be/notes/xhr-responsetype-json
* ----------------------------------------------------- */
var getJSON = function(url, successHandler, errorHandler) {
var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
var supportsJSON = (function() {
if (typeof XMLHttpRequest == 'undefined') { return false; }
@davidhund
davidhund / getURLParamsFromString.js
Created December 13, 2017 12:24
Get URL parameters from String
/**
* Get URL parameters from String
* source: https://css-tricks.com/snippets/javascript/get-url-variables/
* @param {String} url The URL
* @return {Object} The URL parameters
*/
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
@davidhund
davidhund / retext-stream-example.js
Created November 2, 2017 13:29
retext example does not work as expected w.r.t. remark example
var unified = require('unified');
var createStream = require('unified-stream');
var parse = require('rehype-parse');
var rehype2retext = require('rehype-retext');
var rehype2remark = require('rehype-remark');
var remarkStringify = require('remark-stringify');
var retextStringify = require('retext-stringify');
var english = require('retext-english');
// Why does the following (2remark) work (output MD)

Front-end Performance

The Case for FED Performance Optimisation

A fast website is essential for a good user experience (UX), conversion and findability.

Performance == User Experience == Conversion

For real-world examples of this see https://wpostats.com/

@davidhund
davidhund / print.css
Created April 14, 2017 08:52
An example (starter) Print stylesheet
/**
* = PRINT styles
*
* - Imported in global.css (http://www.phpied.com/delay-loading-your-print-css/)
* - Taken straight from: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css#L197
*
* @TODO:
* - Add to this?
*
* ========================================================================= */