This file contains 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 | |
// Create an array of timestamps for posts | |
// and put them into an array called $timestamps. | |
foreach ($timestamps as $timestamp) { | |
$day = date("j", $timestamp); | |
$hour = date("G", $timestamp); | |
if (isset($heatcalendar['posts'][$day][$hour])) { | |
$heatcalendar['posts'][$day][$hour]++; |
This file contains 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 | |
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
function sendWebmention($source, $target) { | |
$endpoint = false; | |
$options = array( |
This file contains 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
// Generate a timestamp (in seconds) on the server. This won't change if the page is served from a cache. | |
var serverTimestamp = <?php echo time(); ?>; | |
// Create a new Date object from the local date and time on the client. | |
var localDate = new Date(); | |
// Convert the local date and time to Universal Time (same as the server). | |
var localUTCString = localDate.toUTCString(); | |
// Create a new Date object from the UTC date and time on the client. | |
var UTCDate = new Date(localUTCString); | |
// Generate a timestamp (in seconds) from the UTC date and time on the client. | |
var clientTimestamp = UTCDate.getTime() / 1000; |
This file contains 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 (win, doc) { | |
win.addEventListener('load', function() { | |
var latlons = []; | |
doc.querySelectorAll('.h-geo').forEach( function(geo) { | |
var lat = geo.querySelector('data.p-latitude').getAttribute('value'); | |
var lon = geo.querySelector('data.p-longitude').getAttribute('value'); | |
if (lat && lon) { | |
latlons.push([lat, lon]); | |
} | |
}); |
This file contains 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 | |
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
function postToMedium($data=array()) { | |
$user_id = "XXXX"; | |
$accessToken = "XXXX"; | |
This file contains 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 | |
function getEmbedCode($url="") { | |
$return = ''; | |
$providers = array( | |
'flickr.com' => 'https://www.flickr.com/services/oembed/', | |
'huffduffer.com' => 'https://huffduffer.com/oembed', | |
'instagram.com' => 'https://api.instagram.com/publicapi/oembed', |
This file contains 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
// Limit the number of items in a specified cache. | |
function trimCache(cacheName, maxItems) { | |
caches.open(cacheName) | |
.then( cache => { | |
cache.keys() | |
.then(keys => { | |
if (keys.length > maxItems) { | |
cache.delete(keys[0]) | |
.then( () => { | |
trimCache(cacheName, maxItems) |
This file contains 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://github.com/jonathantneal/closest/blob/master/src/index.js | |
var ElementPrototype = window.Element.prototype; | |
if (typeof ElementPrototype.matches !== 'function') { | |
ElementPrototype.matches = ElementPrototype.msMatchesSelector || ElementPrototype.mozMatchesSelector || ElementPrototype.webkitMatchesSelector || function matches(selector) { | |
var element = this; | |
var elements = (element.document || element.ownerDocument).querySelectorAll(selector); | |
var index = 0; | |
while (elements[index] && elements[index] !== element) { | |
++index; | |
} |
This file contains 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
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication | |
// http://creativecommons.org/publicdomain/zero/1.0/ | |
/* | |
This function takes two arguments: | |
element: a reference to a DOM node in the document e.g. a button. | |
feedbackContent: a string of text or HTML. | |
An example of usage would be: | |
document.querySelector('button').addEventListener('click', function() { |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Checkbox</title> | |
<style> | |
body { | |
background-color: #fff; | |
color: #000; |