Skip to content

Instantly share code, notes, and snippets.

@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}
@dhamidi
dhamidi / example.esh
Created December 18, 2013 08:16
ERB-like template processor in POSIX AWK. Usage: ./template.awk < input.esh | sh > output
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><%= "$TITLE" %></title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<p>It's alive!</p>
<ul>
@dhamidi
dhamidi / AAAS.md
Last active December 31, 2015 02:59 — forked from leehambley/AAAS.md
Fix some typos.

Problem

Web applications need understand what permissions are granted to a current user in two key areas.

  1. When enforcing the permission server side (e.g returning 403 when trying to access a resource outside of one's graph)
  2. When rendering the user interface, so as not to render misleading controls (e.g "Edit this Widget", if the user lacks the appropriate permissions.

Further, in many applications in the wild (for better, or worse, perhaps I need new friends and colleagues) I've seen ways implemented to nerf or flat-out disable authorisation controls. In addition to the regular graph-based authorisation flow, the concept of super users is prevelant, and dangerous.

Background

@dhamidi
dhamidi / .inputrc
Created September 11, 2013 13:37
My readline configuration
$include /etc/inputrc
set bind-tty-special-chars off
set skip-completed-text on
set bell-style visible
"\C-x\C-e": edit-and-execute-command
"\C-xa\"": "\"\C-x\C-x\C-f\""
"\C-xa(": "(\C-x\C-x\C-f)"