Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -euo pipefail;
config="${XDG_CONFIG_HOME:-$HOME/.config}/obsidian/obsidian.json"
path="$1"
# Lookup an already existing vault-id
script='.vaults | to_entries[] | select(.value.path == $path) | first(.key)'
vaultid="$(<"$config" jq --arg path "$path" "$script" -r)"
@webstrand
webstrand / parallel-tmux.execline
Created December 2, 2022 19:02
tmux Execute two commands concurrently in the same terminal
#!/bin/execlineb -WP
background {
getpid -E pid
tmux -S .log/tmux-${pid}
new-session -s "log" "tail -f -n +1 .log/postgresql/current ; read" ;
split-window "tail -f -n +1 .log/graphile-migrate-watch/current ; read" ;
select-layout even-horizontal ;
bind-key -n C-c kill-session ;
bind-key d kill-session ;
@webstrand
webstrand / typescript@4.8.4.patch
Created November 11, 2022 15:37
Patch increasing the instantiation depth of the typescript compiler
--- a/lib/tsc.js
+++ b/lib/tsc.js
@@ -53539,1 +53539,1 @@ var ts;
- if (instantiationDepth === 100 || instantiationCount >= 5000000) {
+ if (instantiationDepth === 100*2 || instantiationCount >= 5000000*2) {
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
@@ -64294,1 +64294,1 @@ var ts;
- if (instantiationDepth === 100 || instantiationCount >= 5000000) {
+ if (instantiationDepth === 100*2 || instantiationCount >= 5000000*2) {
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended"
],
"globals": {
"Atomics": "readonly",
export {jsx, jsx as jsxs, jsx as Fragment}
type DOMElement = Element;
declare global {
namespace JSX {
type Element = DOMElement;
type ChildElement = string | number | boolean | symbol | bigint | null | undefined | { toString(): string } | (() => ChildElements) | Node;
type ChildElements = ChildElement | Iterable<ChildElement>;
interface HTMLAttributes<T> {
@webstrand
webstrand / sync-directory-traversal.mts
Last active July 16, 2022 20:17
Fast Synchronous Directory Traversal using chdir
/*
MIT License
Copyright (c) webstrand 2022
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@webstrand
webstrand / template-literal-debug-dump.ts
Created July 13, 2022 17:23
Force the use of every field defined by the dump-command-generator by the terminal template literal
const NonExhaustiveUseOfDebug = Symbol();
export declare function dump(strings: TemplateStringsArray, ...interpolations: unknown[]): void;
export declare function dump<F extends string | number>(props: { fields: { [_ in F]: unknown } }):
<I extends F>(strings: TemplateStringsArray, ...interpolations: ([F] extends [I] ? I[] : (F extends I ? F & { [NonExhaustiveUseOfDebug]: true } : F)[])) => void;
dump`whatever`;
dump({ fields: { SpecificString: ['a', 'b'] }})`This is a test ${'SpecificString'} :)`; // ok
dump({ fields: { SpecificString: ['a', 'b'], boo: {} }})`This is a test ${'SpecificString'} :)`; // error
@webstrand
webstrand / clipped-path.svg
Last active June 14, 2022 18:10
SVG Integer Hexagons
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@webstrand
webstrand / CSSColorString.ts
Created February 14, 2022 16:34
Type for CSS <color> string sans whitespace separators
type Color =
| `#${string}` | `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})`
| `hsl(${number}%,${number}%,${number}%)` | `hsla(${number}%,${number}%,${number}%,${number})`
| ColorKeywords | Lowercase<ColorKeywords> | Uncapitalize<ColorKeywords>
type ColorKeywords =
| "AliceBlue" | "AntiqueWhite" | "Aqua" | "Aquamarine" | "Azure" | "Beige"
| "Bisque" | "Black" | "BlanchedAlmond" | "Blue" | "BlueViolet" | "Brown"
| "BurlyWood" | "CadetBlue" | "Chartreuse" | "Chocolate" | "Coral"
| "CornflowerBlue" | "Cornsilk" | "Crimson" | "Cyan" | "DarkBlue"
@webstrand
webstrand / open-obsidian-vault.sh
Last active July 4, 2022 10:46
Open an arbitrary folder as an obsidian vault
#!/usr/bin/env bash
set -euo pipefail;
config="${XDG_CONFIG_HOME:-$HOME/.config}/obsidian/obsidian.json"
path="$1"
# Lookup an already existing vault-id
script='.vaults | to_entries[] | select(.value.path == $path) | first(.key)'
vaultid="$(<"$config" jq --arg path "$path" "$script" -r)"