diff options
-rw-r--r-- | emacs/.emacs.d/wpc/chrome.el | 82 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/do.el | 54 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/enum.el | 98 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/finance.el | 119 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/iso.el | 95 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/kaomoji.el | 45 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/keybindings.el | 2 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/keymap.el | 25 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/me-seconds.el | 245 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/monoid.el | 30 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/playback.el | 41 | ||||
-rw-r--r-- | emacs/.emacs.d/wpc/polymorphism.el | 37 |
12 files changed, 0 insertions, 873 deletions
diff --git a/emacs/.emacs.d/wpc/chrome.el b/emacs/.emacs.d/wpc/chrome.el deleted file mode 100644 index 133c7af355fa..000000000000 --- a/emacs/.emacs.d/wpc/chrome.el +++ /dev/null @@ -1,82 +0,0 @@ -;;; chrome.el --- Helpers for Google Chrome -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Some helper functions for working with Google Chrome. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dependencies -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'macros) -(require 'alist) -(require 'list) -(require 'general) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar chrome/install-kbds? t - "If t, install keybinding.") - -;; TODO: Consider modelling this as a rose-tree that can nest itself -;; arbitrarily. -;; TODO: Consider exporting existing chrome bookmarks. -(defconst chrome/label->url - '(("Google" . "www.google.com") - ("Hacker News" . "news.ycombinator.com") - ("Gmail" . "www.gmail.com") - ("WhatsApp" . "web.whatsapp.com") - ("Google Chat" . "chat/") - ("Google Calendar" . "calendar/") - ("Teknql" . "teknql.slack.com/messages") - ("Twitter" . "twitter.com")) - "Mapping labels to urls for my bookmarks.") - -(defconst chrome/splash-pages - '("Google Calendar" - "Gmail" - "Google Chat" - "WhatsApp" - "Teknql") - "The pages that should open when I open Chrome.") - -;; TODO: Add defensive check to start chrome if it isn't already open. - -;; TODO: Support option to create new session even if one already exists. - -(defun chrome/open-splash-pages () - "Opens Chrome with my preferred splash pages." - (interactive) - (->> chrome/splash-pages - (-map (lambda (x) (alist/get x chrome/label->url))) - chrome/open-urls)) - -;; TODO: Support optional kwargs. -(cl-defun chrome/open-url (url &key new-window?) - "Opens `URL' in google-chrome. -Will open without toolbars if APP-MODE? is t." - (shell-command (s-concat - "google-chrome " - (if new-window? "--new-window " "") - url))) - -(defun chrome/open-urls (urls) - "Open multiple `URLS' in chrome." - (chrome/open-url - (list/join " " urls))) - -(defun chrome/browse () - "Display a counsel window for browsing URLs." - (interactive) - (ivy-read - "URL: " - chrome/label->url - :action (lambda (entry) - (chrome/open-url (cdr entry))))) - -(provide 'chrome) -;;; chrome.el ends here diff --git a/emacs/.emacs.d/wpc/do.el b/emacs/.emacs.d/wpc/do.el deleted file mode 100644 index 7dc2b260fdcd..000000000000 --- a/emacs/.emacs.d/wpc/do.el +++ /dev/null @@ -1,54 +0,0 @@ -;;; do.el --- Small assertion library for Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Assertion library inspired by Elixir's core testing library. -;; -;; The goal here is to create this module without relying on other non-core -;; Elisp libraries. I will attempt to do this as long as I'm not sacrificing -;; the readability of this code nor the ease at which it can be written. -;; -;; A note on testing: -;; Another goal with this library is to blur the line between testing code and -;; runtime code. Developers should ideally be using `do/assert' and `do/refute' -;; in their library code. Because of this, I'm avoiding referring -;; to the notion of testing in the names of these functions. -;; -;; Hypothesis: -;; The lower the friction is for writing tests, the more likely people will -;; write tests. - -;; TODO: Support better error messages, which might include information about -;; line numbers in source code where the assertion failed. - -;; TODO: Consider offering the ability to have some of these functions compile -;; to nothing at runtime if developers want to use them while developing without -;; incurring the costs at runtime. - -;; TODO: Consider using this module instead of prelude.el. Right now, I'm -;; having troubling preferring one to the other. The benefit of this module is -;; that it's independent of prelude, but that might also be a downside, since -;; the messaging that asserting should be a critical part of any core library -;; like prelude. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defmacro do/assert (x) - "Errors unless X is t. -These are strict assertions and purposely do not rely on truthiness." - (let ((as-string (format "%s" x))) - `(unless (equal t ,x) - (error (concat "Assertion failed: " ,as-string))))) - -(defmacro do/refute (x) - "Errors unless X is nil." - (let ((as-string (format "%s" x))) - `(unless (eq nil ,x) - (error (concat "Refutation failed: " ,as-string))))) - -(provide 'do) -;;; do.el ends here diff --git a/emacs/.emacs.d/wpc/enum.el b/emacs/.emacs.d/wpc/enum.el deleted file mode 100644 index 078e7972099c..000000000000 --- a/emacs/.emacs.d/wpc/enum.el +++ /dev/null @@ -1,98 +0,0 @@ -;;; enum.el --- Enumerable protocol for Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Heavily influenced by Elixir. - -;; I will not be implement every function in the Enum library, since I don't -;; need every function. Some of the streaming functionality may prove difficult -;; to write in Elisp. We shall see. - -;; TODO: Implement the following functions: -;; - all?/2 -;; - any?/2 -;; - at/3 -;; - chunk_by/2 -;; - chunk_every/{2,3,4} -;; - chunk_while/4 -;; - concat/1 -;; - concat/2 -;; - count/{1,2} -;; - dedup/1 # prefer calling this function dedupe -;; - dedup_by/2 # same as above -;; - drop/2 -;; - drop_every/2 -;; - drop_while/2 -;; - each/2 -;; - empty?/1 -;; - fetch/2 -;; - fetch!/2 -;; - filter/2 -;; - find/3 -;; - find_index/2 -;; - find_value/3 -;; - flat_map/2 -;; - flat_map_reduce/3 -;; - group_by/3 -;; - intersperse/2 -;; - into/{2,3} -;; - join/2 -;; - map/2 -;; - map_every/3 -;; - map_join/3 -;; - map_reduce/3 -;; - max/2 -;; - max_by/3 -;; - member?/2 # consider calling this contains? -;; - min/2 -;; - min_by/2 -;; - min_max/2 # This is a great function because of O(n) time. -;; - min_max_by/3 -;; - random/1 # Consider just sample with num=1 -;; - reduce/{2,3} -;; - reduce_while/3 -;; - reject/2 -;; - reverse/{1,2} -;; - reverse_slice/3 -;; - scan/{2,3} -;; - shuffle/1 -;; - slice/{2,3} -;; - sort/{1,2} -;; - sort/2 -;; - sort_by/3 -;; - split/2 -;; - split_while/2 -;; - split_with/2 -;; - sum/1 -;; - take/2 -;; - take_every/2 -;; - take_random/2 # prefer calling this function sample -;; - take_while/2 -;; - to_list/1 -;; - uniq/1 # prefer calling this unique -;; - uniq_by/2 # prefer calling this unique-by -;; - unzip/1 -;; - with_index/2 -;; - zip/{1,2} - -;; TODO: Consider how to handle dispatching by type. - -;; TODO: Which types should be supported herein? -;; - linked-lists -;; - associative-lists -;; - cycles - -;; Warning: This module is a total work-in-progress, and it's quite possible -;; that I may never even finish it. - -;;; Code: - -(defun enum/count (xs) - "Return the number of elements in `XS'." - (cond - ((alist/instance? xs) (alist/count xs)) - ((list/instance? xs) (list/length xs))) - ) - -(provide 'enum) -;;; enum.el ends here diff --git a/emacs/.emacs.d/wpc/finance.el b/emacs/.emacs.d/wpc/finance.el deleted file mode 100644 index b124061ccba3..000000000000 --- a/emacs/.emacs.d/wpc/finance.el +++ /dev/null @@ -1,119 +0,0 @@ -;;; finance.el --- Functions to help me organize my finances -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Using functions to organize my financial thinking. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dependencies -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'prelude) -(require 'math) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar finance/enable-tests? t - "When t, run the tests defined herein.") - -;; TODO: Support printing an org-table of these amount in a similar format to: -;; https://keisan.casio.com/exec/system/1234231998 -(cl-defun finance/future-value (amt - &key - num-years - (frequency 'monthly) - (interest-rate 0.06) - (payment-due-at 'beg) - (present-value 0)) - "Compute the Future Value of AMT. - -This function assumes that the interest rate is applied annually and not -monthly. - -This function will attempt to provide the following defaults: -- frequency: 'monthly -- interest-rate: 6% -- payment-due-at: 'beg -- present-value: 0.00" - (prelude/assert (set/contains? payment-due-at (set/new 'beg 'end))) - (prelude/assert (set/contains? frequency (set/new 'annually - 'semiannually - 'quarterly - 'monthly))) - (let ((pmt amt) - (k (alist/get frequency '((annually . 1) - (semiannually . 2) - (quarterly . 4) - (monthly . 12)))) - (r interest-rate) - (n num-years) - (pv present-value)) - (if (= 0 r) - (+ pv (* pmt n k)) - (if (equal 'beg payment-due-at) - (+ (* pv (math/exp (+ 1 (/ r k)) (* n k))) - (* pmt - (/ (- (math/exp (+ 1 (/ r k)) (* n k)) 1) - (/ r k)) - (+ 1 (/ r k)))) - (+ (* pv (math/exp (+ 1 (/ r k)) (* n k))) - (* pmt - (/ (- (math/exp (+ 1 (/ r k)) (* n k)) 1) - (/ r k)))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Tests -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(when finance/enable-tests? - (prelude/assert - (equal "1551.27" - (string/format "%0.2f" - (finance/future-value - 9.99 - :interest-rate 0.05 - :num-years 10 - :frequency 'monthly - :payment-due-at 'end - :present-value 0)))) - (prelude/assert - (equal "14318.34" - (string/format "%0.2f" - (finance/future-value 10.0 :num-years 35)))) - (prelude/assert - (equal "4200.00" - (string/format "%0.2f" - (finance/future-value - 10.0 - :interest-rate 0.0 - :num-years 35 - :frequency 'monthly - :payment-due-at 'beg - :present-value 0)))) - (prelude/assert - (equal "14318.34" - (string/format "%0.2f" - (finance/future-value - 10.0 - :interest-rate 0.06 - :num-years 35 - :frequency 'monthly - :payment-due-at 'beg - :present-value 0)))) - (prelude/assert - (equal "38282.77" - (string/format "%0.2f" - (finance/future-value - 10.0 - :interest-rate 0.1 - :num-years 35 - :frequency 'monthly - :payment-due-at 'beg - :present-value 0))))) - -(provide 'finance) -;;; finance.el ends here diff --git a/emacs/.emacs.d/wpc/iso.el b/emacs/.emacs.d/wpc/iso.el deleted file mode 100644 index c9ce4a48fc71..000000000000 --- a/emacs/.emacs.d/wpc/iso.el +++ /dev/null @@ -1,95 +0,0 @@ -;;; iso.el --- Isomorphisms in Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Providing basic isomorphisms to improve code quality. - -;;; Code: - -(require 'dotted) -(require 'tuple) -(require 'symbol) -(require 'string) -(require 'list) -(require 'alist) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(cl-defstruct iso to from x) - -(defconst iso/whitelist - '((dotted . tuple) - (symbol . string)) - "Alist representing supported isomorphisms.") - -(defconst iso/vertices - (list/concat (alist/keys iso/whitelist) - (alist/values iso/whitelist)) - "List of all of the vertices in the iso graph.") - -(defun iso/classify (x) - "Return type of X." - (cond - ((string/instance? x) 'string) - ((symbol/instance? x) 'symbol) - ((dotted/instance? x) 'dotted) - ((tuple/instance? x) 'tuple))) - -(cl-defun iso/exists? (to from) - "Return t if an isomorphism of TO to FROM exists." - ;; TODO: All of this can be improved modelling this with a graph. - (cond - ;; to -> from - ((list/contains? to (alist/keys iso/whitelist)) - (list/contains? from (alist/values iso/whitelist))) - ;; from -> to - ((list/contains? from (alist/keys iso/whitelist)) - (list/contains? to (alist/values iso/whitelist))) - ;; doesn't exist - (t nil))) - -(progn - (prelude/assert - (iso/exists? 'symbol 'string)) - (prelude/assert - (iso/exists? 'dotted 'tuple)) - (prelude/refute - (iso/exists? 'dotted 'symbol)) - (prelude/refute - (iso/exists? 'symbol 'list))) - -;; TODO: Model this as a graph. -(defconst iso/morphisms - '((string . - '(symbol #') - )) - (list (:from 'string :to 'symbol :fn #'intern) - (:from 'symbol :to 'string :fn #'symbol-name) - ) - "") - -(defun iso/to (f x) - "Apply F to X's to." - (->> x - iso-to)) - -(->> (iso/new "william" :to 'symbol) - (iso/as-to #'symbol-name) - ) - -(cl-defun iso/new (x &key to) - "Create a new isomorphism of X mapping to TO." - (let ((from (iso/classify x))) - (prelude/assert (iso/exists? to from)) - (make-iso :from from - :to to - :x x))) - -(macros/comment - (iso/new "william" :to 'symbol) - (iso/new '(one . two) :to 'tuple)) - -(provide 'iso) -;;; iso.el ends here diff --git a/emacs/.emacs.d/wpc/kaomoji.el b/emacs/.emacs.d/wpc/kaomoji.el deleted file mode 100644 index d6d509c14667..000000000000 --- a/emacs/.emacs.d/wpc/kaomoji.el +++ /dev/null @@ -1,45 +0,0 @@ -;;; kaomoji.el --- Supporting kaomoji usage -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Simple keyboards like this make life a bit better. - -;;; Code: - -(defvar kaomoji/install-kbds? - nil - "Set to t if you'd like the keybindings to be installed.") - -(defconst kaomoji/symbols '(("Joy" . "(⌒‿⌒)") - ("Love" . "(ღ˘⌣˘ღ)") - ("Sympathy" . "ヽ(~_~(・_・ )ゝ") - ("Dissatisfaction" . "(>﹏<)") - ("Anger" . "ヽ(‵﹏´)ノ") - ("Hugging" . "(づ ̄ ³ ̄)づ") - ("Hiding" . "┬┴┬┴┤( ͡° ͜ʖ├┬┴┬┴") - ("Sleeping" . "(-_-) zzZ") - ("Embarrassed" . "(×﹏×)") - ("Shrug" . "ヽ(ー_ー )ノ")) - "Alist of human-readable emotions to the kaomoji.") - -;; TODO: Consider supporting a hydra for these. - -(defun kaomoji/select () - "Interactively select a kaomoji and copy it to the clipboard." - (interactive) - (ivy-read - "Select a kaomoji: " - kaomoji/symbols - :action (lambda (entry) - (kill-new (cdr entry)) - (alert "Copied to clipboard!")))) - -;; TODO: Define Hydra for all custom keyboards. -;; TODO: Define a better keybinding in a different keymap. -(when kaomoji/install-kbds? - (general-define-key - :keymaps 'global - "M-k" #'kaomoji/select)) - -(provide 'kaomoji) -;;; kaomoji.el ends here diff --git a/emacs/.emacs.d/wpc/keybindings.el b/emacs/.emacs.d/wpc/keybindings.el index 2f4a703b084c..7d0125b3981e 100644 --- a/emacs/.emacs.d/wpc/keybindings.el +++ b/emacs/.emacs.d/wpc/keybindings.el @@ -20,7 +20,6 @@ (require 'clipboard) (require 'screen-brightness) -(require 'chrome) (require 'scrot) (require 'ivy-clipmenu) (require 'general) @@ -126,7 +125,6 @@ (keybinding/exwm "<XF86AudioLowerVolume>" #'pulse-audio/decrease-volume) (keybinding/exwm "<XF86AudioRaiseVolume>" #'pulse-audio/increase-volume) (keybinding/exwm "<XF86AudioMicMute>" #'pulse-audio/toggle-microphone) -(keybinding/exwm "C-M-c" #'chrome/browse) (keybinding/exwm (kbd/raw 'x11 "s") #'scrot/select) (keybinding/exwm "<C-M-tab>" #'window-manager-switch-to-exwm-buffer) diff --git a/emacs/.emacs.d/wpc/keymap.el b/emacs/.emacs.d/wpc/keymap.el deleted file mode 100644 index 87d340fcdbf1..000000000000 --- a/emacs/.emacs.d/wpc/keymap.el +++ /dev/null @@ -1,25 +0,0 @@ -;;; keymap.el --- Working with Elisp keymaps -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Very much a work-in-progress. - -;;; Code: - -(require 'macros) -(require 'symbol) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun keymap/pretty-print (x) - "Pretty prints `X'." - ;; TODO: Work-in-progress - (s-concat "\\{" (symbol/to-string x) "}")) - -(macros/comment - (keymap/pretty-print lispyville-mode-map)) - -(provide 'keymap) -;;; keymap.el ends here diff --git a/emacs/.emacs.d/wpc/me-seconds.el b/emacs/.emacs.d/wpc/me-seconds.el deleted file mode 100644 index f03e5d07d790..000000000000 --- a/emacs/.emacs.d/wpc/me-seconds.el +++ /dev/null @@ -1,245 +0,0 @@ -;;; me-seconds.el --- How valuable is my time? -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Inspired by Google's concept of SWE-seconds, I decided to try and compute how -;; value my personal time is. -;; -;; This library should integrate with another library that handles currency -;; conversions using locally cached data for historial values and network -;; requests for current values. -;; -;; Context sensitivity: -;; Many of the values herein are based on my values that are a function of the -;; year, my current salary, my current company holiday policy, and my current -;; country holiday policy. As such, many of these constants need to be updated -;; whenever changes occur in order for these functions to be useful. -;; -;; Units of time: -;; - seconds -;; - minutes -;; - hours -;; - days -;; - weeks -;; - months -;; - years -;; -;; Wish list: -;; - I should create a money.el struct to work with herein. This module would -;; expose basic algebra for working with money structs, which would be handy. -;; - I should create a time.el struct for working with hours in the day. I'd -;; like to be able to do (+ 9:15 17:45) cleanly. -;; -;; Terminology: -;; SWE hours give an order of magnitude approximation to the cost of resources -;; in dollars per hour at 2115 hours per year. -;; - SWE hour (SWEh) -;; - SWE year (SWEy) -;; - SWE nominal -;; - SWE opportunity -;; -;; Other isomorphisms include: -;; - Borg GCU -;; - Borg RAM -;; - Tape (library) -;; - Tape (vault) -;; - Spindles (low latency) -;; - Spindles (throughput) -;; - Spindles (throughput) -;; - Tape (throughput) -;; - SWE (nominal) -;; - SWE (opportunity) - - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dependencies -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'macros) -(require 'string) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Constants -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun me-seconds/salary (amt) - "Return the yearly rate of AMT of money in GBP. -f :: Integer -> Rate" - (make-rate :money (make-money :whole amt :fractional 0 :currency 'GBP) - :unit 'year)) - -(defconst me-seconds/salary (me-seconds/salary 80000) - "My salary in GBP.") - -;; TODO: Consider changing these into units of time. -(defconst me-seconds/months-per-year 12 - "Number of months in a year.") - -(defconst me-seconds/days-per-year 365 - "Number of days in a year.") - -(defconst me-seconds/hours-per-year (* 24 me-seconds/days-per-year) - "Number of hours in a year.") - -(defconst me-seconds/minutes-per-year (* 60 me-seconds/hours-per-year) - "Number of minutes in a year.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Vacation -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst me-seconds/bank-holidays-per-year 8 - "Number of bank holidays in the UK each year.") - -(defconst me-seconds/pto-days-vacation-per-year 25 - "Number of days of paid-time-off I receive each year in the UK.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Sleeping -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst me-seconds/sleeping-hours-per-day 8 - "An approximation of the number of hours I sleep each night on average.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Waking -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst me-seconds/waking-hours-per-day - (- 24 me-seconds/sleeping-hours-per-night) - "An approximation of the number of hours I sleep each night on average.") - -;; TODO: Adjust this for vacation time. -(defconst me-seconds/waking-hours-per-year - (* me-seconds/waking-hours-per-day me-seconds/days-per-year) - "The number of hours that I work each year.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Working -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst me-seconds/working-hours-per-day - (- 17 9) - "An approximation of the number of hours I work each weekday on average. -Note that this differs from the assumed SWE hours per day calculation, which - assumes 9 working hours. See the discussion about this of go/rules-of-thumb.") - -(defconst me-seconds/working-hours-per-year 2115 - "This number is borrowed from go/rules-of-thumb.") - -;; Keep in mind that the following classifications of time: -;; - 9:00-17:00 M-F. Is this more expensive than time sleeping? -;; - Weekend -;; - Weekday -;; - Working hours -;; - Waking hours -;; - Sleeping hours -;; - Vacation hours -;; -;; TODO: Consider tax implications (i.e. after-tax amounts and pre-tax amounts). -;; -;; Should these all be treated the same since they all pull from the same pot of -;; time? Or perhaps there are multiples involved? Much to think about. How does -;; Google handle this? - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; Supported currencies: -;; - GBP -;; NOTE: Amount is an integer. -(cl-defstruct money whole fractional currency) -(cl-defstruct rate money unit) - -;; TODO: Add to money.el. -(defun money/to-string (x) - "Return the string representation of X. -f :: Money -> String" - (let ((currency (money-currency x)) - (whole (int-to-string (money-whole x))) - (fract (int-to-string (money-fractional x)))) - (pcase currency - ('GBP (string/concat "£" whole "." fract)) - ('USD (string/concat "$" whole "." fract)) - (_ (error (string/concat - "Currency: \"" - (symbol-name currency) - "\" not supported")))))) - -(macros/comment - (money/to-string - (make-money :whole 100 :fractional 99 :currency 'GBP))) - -;; TODO: Add to rate.el. -(defun rate/to-string (x) - "Message X as a rate. -f :: Rate -> String" - (string/concat - (money/to-string (rate-money x)) - " / " - (pcase (rate-unit x) - ('second "sec") - ('minute "min") - ('hour "hr") - ('day "day") - ('week "week") - ('month "month") - ('year "year")))) - -(macros/comment - (rate/to-string - (make-rate - :money (make-money :whole 10 :fractional 10 :currency 'GBP) - :unit 'day))) - -;; TODO: Move this to math.el? -(defun ensure-float (x) - "Ensures X is treated as a float." - (+ 0.0 x)) - -;; TODO: Move these to basic time mapping module. -;; TODO: Consider making this an isomorphism. -(defun minutes/to-hours (x) - "Convert X minutes to n hours." - (/ x 60.0)) - -(defun hours/to-minutes (x) - "Convert X hours to n minutes." - (* x 60)) - -(defun days/to-minutes (x) - "Convert X days to n minutes." - (* x 24 60)) - -(defun weeks/to-minutes (x) - "Convert X weeks to n minutes." - (* x 7 24 60)) - -(defun months/to-minutes (x) - "Convert X months to n minutes. -This approximates the number of days in a month to 30." - (* x 30 24 60)) - -;; TODO: Support algebraic functions with money structs. -;; TODO: Support isomorphisms for rates to other units of time. That would -;; subsume most of this module's use. -(defun me-seconds/value-per-minute (salary) - "Computes my value per minute based on my current SALARY. -Signature: f :: Rate -> Rate -This is assuming that all of my time is equally valuable. See the above - discussion about the various classifications of my time.") - -;; TODO: See note above about isomorphisms between various rates. -(defun me-seconds/value (salary x) - "Compute the value of X minutes of my time at my current SALARY. -f :: Rate -> Integer -> Money") - -(macros/comment - (rate/to-string me-seconds/salary) - ) - -(provide 'me-seconds) -;;; me-seconds.el ends here diff --git a/emacs/.emacs.d/wpc/monoid.el b/emacs/.emacs.d/wpc/monoid.el deleted file mode 100644 index 401d63c41728..000000000000 --- a/emacs/.emacs.d/wpc/monoid.el +++ /dev/null @@ -1,30 +0,0 @@ -;;; monoid.el --- Working with Monoids in Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; The day has finally arrived where I'm using Monoids in Elisp. -;; -;; The monoid typeclass is as follows: -;; - empty :: a -;; - concat :: (list a) -> a - -;;; Code: - -;; TODO: Consider a prelude version that works for all Elisp types. -(defun monoid/classify (xs) - "Return the type of `XS'." - (cond - ((listp xs) 'list) - ((vectorp xs) 'vector) - ((stringp xs) 'string))) - - -(defun monoid/empty (xs) - "Return the empty monoid for the type `XS'." - (pcase (monoid/classify xs) - ('list '()) - ('vector []) - ('string ""))) - -(provide 'monoid) -;;; monoid.el ends here diff --git a/emacs/.emacs.d/wpc/playback.el b/emacs/.emacs.d/wpc/playback.el deleted file mode 100644 index e7ad4b2481a4..000000000000 --- a/emacs/.emacs.d/wpc/playback.el +++ /dev/null @@ -1,41 +0,0 @@ -;;; playback.el --- Control playback with Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; As you know, my whole universe is turning Elisp, so this should too! - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dependencies -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'prelude) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun playback/prev () - "Move to the previous song." - (interactive) - (prelude/start-process - :name "playback/prev" - :command "playerctl previous")) - -(defun playback/next () - "Move to the next song." - (interactive) - (prelude/start-process - :name "playback/next" - :command "playerctl next")) - -(defun playback/play-pause () - "Play or pause the current song." - (interactive) - (prelude/start-process - :name "playback/play-pause" - :command "playerctl play-pause")) - -(provide 'playback) -;;; playback.el ends here diff --git a/emacs/.emacs.d/wpc/polymorphism.el b/emacs/.emacs.d/wpc/polymorphism.el deleted file mode 100644 index 09045f7fb258..000000000000 --- a/emacs/.emacs.d/wpc/polymorphism.el +++ /dev/null @@ -1,37 +0,0 @@ -;;; polymorphism.el --- Sketching my ideas for polymorphism in Elisp -*- lexical-binding: t -*- -;; Author: William Carroll <wpcarro@gmail.com> - -;;; Commentary: -;; Once again: modelled after Elixir. - -;;; Code: - -;; More sketches of Elisp polymorphism initiative. -;; -;; Two macros: -;; - `defprotocol' -;; - `definstance' -;; -;; Is it just a coincidence that these two macros have the same number of -;;characters or is that fate? I say fate. -;; -;; (defprotocol monoid -;; :functions (empty concat)) -;; -;; (definstance monoid vector -;; :empty -;; (lambda () []) -;; :concat -;; #'vector/concat) -;; -;; More sketching... -;; (defun monoid/empty () -;; "Sketch." -;; (funcall #'(,(monoid/classify)/empty))) -;; (defun monoid/concat (xs) -;; "Sketch." -;; (apply #'(,(monoid/classify)/concat) args)) - - -(provide 'polymorphism) -;;; polymorphism.el ends here |