Skip to content

Instantly share code, notes, and snippets.

@easrng
easrng / serve.ts
Last active June 2, 2024 05:42
cross-runtime http `serve` function for js
/// <reference lib="webworker" />
// @ts-ignore
type _makeTSPlaygroundLoadTheBunTypes = import("bun-types");
type ServeOptions = {
fetch: (req: Request) => PromiseLike<Response> | Response;
port?: number;
hostname?: string;
signal?: AbortSignal;
@easrng
easrng / install.sh
Created February 16, 2024 10:52
install busybox shims on vfat filesystem (no symlinks) (bbins should be list of paths busybox --install fails on)
while IFS= read -r line; do printf '#!/bin/busybox ash\nexec busybox %s "$@"\n' "$(echo "$line" | busybox sed -E 's/.+\/([^\/]+)$/\1/')" >"$line"; busybox chmod +x "$line"; done < ./bbins
@easrng
easrng / AO3-style content warnings.toml
Created February 3, 2024 09:25
prechoster (https://cloudwithlightning.net/random/chostin/prechoster/) template for AO3-style content warnings on cohost
version = 1
title = 'Svelte Templating'
[[modules]]
plugin = 'source.svelte'
data.contents = '''
<script>
import AO3 from "./AO3.svelte";
</script>
import { lowercaseKeys } from "https://esm.town/v/stevekrouse/lowercaseKeys?v=1";
import OpenAI from "npm:openai@^4.0.0";
const openai = new OpenAI();
const input = String
.raw`Some types are fine to use from multiple threads, as long as only a single thread at a time uses a
particular value. An example here would be a ${"`"}Cell<i32>${"`"}. If two threads have a reference to a cell
at the same time, a ${"`"}&Cell<i32>${"`"}, we are in trouble --- ${"`"}Cell${"`"}'s loads and stores are not atomic
and are UB by definition if used concurrently. However, if two different threads have exclusive
access to a ${"`"}Cell${"`"}, that's fine --- because the access is exclusive, it necessary means that it is
not simultaneous. That is, it's OK for thread A to _send_ a ${"`"}Cell<i32>${"`"} to a different thread B,
@easrng
easrng / cwtch-bin.nix
Last active December 9, 2023 06:10
Cwtch (Metadata Resistant Chat) packaged for nix
{
stdenv, lib, fetchurl, autoPatchelfHook, makeWrapper,
zlib, gdk-pixbuf, cairo, libepoxy, at-spi2-atk, glib, gtk3, pango, harfbuzz, fontconfig
}:
stdenv.mkDerivation rec {
pname = "cwtch-bin";
version = "1.13.2";
src = fetchurl {
@easrng
easrng / normalizeMime.js
Created November 8, 2023 07:27
normalize MIME types for comparison
function normalizeMime(string) {
let pos = 0;
let normalized = "";
const consume = (regex) => {
const match = string.match(regex);
if (!match)
throw new SyntaxError(
"failed to match /" +
regex.source +
"/" +
@easrng
easrng / useStorage.js
Created November 7, 2023 22:22
a preact hook for webextension storage
function useStorage() {
const [storage, setStorage] = useState(null)
useEffect(() => {
const listener = async () => {
const { storage } = await browser.storage.sync.get("storage")
setStorage(storage)
}
browser.storage.sync.onChanged.addListener(listener)
listener()
return () => {
$[x2 **Comprehensive MFM test**]
This file uses every MFM feature as of [commit 30efd93](https://github.com/misskey-dev/misskey/blob/1d9b5ae1ba6d98cb496367d955fd691371d31f71/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts). **It does not include Firefish's extensions!**
text
**bold**
~~strike~~
*italic*
@easrng
easrng / README.md
Last active October 2, 2023 21:33
Nicer WebDAV listings in Firefox

Nicer WebDAV listings in Firefox

This CSS makes WebDAV listings look nicer in Firefox. Unfortunately it doesn't work right with userstyle addons, so you need to add it to your userContent.css file.

Before After
just a bunch of text in the default font running together with no line breaks or spaces a nicely-styled listing that's actually legible
How do I make a userContent.css file?
export * from 'file:/app/deno/internals.ts'