03403e2b1a36

Merge
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 30 Jul 2022 11:23:28 -0400
parents c320b7ae191f (current diff) ce2276bdcbe5 (diff)
children 61b4f1f3a9f1 18fec414aff5
branches/tags (none)
files gitconfig

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/backpackfor	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cp ~/Dropbox/tasks/backpack-archive ~/Dropbox/tasks/backpack.txt
+nvim ~/Dropbox/tasks/backpack.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/c	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cacl --no-inform --batch "$@"
--- a/bin/e	Sat Jul 30 11:23:23 2022 -0400
+++ b/bin/e	Sat Jul 30 11:23:28 2022 -0400
@@ -2,4 +2,8 @@
 
 set -euo pipefail
 
-"$EDITOR" "$@"
+if test "$#" -eq 0; then
+    "$EDITOR" .
+else
+    "$EDITOR" "$@"
+fi
--- a/bin/ee	Sat Jul 30 11:23:23 2022 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-e .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/git-du	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+ROOT="$1"
+shift
+
+git-object-sizes \
+    | head -200 \
+    | grep -P "^\d+,\d+,[0-9a-f]+,$ROOT.*" \
+    | awk --field-separator , '
+    {
+        sums[$4] += $1
+    }
+    END {
+        for (x in sums) {
+            print sums[x], x
+        }
+    }
+    '
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/git-object-sizes	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# Shows you the largest objects in your repo's pack file.
+# Written for osx.
+#
+# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
+# @author Antony Stubbs
+#
+# Edited by sjl
+
+# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
+IFS=$'\n';
+
+# list all objects including their size, sort by size
+objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -P '(tree|blob|commit)'`
+
+# echo "All sizes are in bytes. The pack column is the size of the object, compressed, inside the pack file." >&2
+
+# echo "size,pack,SHA,location"
+for y in $objects
+do
+    # echo "$y"
+
+    # extract the size in bytes
+    size=`echo $y | f 3`
+
+    # extract the compressed size in bytes
+    compressedSize=`echo $y | f 4`
+
+    # extract the SHA
+    sha=`echo $y | f 1`
+
+    # find the objects location in the repository tree
+    loc=`git rev-list --all --objects | grep $sha | f 2`
+
+    #lineBreak=`echo -e "\n"`
+    echo "${size},${compressedSize},${sha},${loc}"
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/join-regex-or	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,4 @@
+#!/usr/bin/env python3
+
+import sys
+print("|".join(sys.stdin.readlines()).replace('\n', ''))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/packfor	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+cp ~/Dropbox/tasks/pack-archive ~/Dropbox/tasks/pack.txt
+nvim ~/Dropbox/tasks/pack.txt
--- a/fish/functions/packfor.fish	Sat Jul 30 11:23:23 2022 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-function packfor
-    cp ~/Dropbox/tasks/pack-archive ~/Dropbox/tasks/pack.txt
-end
--- a/gitconfig	Sat Jul 30 11:23:23 2022 -0400
+++ b/gitconfig	Sat Jul 30 11:23:28 2022 -0400
@@ -89,6 +89,7 @@
     fuom = "!sh -c 'git co $(git mainbranch) && git fo && git uo' -"
     fuum = "!sh -c 'git co $(git mainbranch) && git fu && git uu' -"
     rom =  "!sh -c 'git fo && git rebase origin/$(git mainbranch)' -"
+    recon =  rebase --continue
 
     addremove = !git add . && git add -u
     addrem = !git addremove
--- a/lisp/build-binary.sh	Sat Jul 30 11:23:23 2022 -0400
+++ b/lisp/build-binary.sh	Sat Jul 30 11:23:28 2022 -0400
@@ -9,5 +9,6 @@
 sbcl --load "$LISP" \
     --eval "(sb-ext:save-lisp-and-die \"$NAME\"
               :executable t
+              :compression t
               :save-runtime-options t
               :toplevel '$NAME:toplevel)"
--- a/lisp/subex.lisp	Sat Jul 30 11:23:23 2022 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (ql:quickload '(:adopt) :silent t))
-
-(defpackage :subex
-  (:use :cl)
-  (:export :toplevel *ui*))
-
-(in-package :subex)
-
-;;;; Global Options and UI ----------------------------------------------------
-(defparameter *o/help*
-  (adopt:make-option 'help :long "help" :help "display help and exit" :reduce (constantly t)))
-
-(defparameter *o/version*
-  (adopt:make-option 'version :long "version" :help "display version and exit" :reduce (constantly t)))
-
-(defparameter *ui/main*
-  (adopt:make-interface
-    :name "subex"
-    :usage "[subcommand] [options]"
-    :help "subcommand example program"
-    :summary "an example program that uses subcommands"
-    :contents (list *o/help* *o/version*)))
-
-(defparameter *ui* *ui/main*)
-
-
-;;;; Subcommand Foo -----------------------------------------------------------
-(defparameter *o/foo/a*
-  (adopt:make-option 'a :result-key 'mode :short #\a :help "run foo in mode A" :reduce (constantly :a)))
-
-(defparameter *o/foo/b*
-  (adopt:make-option 'b :result-key 'mode :short #\b :help "run foo in mode B" :reduce (constantly :b)))
-
-(defparameter *ui/foo*
-  (adopt:make-interface
-    :name "subex foo"
-    :usage "foo [-a|-b]"
-    :summary "foo some things"
-    :help "foo some things"
-    :contents (list *o/foo/a* *o/foo/b*)))
-
-(defun run/foo (mode)
-  (format t "Running foo in ~A mode.~%" mode))
-
-
-;;;; Subcommand Bar -----------------------------------------------------------
-(defparameter *o/bar/meow*
-  (adopt:make-option 'meow :long "meow" :help "meow loudly after each step" :reduce (constantly t)))
-
-(defparameter *ui/bar*
-  (adopt:make-interface
-    :name "subex bar"
-    :usage "bar [--meow] FILE..."
-    :summary "bar some files"
-    :help "bar some files"
-    :contents (list *o/bar/meow*)))
-
-(defun run/bar (paths meow?)
-  (dolist (p paths)
-    (format t "Bar-ing ~A.~%" p)
-    (when meow?
-      (write-line "meow."))))
-
-
-;;;; Toplevel -----------------------------------------------------------------
-(defun toplevel/foo (args)
-  (multiple-value-bind (arguments options) (adopt:parse-options-or-exit *ui/foo* args)
-    (unless (null arguments)
-      (error "Foo does not take arguments, got ~S" arguments))
-    (run/foo (gethash 'mode options))))
-
-(defun toplevel/bar (args)
-  (multiple-value-bind (arguments options) (adopt:parse-options-or-exit *ui/bar* args)
-    (when (null arguments)
-      (error "Bar requires arguments, got none."))
-    (run/bar arguments (gethash 'meow options))))
-
-(defun lookup-subcommand (string)
-  (cond
-    ((null string) (values nil *ui/main*))
-    ((string= string "foo") (values #'toplevel/foo *ui/foo*))
-    ((string= string "bar") (values #'toplevel/bar *ui/bar*))
-    (t (error "Unknown subcommand ~S" string))))
-
-(defun toplevel ()
-  (sb-ext:disable-debugger)
-  (multiple-value-bind (arguments global-options)
-      (handler-bind ((adopt:unrecognized-option 'adopt:treat-as-argument))
-        (adopt:parse-options *ui/main*))
-    (when (gethash 'version global-options)
-      (write-line "1.0.0")
-      (adopt:exit))
-    (multiple-value-bind (subtoplevel ui) (lookup-subcommand (first arguments))
-      (when (or (null subtoplevel)
-                (gethash 'help global-options))
-        (adopt:print-help-and-exit ui))
-      (funcall subtoplevel (rest arguments)))))
-
--- a/lisp/weather.lisp	Sat Jul 30 11:23:23 2022 -0400
+++ b/lisp/weather.lisp	Sat Jul 30 11:23:28 2022 -0400
@@ -45,6 +45,10 @@
 
 
 ;;;; OpenWeatherMap -----------------------------------------------------------
+;;; TODO Switch to weather.gov some day to get my taxes' worth, e.g.
+;;; https://forecast.weather.gov/MapClick.php?lat=43.1577&lon=-77.6066&FcstType=digitalDWML
+;;; Sadly this is XML.
+
 (defclass* response ()
   ((hourly :json (vector hour)))
   (:metaclass jarl:json-class))
--- a/lispwords	Sat Jul 30 11:23:23 2022 -0400
+++ b/lispwords	Sat Jul 30 11:23:28 2022 -0400
@@ -49,6 +49,9 @@
 ; arrows
 (1 -> ->> -<> -<>> _)
 
+; drakma
+(1 http-request)
+
 ; sketch
 (1 with-pen with-font)
 (2 defsketch)
--- a/stumpwmrc	Sat Jul 30 11:23:23 2022 -0400
+++ b/stumpwmrc	Sat Jul 30 11:23:28 2022 -0400
@@ -1,12 +1,14 @@
 (in-package :stumpwm-user)
 (shadow :window)
 
-(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads :jarl) :silent t)
+(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads :jarl :local-time)
+              :silent t)
+
 (use-package :losh)
 
-
 ;;;; Config -------------------------------------------------------------------
 (set-prefix-key (kbd "C-space"))
+(local-time:reread-timezone-repository)
 
 (defvar *redirected* (redirect-all-output (data-dir-file "debug" "log")))
 
@@ -234,6 +236,52 @@
             :name "Posture thread"))))
 
 
+;;;; Budget ------------------------------------------------------------------
+(defparameter *budget/per-day*
+  (first (losh:read-all-from-file "/home/sjl/Dropbox/budget/per-day")))
+
+(defparameter *tz/eastern*
+  (local-time:find-timezone-by-location-name "US/Eastern"))
+
+(defparameter *budget/start*
+  (local-time:encode-timestamp 0 0 0 0 26 7 2022 :timezone *tz/eastern*))
+
+(defun budget/elapsed ()
+  (local-time:timestamp-difference (local-time:now) *budget/start*))
+
+(defun budget/days-elapsed ()
+  (floor (/ (budget/elapsed) (* 60 60 24))))
+
+(defun budget/in ()
+  (* (budget/days-elapsed) *budget/per-day*))
+
+(defun budget/out ()
+  (loop :for path :in (directory "/home/sjl/Dropbox/budget/hosts/*/total")
+        :summing (print (first (read-all-from-file (print path))))))
+
+(defun budget/current ()
+  (- (budget/in) (budget/out)))
+
+(defcommand budget () ()
+  (message "$~D" (budget/current)))
+
+(defmacro with-budget-file ((f file &rest open-args) &body body)
+  `(with-open-file
+     (,f (format nil "/home/sjl/Dropbox/budget/hosts/~(~A~)/~A" *host* ,file)
+      ,@open-args)
+     ,@body))
+
+(defcommand spend (amount what) ((:integer "Amount: $") (:string "For: "))
+  (let ((current (with-budget-file (total "total")
+                   (first (read-all-from-file total))))
+        (timestamp (local-time:to-rfc3339-timestring (local-time:now))))
+    (with-budget-file (total "total" :direction :output :if-exists :supersede)
+      (print (+ current amount) total))
+    (with-budget-file (records "records" :direction :output :if-exists :append :if-does-not-exist :create)
+      (print (list timestamp amount what) records))
+    (message "Spent $~D for ~A at ~A" amount what timestamp)))
+
+
 ;;;; Load ---------------------------------------------------------------------
 (load-module "pass")
 
@@ -520,6 +568,7 @@
     ((:integer "Seconds: "))
   (run-shell-command (format nil "tea ~D" seconds)))
 
+
 ;;;; Isk ----------------------------------------------------------------------
 (defcommand send-key (key &optional (win (current-window))) (:key)
   "Send key press and key release events for KEY to window WIN."
@@ -579,7 +628,6 @@
   (isk-u-Æ "M-H" "AE"))
 
 
-
 ;;;; Key Mapping --------------------------------------------------------------
 ;;; Conventions:
 ;;;
@@ -620,7 +668,10 @@
   ("H-F" "delete-fucked-screenshot")
   ("H-R" "loadrc")
   ("H-r" "rain")
-  ("H-V" "vlc"))
+  ("H-V" "vlc")
+  ("H-4" "budget")
+  ("H-$" "spend")
+  )
 
 (define-top-keys ;; clipboard
   ("H-c" "show-clipboard-history")
@@ -643,9 +694,6 @@
   ("H-1" "gmove 1")
   ("H-2" "gmove 2")
   ("H-3" "gmove 3")
-  ("H-4" "gmove 4")
-  ("H-5" "gmove 5")
-  ("H-6" "gmove 6")
 
   ("C-H-H" "exchange-direction left")
   ("C-H-J" "exchange-direction down")
@@ -711,7 +759,6 @@
   ("H-F12" "refresh-heads"))
 
 
-
 ;; (stumpwm::unbind-remapped-keys)
 (define-remapped-keys
   '(("st-256color"
@@ -868,9 +915,6 @@
 
 
 ;;;; Startup ------------------------------------------------------------------
-;; (defvar *network-manager*
-  ;; (run-shell-command "nm-applet --sm-disable"))
-
 ;; (defvar *dropbox*
   ;; (run-shell-command "~/.dropbox-dist/dropboxd"))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/ftdetect/martian.vim	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,1 @@
+autocmd BufRead,BufNewFile *.mro set filetype=martian
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/syntax/martian.vim	Sat Jul 30 11:23:28 2022 -0400
@@ -0,0 +1,98 @@
+" Martian (MRO) Syntax
+" Author: Matt Sooknah
+
+if exists("b:current_syntax")
+  finish
+endif
+
+syn match include '^\s*@include' nextgroup=mroString skipwhite
+
+syn keyword filetype  filetype nextgroup=parType skipwhite
+syn keyword parameter in out  nextgroup=parType skipwhite contained
+syn keyword src       src nextgroup=srctype skipwhite contained
+syn keyword srctype   py comp exe nextgroup=mroString contained skipwhite
+syn keyword restype   mem_gb vmem_gb threads special volatile nextgroup=assign contained skipwhite
+syn keyword modifier  local preflight volatile nextgroup=modifier,callTarg skipwhite contained
+syn keyword boundMod  local preflight volatile disabled nextgroup=assign contained skipwhite
+syn keyword sweep     sweep nextgroup=sweepArray contained
+
+syn keyword declaration pipeline stage nextgroup=pipeName skipwhite
+syn keyword call        call nextgroup=modifier,callTarg skipwhite
+syn keyword return      return nextgroup=callParams skipwhite contained
+
+syn keyword mroNull  null       contained
+syn keyword mroBool  true false contained
+
+syn keyword split      split  nextgroup=splitUsing,paramBlock skipwhite contained
+syn keyword splitUsing using  nextgroup=paramBlock skipwhite contained
+syn keyword using      using  nextgroup=resParams  skipwhite contained
+syn keyword retain     retain nextgroup=idList     skipwhite contained
+syn keyword callUsing  using  nextgroup=modBlock   skipwhite contained
+syn keyword as         as     nextgroup=callTarg   skipwhite contained
+syn keyword self       self   nextgroup=dot contained
+
+syn match dot    '\.' nextgroup=parName contained
+syn match mapSep ':'  nextgroup=mroString,mroNull,mroBool,arrayLit,mapLit skipwhite contained
+syn match assign '='  nextgroup=self,sweep,mroString,mroNumber,mroNull,mroBool,parName,arrayLit,mapLit skipwhite contained
+
+syn match assignment '_\?[A-Za-z][A-Za-z0-9_]*\s*=' contains=parName,assign contained skipwhite nextgroup=self,sweep,mroString,mroNumber,mroNull,mroBool,parName,arrayLit,mapLit
+syn match parType '_\?[A-Za-z][.A-Za-z0-9_]*' nextgroup=arrayDim,parName skipwhite contained
+syn match arrayDim '\[\]' nextgroup=arraydim,parName skipwhite contained
+syn match parName '_\?[A-Za-z][A-Za-z0-9_]*' nextgroup=dot,mroString skipwhite contained
+syn match pipeName '_\?[A-Za-z][A-Za-z0-9_]*' nextgroup=paramBlock contained
+syn match callTarg '_\?[A-Za-z][A-Za-z0-9_]*' nextgroup=as,callParams skipwhite contained
+
+syn match commentLine '#.*$'
+
+syn match mroNumber '\v<\d+>' contained skipwhite nextgroup=mapSep
+syn match mroNumber '\v<\d+\.\d+>' contained skipwhite nextgroup=mapSep
+
+syn region paramBlock start="(" end=")" fold transparent nextgroup=split,using,retain,callBlock skipwhite skipnl contained contains=parameter,src
+syn region callParams start="(" end=")" fold transparent nextgroup=callUsing,retain skipwhite contained contains=assignment
+syn region resParams  start="(" end=")" fold transparent nextgroup=retain contained skipwhite skipnl contains=restype
+syn region idList     start="(" end=")" fold transparent contained contains=parName
+syn region modBlock   start="(" end=")" fold transparent contained contains=boundMod
+syn region callBlock  start="{" end="}" fold transparent contains=call,return contained skipwhite
+syn region mroString  start=/"/ skip=/\\"/ end=/"/ nextgroup=mapSep skipwhite contained
+syn region arrayLit   start='\[' end='\]' transparent contains=mroString,mroNumber,mroNull,mroBool,arrayLit,mapLit,parName contained
+syn region sweepArray start='(' end=')' transparent contains=mroString,mroNumber,mroNull,mroBool,arrayLit,mapLit contained
+syn region mapLit     start="{" end="}" transparent contains=mroString,mroNumber contained
+
+let b:current_syntax = "mro"
+
+hi def link commentLine   Comment
+
+hi def link include       PreProcessor
+hi def link filetype      Statement
+hi def link parameter     Statement
+hi def link src           Statement
+hi def link declaration   Statement
+hi def link return        Statement
+hi def link call          Statement
+hi def link modifier      Statement
+hi def link split         Statement
+hi def link splitUsing    Statement
+hi def link callUsing     Statement
+hi def link using         Statement
+hi def link as            Keyword
+hi def link restype       Keyword
+hi def link boundMod      Keyword
+hi def link self          Keyword
+hi def link sweep         Keyword
+hi def link using         Statement
+hi def link retain        Statement
+
+hi def link parType       Type
+hi def link srcType       Type
+
+hi def link pipeName      Type
+hi def link callTarg      Type
+hi def link parName       Identifier
+
+hi def link dot       Operator
+
+hi def link mroNumber Constant
+hi def link mroString Constant
+hi def link mroNull   Constant
+hi def link mroTrue   Constant
+hi def link mroFalse  Constant
--- a/vim/vimrc	Sat Jul 30 11:23:23 2022 -0400
+++ b/vim/vimrc	Sat Jul 30 11:23:28 2022 -0400
@@ -1348,7 +1348,7 @@
 augroup ft_git
     au!
 
-    au FileType gitcommit nnoremap <buffer> <localleader>j /On branch sjl<cr>f/l"zyt/gg0P
+    au FileType gitcommit nnoremap <buffer> <localleader>j /On branch sjl<cr>f/l"zyt/gg0P:nohl<cr>$a <esc>a
 augroup END
 
 " }}}
@@ -1677,6 +1677,15 @@
 augroup END
 
 " }}}
+" Martian {{{
+
+augroup ft_martian
+    au!
+
+    au Filetype markdown inoremap <buffer> <c-n> <c-x><c-n>
+augroup END
+
+" }}}
 " Mercurial {{{
 
 augroup ft_mercurial
@@ -1856,7 +1865,7 @@
     au FileType vim vnoremap <localleader>S y:@"<CR>
     au FileType vim nnoremap <localleader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
-    au FileType vim inoremap <c-n> <c-x><c-n>
+    au FileType vim inoremap <buffer> <c-n> <c-x><c-n>
 augroup END
 
 " }}}