Skip to content

Instantly share code, notes, and snippets.

View DaveHudson's full-sized avatar

Dave Hudson DaveHudson

View GitHub Profile
@DaveHudson
DaveHudson / machine.js
Created November 28, 2019 09:29
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Last active November 28, 2019 08:32
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Created November 27, 2019 17:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Last active November 27, 2019 15:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / machine.js
Created November 24, 2019 15:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@DaveHudson
DaveHudson / terminal-notification-icon.sh
Created February 26, 2019 13:31
Bash script to change icon in terminal-notifier
#!/bin/bash
# Copy Terminal.icns
cp "./src/assets/Terminal.icns" "node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Resources/"
# Edit Info.plist
sed -i '' "s/nl.superalloy.oss.terminal-notifier/com.applification.oss.terminal-notifier/g" "node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/Info.plist"
@DaveHudson
DaveHudson / service-worker.js
Created March 6, 2018 10:59
Service Worker
importScripts("/precache-manifest.1ffc866b68fc483cce70dd1aa121dd71.js", "https://storage.googleapis.com/workbox-cdn/releases/3.0.0-beta.1/workbox-sw.js");
workbox.precaching.precacheAndRoute(self.__precacheManifest || []);
@DaveHudson
DaveHudson / preact.config.js
Created February 26, 2018 19:12
preact.config.js
const WorkboxPlugin = require('workbox-webpack-plugin');
export default config => {
config.plugins.push(
new WorkboxPlugin.InjectManifest({
swSrc: './service-worker.js',
swDest: './service-worker.js',
include: [/\.html$/, /\.js$/, /\.svg$/, /\.css$/, /\.png$/, /\.ico$/]
})
);
@DaveHudson
DaveHudson / package.json
Last active March 6, 2018 10:54
package.json
"scripts": {
"build": "preact build --no-service-worker --template src/template.html",
"serve": "preact build --no-service-worker --template src/template.html && preact serve"
}
@DaveHudson
DaveHudson / index-script.html
Created February 26, 2018 19:11
Add Service Worker to HTML
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(function (registration) {
console.log('Service Worker registration successful with scope: ', registration.scope)
})
.catch(function (err) {
console.log('Service Worker registration failed: ', err)
})
}