const date = new Date(2012, 11, 20, 3, 0, 0)
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
{ | |
"USD": { | |
"symbol": "$", | |
"name": "US Dollar", | |
"symbol_native": "$", | |
"decimal_digits": 2, | |
"rounding": 0, | |
"code": "USD", | |
"name_plural": "US dollars" | |
}, |
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
// src: https://github.com/LeCoupa/awesome-cheatsheets | |
// Date Object CheatSheet | |
// The Date object is used to work with dates and times. | |
// More: http://www.w3schools.com/jsref/jsref_obj_date.asp | |
// 1. Instantiating a Date. | |
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 deltaDate(input, days, months, years) { | |
return new Date( | |
input.getFullYear() + years, | |
input.getMonth() + months, | |
Math.min( | |
input.getDate() + days, | |
new Date( | |
input.getFullYear() + years, | |
input.getMonth() + months + 1, | |
0 |
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
/* | |
This module creates an HTTPS web server and serves static content | |
from a specified directory on a specified port. | |
To generate a new cert: | |
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 | |
To remove the passphrase requirement: |
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
/* | |
* CHALLANGE: | |
* Cache `index.html` file using service worker. | |
* | |
* This bit of code is included in <script> tag of index.html | |
* if (navigator.serviceWorker) { | |
* navigator.serviceWorker.register('serviceworker.js', {scope: '/'}) | |
* } | |
* | |
*/ |
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
//src: https://github.com/tretapey/svelte-pwa/blob/master/public/service-worker.js | |
'use strict'; | |
// Update cache names any time any of the cached files change. | |
const CACHE_NAME = 'static-cache-v1'; | |
// Add list of files to cache here. | |
const FILES_TO_CACHE = [ | |
'/offline.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
self.addEventListener('activate', function(event) { | |
var cacheAllowlist = ['pages-cache-v1', 'blog-posts-cache-v1']; | |
event.waitUntil( | |
caches.keys().then(function(cacheNames) { | |
return Promise.all( | |
cacheNames.map(function(cacheName) { | |
if (cacheAllowlist.indexOf(cacheName) === -1) { | |
return caches.delete(cacheName); |
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
addEventListener('fetch', event => { | |
// Prevent the default, and handle the request ourselves. | |
event.respondWith(async function() { | |
// Try to get the response from a cache. | |
const cachedResponse = await caches.match(event.request); | |
// Return it if we found one. | |
if (cachedResponse) return cachedResponse; | |
// If we didn't find a match in the cache, use the network. | |
return fetch(event.request); | |
}()); |
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
body:before { | |
content: ''; | |
display: block; | |
position: fixed; | |
top: 0; | |
z-index: 7; | |
left: 0; | |
right: 0; | |
height: env(safe-area-inset-top); | |
width: 100%; |