Skip to content

Instantly share code, notes, and snippets.

export function mapRecord<K extends string, V1, V2>(
input: Record<K, V1>,
mapper: (value: V1, key: K) => V2,
): Record<K, V2> {
const entries = Object.entries(input).map(([key, value]) => [key, mapper(value as V1, key as K)]);
return Object.fromEntries(entries);
}
#!/usr/bin/env bash
# Usage: rgb [Red 0-5] [Green 0-5] [Blue 0-5]
c=$((16+(${1:-0}*36)+(${2:-0}*6)+(${3:-0}*1)))
if [[ -t 1 ]]
then printf '\e[38:5:%dm%-3d\e[m\n' $c $c
else echo $c
fi
# Implemented by [Brave Ask](https://ask.brave.com)
# PS! Unchecked! Read before executing!
# make.R - Minimal make-like system for R
library(digest)
make <- function(target, rules) {
if (target %in% names(rules$files)) {
file <- rules$files[[target]]
deps <- file$depends

Archived chat with Brave Ask on 2026-02-05

> 4-vector potential eli5

The 4-vector potential is a way of combining electric and magnetic fields into a single mathematical object that works nicely with Einstein's relativity.

Think of it like this: Instead of treating electric potential (voltage) and magnetic potential separately, we bundle them together into one 4-dimensional package. It has:

  • One time component: the regular electric potential (φ) you know from circuits
  • Three space components: the magnetic vector potential (A), which describes magnetic fields
#titlebar,
#toolbar-menubar {
display: none !important;
}
#TabsToolbar {
--height: 42px;
height: var(--height) !important;
transition: margin-bottom 200ms !important;
&:not(:has(#tabbrowser-arrowscrollbox tab ~ tab)) /* single tab */ {
export interface Observer<T> {
update(value: T): void;
}
export interface Observable<T> {
observe(observer: Observer<T>): Abortable;
}
export interface Abortable {
abort(): void;
#!/bin/bash
set -euo pipefail
main() {
install_deps
write_config
reload_wlmod
connect_wifi
echo SUCCESS
}
[p]=document.getElementsByTagName("player")
for(let parent=p.parentElement;parent;parent=parent.parentElement)
for(let c of parent.children) (c!=p&&!c.contains(p)) && (c.style='pointer-events:none!important;z-index:1'))
p.style='z-index:99;position:fixed;left:50%;top:50%;translate:-50% -50%;max-width:100vw;max-height:100vh;width:100%'
#!/usr/bin/env bash
[[ -z "$PORT" ]] && PORT=18181
[[ -z "$SAMPLING" ]] && SAMPLING=44100
help() {
printf 'Usage: ffstream %s\n' 'receive' 'send <address>'
}
operator=$1
import { createAgent, tool } from "langchain";
import { z } from "zod";
import { ChatOllama } from "@langchain/ollama";
const getWeather = tool(({ city }) => `It's always sunny in ${city}!`, {
name: "get_weather",
description: "Get the weather for a given city",
schema: z.object({ city: z.string() }),
});