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
self.addEventListener('install', (e) => { | |
e.waitUntil( | |
caches.open("precache").then((cache) => cache.add("/broken.png")) | |
); | |
}); | |
function isImage(fetchRequest) { | |
return fetchRequest.method === "GET" && fetchRequest.destination === "image"; | |
} |
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 sunIsUp(\DateTime $when, $lat, $lon): bool { | |
$whenTimestamp = $when->getTimestamp(); | |
$sunriseTimestamp = date_sunrise( | |
$whenTimestamp, | |
SUNFUNCS_RET_TIMESTAMP, | |
$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 | |
/** | |
* Fetches and Caches a Instagram Feed | |
* | |
* - Get an Instagram Developer Account here: https://www.instagram.com/developer/ | |
* - Create a new client, using the 'redirect URI' as https://rudrastyh.com/tools/access-token | |
* - Get an access token here: https://rudrastyh.com/tools/access-token | |
* - This file will return JSON - so use some AJAX on the front-end to display | |
* - Add the instagram-feed-cache.json file as ignored, to .gitignore | |
*/ |
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/ | |
// HTML files: try the network first, then the cache. | |
// Other files: try the cache first, then the network. | |
// Both: cache a fresh version if possible. | |
// (beware: the cache will grow and grow; there's no cleanup) | |
const cacheName = 'files'; |