Skip to content

Instantly share code, notes, and snippets.

View zwacky's full-sized avatar

Simon zwacky

View GitHub Profile
import * as firebase from 'firebase/app';
import 'firebase/storage';
import 'firebase/database';
// ...
firebase.initializeApp(firebaseConfig);
import * as firebase from 'firebase';
@zwacky
zwacky / .eslintrc.json
Last active June 24, 2017 17:20
a basic eslint config that supports async/await
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions":{
"ecmaVersion": 8
},
@zwacky
zwacky / .babelrc-basic
Last active June 24, 2017 16:45
a basic .babelrc for setting up async/await support
{
"presets": [
[
"env", {
"targets": {
"browsers": [
"last 2 versions",
"IE >= 9"
]
}
@zwacky
zwacky / firebase.json
Created June 12, 2017 21:48
firebase configuration for ionic 3 PWA that excludes service-worker.js from caching competely
{
"hosting": {
"public": "./platforms/browser/www/",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
@zwacky
zwacky / check-service-worker-update.ts
Last active September 13, 2021 10:11
the wrapped service-worker in index.html can then be called if any update is available
// listen to the service worker promise in index.html to see if there has been a new update.
// condition: the service-worker.js needs to have some kind of change - e.g. increment CACHE_VERSION.
window['isUpdateAvailable']
.then(isAvailable => {
if (isAvailable) {
const toast = this.toastCtrl.create({
message: 'New Update available! Reload the webapp to see the latest juicy changes.',
position: 'bottom',
showCloseButton: true,
});
@zwacky
zwacky / register-service-worker.js
Last active October 19, 2020 11:12
registers a service-worker which is wrapped in a promise that resolves with the value whether the service-worker has been updated or not
// make the whole serviceworker process into a promise so later on we can
// listen to it and in case new content is available a toast will be shown
window.isUpdateAvailable = new Promise(function(resolve, reject) {
// lazy way of disabling service workers while developing
if ('serviceWorker' in navigator && ['localhost', '127'].indexOf(location.hostname) === -1) {
// register service worker file
navigator.serviceWorker.register('service-worker.js')
.then(reg => {
reg.onupdatefound = () => {
const installingWorker = reg.installing;
@zwacky
zwacky / fix_itunes_upload.sh
Created May 11, 2017 09:32
Stuck on Authenticating with iTunes Store (error code -22421)
# ISSUE:
# Stuck authenticating with Itunes Store
#
# ERROR:
# Archive upload failed due to the issues listed below.
# This action could not be completed. Try again (-22421)
cd ~
mv .itmstransporter/ .old_itmstransporter/
"/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/itms/bin/iTMSTransporter"
@zwacky
zwacky / sizeup.lua
Last active March 17, 2017 10:35 — forked from josephholsten/sizeup.lua
SizeUp in Hammerspoon
-- === sizeup ===
--
-- SizeUp emulation for hammerspoon
--
-- To use, you can tweak the key bindings and the margins
local sizeup = { }
--------------
-- Bindings --
@zwacky
zwacky / less-error-prone-dom-manipulation.js
Last active March 1, 2017 12:53
DOM manipulation without explicitly checking if they exist already in the DOM
// less error prone DOM manipulation
[].filter.call([document.querySelector('.single-selected-class')], item => item)
.forEach(item => item.blur());