Skip to content

Instantly share code, notes, and snippets.

<?php
$SITEPATH = $_SERVER['DOCUMENT_ROOT'] . '/path/to/dir/';
function get_uri( $image, $mime = '' ) {
return 'data: ' . $mime . ';base64,'.base64_encode(file_get_contents( $image ));
}
?>
var $doc = $(document);
var $yourElement = $('#nav a');
$doc.on('mouseup', function(e) {
if ( ! $yourElement.is(e.target) && $yourElement.has(e.target).length === 0 ) {
// your code here
}
});
<?php
// REF: http://stackoverflow.com/questions/14780804/how-do-i-read-a-google-drive-spreadsheet-in-php
$spreadsheet_url="https://docs.google.com/spreadsheets/d/1MLAko1Eym5O-Qt7cRQb55RBWH3ZHW2_VmHCV0x1Bx5s/pub?gid=0&single=true&output=csv";
$stack = array();
if(!ini_set('default_socket_timeout', 15)) echo "<!-- unable to change socket timeout -->";
UPDATE wp_posts SET guid=replace(guid, 'http://old.url', 'http://new.url');
UPDATE wp_posts SET post_content=replace(post_content, 'http://old.url', 'http://new.url');
/*
// Source: https://madebymike.com.au//writing/service-workers/
<script>
if ( 'serviceWorker' in navigator && ( typeof Cache !== 'undefined' && Cache.prototype.addAll ) ) {
navigator.serviceWorker.register( '/sw.js' );
}
</script>
*/
Modal: http://www.humaan.com/modaal/
Tabs: http://www.scottohara.me/tabs/
Accordion: https://github.com/nico3333fr/jquery-accessible-accordion-aria
Slider: http://kenwheeler.github.io/slick/
Tooltips: https://github.com/scottaohara/a11y_tooltips
/**
* Create svg images
*
* @param string $name Icon name.
* @param array $opts Optional attributes.
*
* @return string
*/
function svg_icon( $name, $opts = array() ) {
/** @function
* @name debounce
* @description Utility method for debouncing the resize event
* @param {function} func
* @param {number} wait
* @param {object} immediate
* @example var myEfficientFn = debounce(function() { things to do }, 250);
* @example window.addEventListener( 'resize', myEfficientFn );
*/
/**
* @file A simple Ajax call that will work down to IE10
* @author Tim Wright
* @license MIT
* @example ajaxCall({ 'url' : 'http://...', 'type' : 'GET', 'data' : 'json' }, function( data ){ /callback function here/ });
*/
( function ( global ) {
'use strict';
/**
* Get URL params
*
* @param {String} query - The location.search query
* @returns {Object} - the params
*/
export const getUrlParams = ( query ) => {
const vars = query.split( '&' );
const queryString = {};