Skip to content

Instantly share code, notes, and snippets.

View localnerve's full-sized avatar

Alex Grant localnerve

View GitHub Profile
@dmgig
dmgig / main.py
Created September 12, 2021 00:08
Images to PDF
#!/bin/python3
import os
import sys
import shutil
import glob
from PIL import Image, ImageEnhance
import re
from fpdf import FPDF
@SahidMiller
SahidMiller / example.js
Last active July 7, 2021 15:23
Websocket via Libp2p (electrum-cash)
//Usage
const client = websocketOverLibp2p("/ip4/xxx.xx/tcp/xxx/ws", "/x/electrum")
const getBlocks = () => {
client.send(
JSON.stringify({
method: "blockchain.scripthash.listunspent",
params: [
"60e518016f265ca054e7044b818b3438d2886138c15cc7563f24bbe29e0cca91",
],
id: 1,
@sindresorhus
sindresorhus / esm-package.md
Last active June 30, 2026 15:30
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@mmazzarolo
mmazzarolo / service-workers.md
Last active April 22, 2024 03:40
Service Workers Tips

Service Workers Tips

Reloading a service worker

Reloading a page won't update/remove the previous version of its service worker. To make sure you're using the latest version of your service worker, make sure to check the "Update on reload" toggle in the "Application" ⭢ "Service Workers" section of the Chrome DevTools.

Simulate a network condition

To simulate a network condition (e.g.: offline, 3g, etc...) in a service worker on Chrome, uncheck the "Update on reload" toggle.

@samsch
samsch / stop-using-jwts.md
Last active July 8, 2026 04:28
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@gricard
gricard / webpack4upgrade.md
Last active April 20, 2025 23:06
Just some notes about my attempt to upgrade to webpack 4

If you enjoyed reading this, I'm intending to do more blogging like this over here: https://cdgd.tech

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
@steven2358
steven2358 / ffmpeg.md
Last active July 4, 2026 03:58
FFmpeg cheat sheet
@CodingDoug
CodingDoug / README.md
Last active June 7, 2026 00:27
Copying Data from a Google Sheet into Firebase Realtime Database in real time via Apps Script
@ebidel
ebidel / sw_caching_size.js
Last active November 16, 2022 11:31
Print service worker cache sizes and overall bytes cached.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
// Prints the bytes cached by service worker. Breaks out each cache
// overall in-memory bytes used by the Cache Storage API for the site.
async function getCacheStoragesAssetTotalSize() {
// Note: opaque (i.e. cross-domain, without CORS) responses in the cache will return a size of 0.