This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require 'string) ;; personal library | |
| (require 'dash) | |
| (defmacro updatef (type field f xs) | |
| "Apply F to FIELD in XS, which is a struct of TYPE." | |
| (let ((copier (->> type | |
| symbol-name | |
| (string/prepend "copy-") | |
| intern)) | |
| (accessor (->> field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def danger(): | |
| if random.choice([True, False]): | |
| raise Exception | |
| def main(): | |
| """Attempt to loop `loop_count` times. Simulate random errors and create a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;; bytes.el --- Working with byte values -*- lexical-binding: t -*- | |
| ;; Author: William Carroll <[email protected]> | |
| ;;; Commentary: | |
| ;; Functions to help with human-readable representations of byte values. | |
| ;; | |
| ;; Usage: | |
| ;; See the test cases for example usage. Or better yet, I should use a type of | |
| ;; structured documentation that would allow me to expose a view into the test | |
| ;; suite here. Is this currently possible in Elisp? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphviz import Digraph | |
| from collections import deque | |
| # There are three ways to model a graph: | |
| # 1. Edge list: [(Vertex, Vertex)] | |
| # 2. Neighbors table: Map(Vertex, [Vertex]) | |
| # 3. Adjacency matrix: [[Boolean]] | |
| # | |
| # The following graph is a neighbors table. | |
| g = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; I was making some API calls where a URL needed a `since` parameter that of an | |
| ;; RFC 3339 encoded string. | |
| ;; | |
| ;; Because I didn't know what a RFC 3339 encoded | |
| ;; string was at the time, and because I didn't know what its format was | |
| ;; according to strftime, and because I'm most likely to forget both of these | |
| ;; things by the next time that I need something similar, I decided to write | |
| ;; this package so that I can accumulate a list of common time encodings. | |
| ;; | |
| ;; Thank you, Emacs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Author: [email protected] | |
| // | |
| // Wirelessly transfer RFC documents to your Kindle to device for an alternative | |
| // medium for reading. | |
| // | |
| // Usage: | |
| // ```shell | |
| // > go run rfcToKindle.go -document rfc6479 -recipient [email protected] | |
| // ``` | |
| // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; TODO(wpcarro): Consider defining a --diff-filter section with the following | |
| ;; magit switches: | |
| ;; --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] | |
| ;; Select only files that are Added (A), Copied (C), Deleted (D), Modified | |
| ;; (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, | |
| ;; ...) changed (T), are Unmerged (U), are Unknown (X), or have had their | |
| ;; pairing Broken (B). Any combination of the filter characters (including | |
| ;; none) can be used. When * (All-or-none) is added to the combination, all | |
| ;; paths are selected if there is any file that matches other criteria in | |
| ;; the comparison; if there is no file that matches other criteria, nothing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defconst display/display-states (cycle/from-list '((t . t) (t . nil) (nil . t))) | |
| "A list of cons cells modelling enabled and disabled states for my displays. | |
| The car models the enabled state of my laptop display; the cdr models the | |
| enabled state of my external monitor.") | |
| (defun display/cycle-display-states () | |
| "Cycle through `display/display-states' enabling and disabling displays." | |
| (interactive) | |
| (let ((state (cycle/next display/display-states))) | |
| (if (car state) (display/enable-laptop) (display/disable-laptop)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { config, pkgs, ... }: | |
| # TODO(wpcarro): Refactor to prefer nested attribute for configuration values | |
| # instead of using one-liner field accessors. | |
| { | |
| imports = [ | |
| ./hardware-configuration.nix | |
| ]; | |
| # TODO(wpcarro): Is this correct? I believe my laptop only supports BIOS and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Extras where | |
| -- | Create a list of all of the data constructors for a given type. | |
| enumAll :: (Bounded a, Enum a) => [a] | |
| enumAll = [minBound .. ] |