Skip to content

Instantly share code, notes, and snippets.

View smoj's full-sized avatar

Seme Mojugbe smoj

View GitHub Profile
@chad3814
chad3814 / gist:2924672
Last active January 16, 2024 20:27
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]
@nolanlawson
nolanlawson / readme.md
Last active September 12, 2022 19:40
What's missing in Microsoft's implementation of IndexedDB

What's missing in Microsoft's implementation of IndexedDB

Per a discussion with Christian Heilmann, I've put together a little doc outlining the current IndexedDB issues in IE 10-11 and Edge.

Major blockers

The biggest issue with IE's implementation is the lack of multiEntry, complex keys, or compound keypaths. Kyaw Tun (creator of YDN-DB) has grumbled a lot about this, and David Fahlander (Dexie.js creator) has written a heroic polyfill called IEGap that adds the missing behavior. (Although per David, it passes the W3C tests but not all the Dexie tests due to some tricky edge cases.)

@Rich-Harris
Rich-Harris / service-workers.md
Last active July 10, 2024 17:04
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active July 22, 2024 09:05
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { execSync } = require('child_process')
process.env.VUE_APP_VERSION = require('./package.json').version
process.env.VUE_APP_GIT_BRANCH = process.env.CI_BRANCH || execSync('git rev-parse --abbrev-ref HEAD').toString('utf8').trim()
module.exports = {
outputDir: 'public',
assetsDir: 'static',
@rupeshtiwari
rupeshtiwari / remove console log webpack.md
Last active September 21, 2021 12:54
remove console.log & comments from code webpack

Remove Console Log From Prod Bundle using Webpack

This will help you to remove console.log and comments from typescript or javascript files using webpack 4

Install uglifyjs-webpack-plugin

webpack remove console.log

npm i npm install uglifyjs-webpack-plugin --save-dev

create bs-module-app\webpack\webpack-optimization.config.js

@ganapativs
ganapativs / workbox-4.3.1-notes.js
Created June 19, 2019 06:01
Workbox - 4.3.1 - Notes
/* globals importScripts, workbox */
// https://developers.google.com/web/fundamentals/primers/service-workers/
// https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading
// https://developers.google.com/web/tools/workbox/modules/workbox-sw#using_workbox_sw_via_cdn
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js');
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active May 27, 2024 07:40
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Created March 12, 2021 14:29
Code for Service Workers 8 - Messaging between Clients and Workers
const APP = {
SW: null,
init() {
//called after DOMContentLoaded
//register our service worker
APP.registerSW();
document
.getElementById('colorForm')
.addEventListener('submit', APP.saveColor);