Skip to content

Instantly share code, notes, and snippets.

// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
// node [--trace-gc] local-storage-exmaple.cjs
// creates a server
// will drop /favicon.ico connections poorly without properly closing them
// `cleanupContext` AsyncLocalStorage + `cleanup` FinalizationRegistry will clean up
// will track the http request URL for errors in httpContext
// will show up in error generated for bad permissions
// will grant permissions in permissionsContext based upon query params / search params
// need ?fs=true to make / respond with a 200
//
// goto /?fs=true in browser to see it work
@wilsonpage
wilsonpage / swr.ts
Last active July 18, 2024 20:41
An implementation of stale-while-revalidate for Cloudflare Workers
export const CACHE_STALE_AT_HEADER = 'x-edge-cache-stale-at';
export const CACHE_STATUS_HEADER = 'x-edge-cache-status';
export const CACHE_CONTROL_HEADER = 'Cache-Control';
export const CLIENT_CACHE_CONTROL_HEADER = 'x-client-cache-control';
export const ORIGIN_CACHE_CONTROL_HEADER = 'x-edge-origin-cache-control';
enum CacheStatus {
HIT = 'HIT',
MISS = 'MISS',
REVALIDATING = 'REVALIDATING',
@Phate6660
Phate6660 / rust recommendations and alternatives.md
Last active May 29, 2024 12:35
My growing list of Rust programs to use.

Module Workers Polyfill npm version

This is a 1.1kb polyfill for Module Workers.

It adds support for new Worker('..',{type:'module'}) to all modern browsers (those that support fetch).

Usage

Copy module-workers-polyfill.js to your web directory, then load it using an import or a script tag. It just needs to be loaded before instantiating your Worker.

@ryancdotorg
ryancdotorg / web-crypto-scrypt.js
Last active January 9, 2024 14:40
An async JavaScript Scrypt implementation using Web Cryptography APIs for PBKDF2.
// SPDX-License-Identifier: MIT
//
// An async JavaScript Scrypt implementation using Web Cryptography APIs for PBKDF2
//
// Copyright © 2014-2018 cryptocoinjs (original implementation)
// Copyright © 2016 Richard Moore (asyncronous version)
// Copyright © 2019-2022 Ryan Castellucci (WebCrypto version)
//
// See also:
// https://github.com/cryptocoinjs/scryptsy
@lencioni
lencioni / array.includes.js
Last active February 17, 2020 14:01
Webpack module replacements for shims/polyfill packages
module.exports = function arrayIncludes(arr, search, fromIndex) {
return arr.includes(search, fromIndex);
};
@ServerlessBot
ServerlessBot / IAMCredentials.json
Last active December 20, 2023 16:50
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",
@notwaldorf
notwaldorf / list.md
Last active January 13, 2024 11:09
Meownica's packing list

Meownica's packing list

I travel a lot so I'm down to like 30 minutes of packing per any kind of trip. I always bring one carry-on suitcase for any trips up to 2 weeks (that I never check in unless forced) -- I have an Away suitcase because it's got a built-in (removable) battery, and amazing wheels.

🚨

  • 🆔Wallet & Passport
  • 💧Travel water bottle
  • 💳Travel credit cards (don't pay foreign currency fees!)
  • 💳Insurance cards
  • 💵Local currency you have
  • 🚎Local public transport cards
@Potherca
Potherca / README.md
Last active May 31, 2024 07:27
BASH script to clone all git repository in a Group on GitLab, or Organization on GitHub.

Introduction

Starting at a new employer always mean checking out various git repositories.

As the amount of repositories a company has grows, the time needed to clone all of those repositories also grows.

This script automates this task.

In order for this script to work, a personal access token is needed.