301dff61cd7b

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 19 Jul 2022 12:41:40 -0400
parents da5692160006
children ce2276bdcbe5
branches/tags (none)
files bin/git-du bin/git-object-sizes bin/join-regex-or lisp/build-binary.sh lisp/subex.lisp lisp/weather.lisp

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/git-du	Tue Jul 19 12:41:40 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	Tue Jul 19 12:41:40 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	Tue Jul 19 12:41:40 2022 -0400
@@ -0,0 +1,4 @@
+#!/usr/bin/env python3
+
+import sys
+print("|".join(sys.stdin.readlines()).replace('\n', ''))
--- a/lisp/build-binary.sh	Mon Jun 20 23:21:30 2022 -0400
+++ b/lisp/build-binary.sh	Tue Jul 19 12:41:40 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	Mon Jun 20 23:21:30 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	Mon Jun 20 23:21:30 2022 -0400
+++ b/lisp/weather.lisp	Tue Jul 19 12:41:40 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))