guidelines for concise [zsh][zsh-wiki] scripts
authors: [nicholaswmin][authorgh] - The [MIT][mit-lcns] License.
The keywords must/must not are to be interpreted as described in [RFC-2119][rfc-2119].
This formality is kept to a minimum because this document is meant to be LLM-parseable;
in other cases, your own unique context dictates their applicability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std/dirs | |
def "path shorten" [--last] { | |
str replace $env.HOME "~" | if $last { | |
path split | last | |
} else { $in } | |
} | |
def --env "dirs reset-current" [] { | |
cd ($env.DIRS_LIST | get $env.DIRS_POSITION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { exec } from "node:child_process" | |
import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs" | |
import { mkdir } from "node:fs/promises" | |
import { basename, dirname, join } from "node:path" | |
import { pipeline } from "node:stream/promises" | |
import { promisify } from "node:util" | |
import { createGzip } from "node:zlib" | |
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RotateDirection = Object.freeze({ | |
Left: -1, | |
Right: 1, | |
}); | |
// Init the ASCII character mapping table (equivalent to the large local_* arrays) | |
// /** @type {string[]} */ | |
// const charMap = []; | |
// for(let i = 32; i < 127; i++) { | |
// // Skip " ' \ \x7F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROMPT_COMMAND='PS1_RUN_PREEXEC=1' | |
preexec() { | |
if [ -z "$PS1_RUN_PREEXEC" ]; then | |
return | |
fi | |
unset PS1_RUN_PREEXEC | |
echo $'\e[38;5;241m'"[$(date +'%Y-%m-%dT%H:%M:%S%z')]"$'\e[0m' | |
} | |
trap 'preexec' DEBUG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import decircular from 'decircular' | |
import isObject from 'is-obj' | |
import sortKeys from 'sort-keys' | |
import { type LiteralUnion } from 'type-fest' | |
export type Encoding = 'hex' | 'base64' | 'buffer' | |
export type Algorithm = LiteralUnion<'sha1' | 'sha256' | 'sha512', string> | |
export type Options = { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import requests | |
import yaml | |
import argparse | |
YAML_FILE = 'favicons-database.yml' | |
def fetch_favicon(url): | |
try: | |
response = requests.get(f'{url}/favicon.ico', timeout=10, verify=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# | |
# Two-way clipboard syncronization between Wayland and X11, with cliphy support! | |
# !! Recommended use: Drop this file off @ /usr/local/bin/clipsync && make it executable | |
# Requires: wl-clipboard, xclip, clipnotify. | |
# Modified from: https://github.com/hyprwm/Hyprland/issues/6132#issuecomment-2127153823 | |
# | |
# Usage: | |
# clipsync watch [with-notifications|without-notifications] - run in background. | |
# clipsync stop - kill all background processes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS Snippet for a cloudflare worker to get the "Shareable" URL for a wsj.com article by URL. | |
// Requires a valid, authenticated wsj.com cookie jar. | |
// Uses a cloudflare workers KV namespace bound to `TestKV` to store/fetch the cookies. | |
// getting these cookies is a pain. This was extracted using the chrome dev tools > copy request as Fetch and manually filtering out just the cookie header | |
const default_cookies = 'datadome=7S65yfEc866mp9GpkZUQXtvYKJHblCG5VlkmmCEzHErmZn4Cxj1DizrKaq6u_WW~SL3xkFUyv2sas2PJxIMAdJxPJ3skZr009v4kbL4sHsdYAnJHZhN0wtr8F8WRDz1l; djcs_route=7055a21f-09ec-48b1-b187-06518dfd9f6f; ca_rt=3IX-ARt2INJ47c8pbe87kw.SvzY1D2JoWw2n_c_Y3_wN78ns1LcSsITZEjFkMVz9K-dt9Nv7zaM-KWrg7GZRSWwHURy6sMrpRN6x68I6P9mtncYsvXMhVCnFdZnEnVxlj8; _pcid=%7B%22browserId%22%3A%22ltofwg00gm2jgtk9%22%7D; cX_P=ltofwg00gm2jgtk9; _pubcid=ddebe880-2003-4d12-8da8-2511b02cc014; _sp_su=false; TR=V2-a80a4882c66bd273e8409f9b32bf2dc04f6968616ebc9adf8c862073eeb1efea; ab_uuid=2eaa406a-31e0-49a8-bad2-bb149907d4d2; _ncg_domain_id_=00f9e1d |
NewerOlder