Skip to content

Instantly share code, notes, and snippets.

@nichoth
nichoth / CYPHERLINK.md
Created March 15, 2024 22:40 — forked from dominictarr/CYPHERLINK.md
Cypherlinks
@nichoth
nichoth / Weekly Summary.md
Last active February 4, 2024 22:35 — forked from paprikka/Weekly Summary.md
Weekly Summary Template (Obsidian)

Carried Over

  • share a new drawing this week

Main Focus

[!NOTE] Progress on work. Don't rush.

It's Friday. I have a rough timeline for my work with XXX and we're discussing the specifics. I'm feeling tired, but not burned out. I feel like I have balance. I published every day. I learned something new (a piece of tech/concept) and I wrote about it. We planned our trip to XXX. I've spoken with my brothers.

@nichoth
nichoth / deploy-succeeded.js
Created February 3, 2024 20:03 — forked from maxboeck/deploy-succeeded.js
publish notes via netlify deploy succeeded event
import fetch from 'node-fetch'
import dotenv from 'dotenv'
import Twitter from 'twitter'
import { decode } from 'html-entities'
dotenv.config()
// URL of notes JSON feed
const NOTES_URL = 'https://mxb.dev/notes.json'

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@nichoth
nichoth / components__ServiceWorkers.tsx
Created October 27, 2023 20:01 — forked from itsjavi/components__ServiceWorkers.tsx
Simple Service Worker for Next.js static assets
'use client'
import { useEffect } from 'react'
export function ServiceWorkers(): JSX.Element {
useEffect(() => {
if (typeof window === 'undefined') {
return
}
if ('serviceWorker' in navigator) {
import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
import { signal, effect } from "@preact/signals-core";
interface CustomStorage {
getItem(key: string): void;
setItem(key: string, value: string | null): void;
}
/**
* A version of signal() that persists and recalls its value in localStorage.
*
@nichoth
nichoth / index.html
Last active August 20, 2023 20:36 — forked from dsheiko/index.html
Service-worker to prefetch remote images (with expiration) and respond with fallback one when image cannot be fetched
<!DOCTYPE html>
<html>
<head>
<title>Service-worker demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
if ( "serviceWorker" in navigator ) {
@nichoth
nichoth / evented-p2p.js
Created May 16, 2023 01:15 — forked from heapwolf/evented-p2p.js
real time streaming p2p demo with socket runtime
import { Peer } from 'socket:peer'
import process from 'socket:process'
import Buffer from 'socket:buffer'
import fs from 'socket:fs'
window.onload = async () => {
const clusterId = '14ecd42...' // truncated, make your own clusterId
const publicKeyHex = 'c43c1ddd...' // truncated, make your own hex encoded key
const privateKeyHex = '46adc2f8e9077c72...' // truncated, make your own hex encoded key
@nichoth
nichoth / sw.js
Created May 8, 2023 02:25 — forked from ukmadlz/sw.js
Cloudinary PWA React Advanced Service Worker
(function () {
"use strict";
var cacheNameStatic = 'cloudinary-pwa-react-v2';
var currentCacheNames = [ cacheNameStatic ];
var cachedUrls = [
// 3rd party CDN
'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css',