This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"", | |
"AC", | |
"AD", | |
"AE", | |
"AF", | |
"AG", | |
"AI", | |
"AL", | |
"AM", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[{"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"," |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"city": "New York", | |
"growth_from_2000_to_2013": "4.8%", | |
"latitude": 40.7127837, | |
"longitude": -74.0059413, | |
"population": "8405837", | |
"rank": "1", | |
"state": "New York" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |