Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
describe() {
printf "name: dev-server\n"
printf "description: %s\n" \
"Use this tool to run the development server." \
"The development server is a persistent process and automatically reloads when code changes are made." \
"Use the tail action to retrieve recent log lines."
printf "action: string the action to take, one of start, stop or tail."
}
#!/usr/bin/env bash
# lessopen - LESSOPEN preprocessor for JSON files
# Usage: Set LESSOPEN="|lessopen %s" in your shell
set -euo pipefail
# Check if jq is available
if ! command -v jq >/dev/null 2>&1; then
exit 1
#!/usr/bin/env tclsh
proc every {interval body} {
while {true} {
uplevel 1 $body
after $interval set every_timer done
vwait every_timer
}
}

Proposal: Better Form System Design

Current Problems

The existing form system has several design issues that create unnecessary complexity:

1. Name Generation Mismatch

  • Field names are auto-generated using strings.ToLower(fieldType.Name)
  • Creates mismatches: CurrencyCodecurrencycode but users expect currency_code
  • No control over field naming, leading to confusing APIs

Overview

texted is a scriptable, headless text editor intended to be used for making automated edits to files on disk.

Using texted

A texted program is a series of instructions. No means of abstraction are provided by texted, these are to be implemented at a higher level, by the application using texted.

@dhamidi
dhamidi / repl.sh
Last active October 24, 2021 09:32
#!/usr/bin/env bash
[[ -v REPL_FILES ]] || declare -a REPL_FILES=()
[[ -v REPL_CHECKSUM ]] || declare REPL_CHECKSUM
repl.install() {
local command
declare -ga PROMPT_COMMAND
for command in "${PROMPT_COMMAND[@]}"; do
if [[ "$command" == "repl.load_if_changed" ]]; then
@dhamidi
dhamidi / yank-git-branch.sh
Created October 5, 2021 08:24
zle-bind-x
#!/usr/bin/env zsh
# zsh uses its own line editor instead of readline: zle.
#
# keys are bound to zle widgets
#
# Plan: create a widget, bind it to a key
# our custom zle widget for selecting a git branch using fzf
yank_git_branch() {
local branch=$(git branch | awk '{print $NF}' | fzf)
@dhamidi
dhamidi / keybase.md
Created September 14, 2021 12:49
keybase.md

Keybase proof

I hereby claim:

  • I am dhamidi on github.
  • I am dhamidi (https://keybase.io/dhamidi) on keybase.
  • I have a public key ASAcRDRzUZF29ScaAUK9d5sX1Qk1VFnYkk9LBxbfOgiW1wo

To claim this, I am signing this object:

@dhamidi
dhamidi / README.md
Created September 13, 2018 15:58
Flattens yaml files

Flattens YAML files to make them greppable

$ yq docker-compose.yml 
version 3.3
services.redis.image redis:latest
services.redis.deploy.replicas 1
services.redis.ports.0.published 6379
services.redis.ports.0.target 6379
services.redis.ports.0.mode host
@dhamidi
dhamidi / Musi
Last active January 31, 2016 12:01 — forked from Trevorjoel/Musicandart.php
First project
<html>
<head>
<title>Music and Art</title>
<STYLE>
H1 { color: green }
H1 {font-family: arial; text-align: center;}
H2 {font-family: arial}