Skip to content

Instantly share code, notes, and snippets.

View wesbos's full-sized avatar
🔥
SLAYING BUGS

Wes Bos wesbos

🔥
SLAYING BUGS
View GitHub Profile
@wesbos
wesbos / service-worker.js
Created March 24, 2022 18:26
Nuke a service worker from inside a service worker
// put this in a file where your service worker used to live, like yourdomain.com/service-worker.js. You can find out this path in the SW dev tools of your browser
self.addEventListener('install', (e) => {
console.log('[Service Worker] Installing Service Worker ...', e);
self.skipWaiting();
});
self.addEventListener('activate', (e) => {
console.log('[ServiceWorker] Activate');
self.registration
interface Without {
without(withoutWord: string): boolean;
}
// 1. Easiest / the way I'd do it
function youCantSpell(word: string): Without {
return {
without(withoutWord: string) {
return word.includes(withoutWord);
}
[
"",
"AC",
"AD",
"AE",
"AF",
"AG",
"AI",
"AL",
"AM",
function update(cache, payload) {
cache.evict(cache.identify(payload.data.deleteCartItem));
}
const [removeFromCart, { loading }] = useMutation(REMOVE_FROM_CART_MUTATION, {
variables: { id },
update,
// When the optimistic response comes back, it seems to re-fetch every single query on the page, leaving `data` from queries undefined (and loading and error undefined as well), causing the layout to break.
// // The error itself comes from next.js, and it does seem that the item is evicted from the cache before that happens...
// optimisticResponse: {
This file has been truncated, but you can view the full file.
[[{"id":1,"start":2.46,"end":21.12,"text":"Hello, everybody, and welcome to syntax. This is a new podcast that Scott and I are launching. And we already have three episodes recorded. And we'll be launching them shortly. For now we just wanted to let you know that we're going to be launching this podcast. And to sort of get you subscribe to the feed so that when they're ready to drop, you're ready to get them.","speaker":"Wes Bos","initials":"WB","timestamp":{"hh":"00","mm":"00","ss":"02"}},{"id":2,"start":21.3,"end":27.66,"text":" And this is a web development podcast filled with tasty tips and treats for web developers. ","speaker":"Scott Tolinski","initials":"ST","timestamp":{"hh":"00","mm":"00","ss":"21"}},{"id":3,"start":27.96,"end":39.42,"text":"Oh, oh, yeah. So a little bit about ourselves. My name is Wes Bos. I am a full stack developer from Canada. And I essentially create training courses that help web developers get better at their job. ","speaker":"Wes Bos","initials":"WB","timestamp":{"hh":"00","
@wesbos
wesbos / download-shows.ts
Created November 11, 2020 02:07
deno syntax episode downloader
// deno run --allow-net --allow-write download-shows.ts
import { download } from "https://deno.land/x/download/mod.ts";
const showList = 'https://syntax.fm/api/shows';
async function getShowList(): Promise<Show[]> {
const list = await (await fetch(showList)).json();
return list;
}
[
{
"city": "New York",
"growth_from_2000_to_2013": "4.8%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": "8405837",
"rank": "1",
"state": "New York"
},
@wesbos
wesbos / node-google-speech-to-text.js
Created September 30, 2020 14:47
Syntax Speech to Text
import speech from '@google-cloud/speech';
import fs from 'fs';
import dotenv from 'dotenv';
dotenv.config();
async function main() {
const client = new speech.SpeechClient();
const config = {
@wesbos
wesbos / fake.js
Created September 16, 2020 15:26
fake-your-git-history.js
let currentColor = '#ebedf0';
let clicking = false;
const boxes = document.querySelectorAll('.js-calendar-graph-svg rect');
const graph = document.querySelector('.js-calendar-graph-svg');
// code for switching the current color
function handleColorChange(e) {
const el = e.currentTarget;
currentColor = el.style['background-color'];
console.log(currentColor)
function invert() {
// grab the favicon
const icon = document.querySelector('link[rel*="icon"]');
if (!icon) return;
// make a canvas
const canvas = document.createElement('canvas');
canvas.width = 128;
canvas.height = 128;
document.body.append(canvas);
const ctx = canvas.getContext('2d');