View what.js
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: { |
View syntax-transcripts.json
This file has been truncated, but you can view the full file.
View download-shows.ts
// 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; | |
} |
View cities.json
[ | |
{ | |
"city": "New York", | |
"growth_from_2000_to_2013": "4.8%", | |
"latitude": 40.7127837, | |
"longitude": -74.0059413, | |
"population": "8405837", | |
"rank": "1", | |
"state": "New York" | |
}, |
View node-google-speech-to-text.js
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 = { |
View fake.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) |
View invert-favicon.js
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'); |
View coo.js
// get an array of all the keys on the window | |
const dirty = Object.keys(window); | |
// Then create an iframe set to nothing | |
const iframe = document.createElement('iframe'); | |
iframe.src = ''; | |
// put it into the DOM | |
document.body.append(iframe); |
View sarcastic.js
/* eslint-disable */ | |
String.prototype.sarcastic = function() { | |
return [...this] | |
.map((char, i) => char[`to${i % 2 ? 'Upper' : 'Lower'}Case`]()) | |
.join(''); | |
}; |
View tree.zsh
# Uses tree - install first: | |
# brew install tree | |
function t() { | |
# Defaults to 3 levels deep, do more with `t 5` or `t 1` | |
# pass additional args after | |
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst --filelimit 15 -L ${1:-3} -aC $2 | |
} |
NewerOlder