Skip to content

Instantly share code, notes, and snippets.

@jacky810124
jacky810124 / sw.js
Created March 29, 2018 07:02
PWA Day06 - generic fallback(network error)
self.addEventListener('fetch', function(event) {
event.respondWith(
// Try the cache
caches
.match(event.request)
.then(function(response) {
if (response) {
return response
}
return fetch(event.request)
@jacky810124
jacky810124 / sw.js
Created March 29, 2018 07:11
PWA Day06 - remove outdate cache
self.addEventListener('activate', function(event) {
event.waitUntil(
caches
.keys()
.then(function(cacheNames) {
return Promise.all(
cacheNames
.filter(function(cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
@jacky810124
jacky810124 / app.js
Created March 29, 2018 07:55
PWA Day06 - cache matchAll
caches
.open('example-cache')
.then(function(cache) {
cache
.matchAll('/images/')
.then(function(response) {
response.forEach(function(element, index, array) {
cache.delete(element)
})
})
const days = [
'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'
]
const data = {
'mon': [
{
start: '11:00',
end: '22:00'
}
],
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Document</title>
</head>
<body>
</body>
import React from 'react'
import style from './styles.scss'
class NumericKeyboard extends React.Component {
constructor (props) {
super(props)
this.state = {
}
import styles from './styles.scss'
class SomeComponent extends React.Component {
render () {
return (
<div className={styles['some-component']}>
SomeComponent
</div>
)
}
@jacky810124
jacky810124 / dark.md
Created October 29, 2018 10:11 — forked from a7madgamal/dark.md
Dark mode for Slack on MacOS
  1. Close slack
  2. Open this file /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  3. Append this to it
document.addEventListener('DOMContentLoaded', function() {
 $.ajax({
   url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
   success: function(css) {
 $("").appendTo('head').html(css);
const shuffle = list => {
const shuffledList = [...list];
for (
let currentIndex = shuffledList.length - 1;
currentIndex > 0;
currentIndex--
) {
const nextIndex = Math.floor(Math.random() * (currentIndex + 1));
const nextItem = shuffledList[nextIndex];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>JS Bin</title>
<style>
.progress-bar-wrapper {
position: relative;
background-color: #c8c8c8;