Skip to content

Instantly share code, notes, and snippets.

View jaawerth's full-sized avatar

Jesse Wertheim jaawerth

View GitHub Profile
{:wat #(match $
1 :ok
2 :ok
3 :ok
4 :still-ok
5 `(error "That's the combination to my luggage!")
6 :ok-again
_ :ok-ill-stop)}
(macros
(let [*m* {}]
(fn *m*.comp [...]
(let [n-funcs (select :# ...)]
(assert (< n-funcs 0) "comp requires at least 1 function")
(match n-funcs
0 (fn [])
1 ...
(do
@jaawerth
jaawerth / win-picker
Last active January 2, 2021 00:19
Tiny fuzzy-matching win-picker script using fzf + wmctrl
#!/usr/bin/env bash
fzfargs=()
[ $# -gt 0 ] && fzfargs+=( '-q' "$*" )
tgt_win="$(wmctrl -l | fzf "${fzfargs[@]}" | cut -d' ' -f 1)"
[ -n "$tgt_win" ] && wmctrl -i -a "$tgt_win"
'use strict';
const noop = () => {};
/**
* Wrap promise-returning function, f, in a handler that ensures
* the Promise's resolve/reject translates into next() or next(err).
* If f does not return a Promise, assume it's a regular middleware.
*/
const wrapAsyncMiddleWare = f => (...args) => {
const [next] = args.slice(-1);
@jaawerth
jaawerth / get-ssh-hostname
Last active May 24, 2020 16:53
quick script to get the hostname from an alias in .ssh/config
#!/usr/bin/env bash
SSH_CONFIG="${SSH_CONFIG:-$HOME/.ssh/config}"
error() { >&2 printf "Error: %s\n" "$@"; exit 1; }
[ ! -r "$SSH_CONFIG" ] && error "Couldn't read SSH_CONFIG: \"$SSH_CONFIG\""
if ! awk -v tgt="$1" '
tolower($1) ~ /^host$/ {
; lie to gist that this is clojure for syntax highlighting
; vim: ft=clojure
(require-macros :meta-macros)
(local (mpack Session Tcp Socket) (values (require :mpack)
(require :nvim.session)
(require :nvim.tcp_stream)
(require :nvim.socket_stream)))
(local (fmt join) (values string.format table.concat))
; an api.mpack file needs to be generated from /path/to/neovim/scripts/vim_gendoc.py
#!/usr/bin/env bash
# if args are passed, use first arg as file to process. otherwise assume STDIN
if [ $# -ge 1 -a -f "$1" ]; then
infile="$1"; shift;
else
infile="-"
fi
# here be my awk program!
@jaawerth
jaawerth / web-servers.md
Created April 26, 2020 01:05 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jaawerth
jaawerth / neovim.nix
Created March 18, 2020 02:17 — forked from smolck/neovim.nix
Nix and neovim with nodejs
self: prev:
let
neovim-unwrapped-master =
(prev.neovim-unwrapped.override {
lua = self.luajit;
}).overrideAttrs(oldAttrs: {
cmakeBuildType="debug";
cmakeFlags = oldAttrs.cmakeFlags ++ [ "-DMIN_LOG_LEVEL=0" ];
@jaawerth
jaawerth / README.md
Created January 14, 2020 16:23 — forked from magnetikonline/README.md
Bash array usage cheatsheet.