Skip to content

Instantly share code, notes, and snippets.

@perpen
perpen / Aexe
Last active January 19, 2023 13:07
Acme/plan9: Runs a command in a window, as with button 2
#!/bin/rc
# Runs a command in an acme window, as with button 2
# Tries to restore original selection.
rfork e
if(! ~ $#* 1 2)
exit 'usage: exe PARAM [WINID]'
cmd=$1
id=$2
@perpen
perpen / Looki
Last active December 18, 2022 11:41
Plan 9: A variant of the Look command of acme, reverse/case-insensitive/etc options
#!/bin/rc
# A variant of the Look command of acme.
# Usage: Looki [-r] [-s] [-w] [-x] [SEARCH]
# -r: search backwards
# -s: case sensitive
# -w: whole words
# -x: regex mode, only makes sense when giving explicit param
# Flags may be combined, as in: -rws
#
# This is not an acme builtin: if invoked with an explicit
@perpen
perpen / Watch
Last active January 22, 2023 00:46
Plan 9: An rc approximation of rsc's https://pkg.go.dev/9fans.net/go/acme/Watch
#!/bin/rc
# An rc approximation of rsc's https://pkg.go.dev/9fans.net/go/acme/Watch
#
# Usage: Watch [-r | -n] [-d DIR] [CMD]
# -s starts command immediately
# -r listen for Put on subdirs recursively.
# -n only run the commands when Get is run
# -d cd to given dir, and listen for Put on files under it
# Flags taking no param may be combined eg: -sr
#
@perpen
perpen / setup-string.sh
Created July 28, 2022 17:42
Nothing interesting
#!/bin/bash
# To setup a new machine:
# - run $0 text on an existing machine
# - copy the output into the terminal of the target machine
set -euo pipefail
text() {
local string="$(tar cfj - \
bin/setup-string \
@perpen
perpen / secrets.sh
Created July 28, 2022 12:31
Nothing to see
#!/usr/bin/env bash
# Encrypts ~/.secrets into ~/.secrets.gpg and back
set -eo pipefail
source _functions
SECRETS=$HOME/.secrets
ARCHIVE=$HOME/.secrets.gpg
STATE=$SECRETS/gpg-checksum
@perpen
perpen / git.clj
Created July 27, 2022 23:01
Don't read this
#!/usr/bin/env bb
; Explanation for the `mini-stats` command in this script:
; - I customised my shell prompt to show the output of `git.clj mini-stats .`
;
; - Then I get in my prompt information like:
; `main` - if the current branch is main and there are no unpushed changes, in any branch.
;
; Or something more complicated like:
; `main 2/4/hack(2),bugfix(5)`
#!/usr/bin/env bash
set -e -o pipefail
my-dirs() {
mkdir -p ~/{src,tmp}
if [[ $(hostname) = penguin ]]; then
[[ -r ~/downloads ]] \
|| ln -sfv /mnt/chromeos/MyFiles/Downloads ~/downloads
else
mkdir -p ~/downloads
@perpen
perpen / status-bar.rb
Created July 27, 2022 19:28
A textual status bar for use with dwm, tmux, etc.
#!/usr/bin/env ruby
# frozen_string_literal: true
## TODO
# - use ~/bin/laptop for more things
PROG = 'status-bar'
NPROC = `nproc`.to_i
if true
@perpen
perpen / db_sqflite.clj
Created July 27, 2022 16:10
cljd sqflite experiment
;;;;;;;;;;;;;;;; db.cljd
(ns mu.db
(:require
[mu.utils :as u]))
(defprotocol Db
(init- [db opts] "***")
(show- [db] "dumps tables contents")
(save-blobby- [this bytes] "save Uint8List to blobbies table")
(ns sample.navigation
"Port of https://docs.flutter.dev/cookbook/navigation/navigation-basics"
(:require
["package:flutter/material.dart" :as m]
[cljd.flutter.alpha :as f]))
(def second-route
(f/widget
:inherit [m/Navigator]
(m/Scaffold