From fabf1c9334a86d55be133da851cafccc9e6319fe Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 12 Feb 2020 16:58:29 +0000 Subject: [PATCH] Tidy up structure of briefcase I had a spare fifteen minutes and decided that I should tidy up my monorepo. The work of tidying up is not finished; this is a small step in the right direction. TL;DR - Created a tools directory - Created a scratch directory (see README.md for more information) - Added README.md to third_party - Renamed delete_dotfile_symlinks -> symlinkManager - Packaged symlinkManager as an executable symlink-mgr using buildGo --- default.nix | 1 + gopkgs/utils/utils.go | 5 ++ scratch/README.md | 6 +++ .../crack_the_coding_interview}/11_1.py | 0 .../crack_the_coding_interview}/to_tree.hs | 0 .../array-traversals.py | 0 .../balanced-binary-tree.py | 0 .../bit-manipulation.py | 0 .../bracket-validator.py | 0 .../bst-checker.py | 0 .../cafe-order-checker.py | 0 .../cake-thief.py | 0 .../data_structures_and_algorithms}/coins.py | 0 .../conways-game-of-life.py | 0 .../delete-node.py | 0 .../data_structures_and_algorithms}/dft.py | 0 .../dijkstra-shortest-path.py | 0 ...find-duplicate-optimize-for-space-beast.py | 0 .../find-duplicate-optimize-for-space.py | 0 .../find-rotation-point.py | 0 .../find-unique-int-among-duplicates.py | 0 .../fixtures.py | 0 .../graph-coloring.py | 0 .../graph-to-graphviz.py | 0 .../highest-product-of-3.py | 0 .../inflight-entertainment.py | 0 .../knapsack-0-1.py | 0 .../kth-to-last.py | 0 .../largest-stack.py | 0 .../linked-list-cycles.py | 0 .../merge-sort.py | 0 .../merging-ranges.py | 0 .../mesh-message.gv | 0 .../mesh-message.py | 0 .../data_structures_and_algorithms}/norman.py | 0 .../nth-fibonacci.py | 0 .../optimal-stopping.py | 0 .../perm-tree.py | 0 .../permutation-palindrome.py | 0 .../permutations.py | 0 .../data_structures_and_algorithms}/plot.py | 0 .../product-of-other-numbers.py | 0 .../queue-two-stacks.py | 0 .../rectangular-love.py | 0 .../recursive-string-permutations.py | 0 .../reverse-linked-list.py | 0 .../reverse-words.py | 0 .../second-largest-item-bst.py | 0 .../shortest-path-inject-vertices.py | 0 .../shuffle.py | 0 .../string-reverse.py | 0 .../temperature-tracker.py | 0 .../data_structures_and_algorithms}/test.txt | 0 .../top-scores.py | 0 .../topo-sort.py | 0 .../trickling-water.py | 0 .../which-appears-twice.py | 0 .../part_one/balanced-binary-tree.py | 0 .../deepmind}/part_one/dijkstra.py | 0 .../deepmind}/part_one/efficiency.org | 0 .../deepmind}/part_one/find-rotation-point.py | 0 .../part_one/inflight-entertainment.py | 0 .../deepmind}/part_one/kth-to-last.py | 0 .../deepmind}/part_one/merging-ranges.py | 0 .../part_one/recursive-string-permutations.py | 0 .../deepmind}/part_one/reverse-linked-list.py | 0 .../deepmind}/part_one/stock-price.py | 0 .../deepmind}/part_one/which-appears-twice.py | 0 .../deepmind}/part_two/.envrc | 0 .../deepmind}/part_two/delete-node.py | 0 .../part_two/misc/matrix-traversals.py | 0 .../deepmind}/part_two/package-lock.json | 0 .../deepmind}/part_two/package.json | 0 .../part_two/reverse-string-in-place.ts | 0 .../deepmind}/part_two/shell.nix | 0 .../deepmind}/part_two/todo.org | 0 third_party/README.md | 5 ++ {rfcToKindle => tools/rfcToKindle}/LICENSE | 0 {rfcToKindle => tools/rfcToKindle}/README.md | 0 .../rfcToKindle}/default.nix | 0 {rfcToKindle => tools/rfcToKindle}/main.go | 0 {run => tools/run}/.envrc | 0 {run => tools/run}/README.md | 0 {run => tools/run}/default.nix | 0 {run => tools/run}/main.go | 0 {run => tools/run}/shell.nix | 0 tools/symlinkManager/README.md | 14 ++++++ tools/symlinkManager/default.nix | 15 ++++++ .../symlinkManager/main.go | 48 +++---------------- 89 files changed, 53 insertions(+), 41 deletions(-) create mode 100644 scratch/README.md rename {crack_the_coding_interview => scratch/crack_the_coding_interview}/11_1.py (100%) rename {crack_the_coding_interview => scratch/crack_the_coding_interview}/to_tree.hs (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/array-traversals.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/balanced-binary-tree.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/bit-manipulation.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/bracket-validator.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/bst-checker.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/cafe-order-checker.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/cake-thief.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/coins.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/conways-game-of-life.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/delete-node.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/dft.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/dijkstra-shortest-path.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/find-duplicate-optimize-for-space-beast.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/find-duplicate-optimize-for-space.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/find-rotation-point.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/find-unique-int-among-duplicates.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/fixtures.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/graph-coloring.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/graph-to-graphviz.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/highest-product-of-3.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/inflight-entertainment.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/knapsack-0-1.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/kth-to-last.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/largest-stack.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/linked-list-cycles.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/merge-sort.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/merging-ranges.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/mesh-message.gv (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/mesh-message.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/norman.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/nth-fibonacci.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/optimal-stopping.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/perm-tree.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/permutation-palindrome.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/permutations.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/plot.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/product-of-other-numbers.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/queue-two-stacks.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/rectangular-love.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/recursive-string-permutations.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/reverse-linked-list.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/reverse-words.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/second-largest-item-bst.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/shortest-path-inject-vertices.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/shuffle.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/string-reverse.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/temperature-tracker.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/test.txt (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/top-scores.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/topo-sort.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/trickling-water.py (100%) rename {data_structures_and_algorithms => scratch/data_structures_and_algorithms}/which-appears-twice.py (100%) rename {deepmind => scratch/deepmind}/part_one/balanced-binary-tree.py (100%) rename {deepmind => scratch/deepmind}/part_one/dijkstra.py (100%) rename {deepmind => scratch/deepmind}/part_one/efficiency.org (100%) rename {deepmind => scratch/deepmind}/part_one/find-rotation-point.py (100%) rename {deepmind => scratch/deepmind}/part_one/inflight-entertainment.py (100%) rename {deepmind => scratch/deepmind}/part_one/kth-to-last.py (100%) rename {deepmind => scratch/deepmind}/part_one/merging-ranges.py (100%) rename {deepmind => scratch/deepmind}/part_one/recursive-string-permutations.py (100%) rename {deepmind => scratch/deepmind}/part_one/reverse-linked-list.py (100%) rename {deepmind => scratch/deepmind}/part_one/stock-price.py (100%) rename {deepmind => scratch/deepmind}/part_one/which-appears-twice.py (100%) rename {deepmind => scratch/deepmind}/part_two/.envrc (100%) rename {deepmind => scratch/deepmind}/part_two/delete-node.py (100%) rename {deepmind => scratch/deepmind}/part_two/misc/matrix-traversals.py (100%) rename {deepmind => scratch/deepmind}/part_two/package-lock.json (100%) rename {deepmind => scratch/deepmind}/part_two/package.json (100%) rename {deepmind => scratch/deepmind}/part_two/reverse-string-in-place.ts (100%) rename {deepmind => scratch/deepmind}/part_two/shell.nix (100%) rename {deepmind => scratch/deepmind}/part_two/todo.org (100%) create mode 100644 third_party/README.md rename {rfcToKindle => tools/rfcToKindle}/LICENSE (100%) rename {rfcToKindle => tools/rfcToKindle}/README.md (100%) rename {rfcToKindle => tools/rfcToKindle}/default.nix (100%) rename {rfcToKindle => tools/rfcToKindle}/main.go (100%) rename {run => tools/run}/.envrc (100%) rename {run => tools/run}/README.md (100%) rename {run => tools/run}/default.nix (100%) rename {run => tools/run}/main.go (100%) rename {run => tools/run}/shell.nix (100%) create mode 100644 tools/symlinkManager/README.md create mode 100644 tools/symlinkManager/default.nix rename scripts/delete_dotfile_symlinks.go => tools/symlinkManager/main.go (66%) diff --git a/default.nix b/default.nix index 74268c803..cf7e61e4a 100644 --- a/default.nix +++ b/default.nix @@ -23,6 +23,7 @@ let gopkgs = readTree ./gopkgs; monzo_ynab = readTree ./monzo_ynab; third_party = readTree ./third_party; + tools = readTree ./tools; }; in fix(self: { config = config self; diff --git a/gopkgs/utils/utils.go b/gopkgs/utils/utils.go index 53136878d..7d662d086 100644 --- a/gopkgs/utils/utils.go +++ b/gopkgs/utils/utils.go @@ -21,6 +21,11 @@ func HomeDir() string { return user.HomeDir } +// Returns true if `info` is a symlink. +func IsSymlink(info os.FileMode) bool { + return info&os.ModeSymlink != 0 +} + // Return true if `path` exists and false otherwise. func FileExists(path string) bool { if _, err := os.Stat(path); os.IsNotExist(err) { diff --git a/scratch/README.md b/scratch/README.md new file mode 100644 index 000000000..8259ac70d --- /dev/null +++ b/scratch/README.md @@ -0,0 +1,6 @@ +# Scratch + +The purpose of the `scratch` directory is to host practice exercises. Practice +encompasses things like working on data structures and algorithms problems for +upcoming coding interviews or general aptitude as well as writing code snippets +to help me learn a new programming language or understand an unfamiliar concept. diff --git a/crack_the_coding_interview/11_1.py b/scratch/crack_the_coding_interview/11_1.py similarity index 100% rename from crack_the_coding_interview/11_1.py rename to scratch/crack_the_coding_interview/11_1.py diff --git a/crack_the_coding_interview/to_tree.hs b/scratch/crack_the_coding_interview/to_tree.hs similarity index 100% rename from crack_the_coding_interview/to_tree.hs rename to scratch/crack_the_coding_interview/to_tree.hs diff --git a/data_structures_and_algorithms/array-traversals.py b/scratch/data_structures_and_algorithms/array-traversals.py similarity index 100% rename from data_structures_and_algorithms/array-traversals.py rename to scratch/data_structures_and_algorithms/array-traversals.py diff --git a/data_structures_and_algorithms/balanced-binary-tree.py b/scratch/data_structures_and_algorithms/balanced-binary-tree.py similarity index 100% rename from data_structures_and_algorithms/balanced-binary-tree.py rename to scratch/data_structures_and_algorithms/balanced-binary-tree.py diff --git a/data_structures_and_algorithms/bit-manipulation.py b/scratch/data_structures_and_algorithms/bit-manipulation.py similarity index 100% rename from data_structures_and_algorithms/bit-manipulation.py rename to scratch/data_structures_and_algorithms/bit-manipulation.py diff --git a/data_structures_and_algorithms/bracket-validator.py b/scratch/data_structures_and_algorithms/bracket-validator.py similarity index 100% rename from data_structures_and_algorithms/bracket-validator.py rename to scratch/data_structures_and_algorithms/bracket-validator.py diff --git a/data_structures_and_algorithms/bst-checker.py b/scratch/data_structures_and_algorithms/bst-checker.py similarity index 100% rename from data_structures_and_algorithms/bst-checker.py rename to scratch/data_structures_and_algorithms/bst-checker.py diff --git a/data_structures_and_algorithms/cafe-order-checker.py b/scratch/data_structures_and_algorithms/cafe-order-checker.py similarity index 100% rename from data_structures_and_algorithms/cafe-order-checker.py rename to scratch/data_structures_and_algorithms/cafe-order-checker.py diff --git a/data_structures_and_algorithms/cake-thief.py b/scratch/data_structures_and_algorithms/cake-thief.py similarity index 100% rename from data_structures_and_algorithms/cake-thief.py rename to scratch/data_structures_and_algorithms/cake-thief.py diff --git a/data_structures_and_algorithms/coins.py b/scratch/data_structures_and_algorithms/coins.py similarity index 100% rename from data_structures_and_algorithms/coins.py rename to scratch/data_structures_and_algorithms/coins.py diff --git a/data_structures_and_algorithms/conways-game-of-life.py b/scratch/data_structures_and_algorithms/conways-game-of-life.py similarity index 100% rename from data_structures_and_algorithms/conways-game-of-life.py rename to scratch/data_structures_and_algorithms/conways-game-of-life.py diff --git a/data_structures_and_algorithms/delete-node.py b/scratch/data_structures_and_algorithms/delete-node.py similarity index 100% rename from data_structures_and_algorithms/delete-node.py rename to scratch/data_structures_and_algorithms/delete-node.py diff --git a/data_structures_and_algorithms/dft.py b/scratch/data_structures_and_algorithms/dft.py similarity index 100% rename from data_structures_and_algorithms/dft.py rename to scratch/data_structures_and_algorithms/dft.py diff --git a/data_structures_and_algorithms/dijkstra-shortest-path.py b/scratch/data_structures_and_algorithms/dijkstra-shortest-path.py similarity index 100% rename from data_structures_and_algorithms/dijkstra-shortest-path.py rename to scratch/data_structures_and_algorithms/dijkstra-shortest-path.py diff --git a/data_structures_and_algorithms/find-duplicate-optimize-for-space-beast.py b/scratch/data_structures_and_algorithms/find-duplicate-optimize-for-space-beast.py similarity index 100% rename from data_structures_and_algorithms/find-duplicate-optimize-for-space-beast.py rename to scratch/data_structures_and_algorithms/find-duplicate-optimize-for-space-beast.py diff --git a/data_structures_and_algorithms/find-duplicate-optimize-for-space.py b/scratch/data_structures_and_algorithms/find-duplicate-optimize-for-space.py similarity index 100% rename from data_structures_and_algorithms/find-duplicate-optimize-for-space.py rename to scratch/data_structures_and_algorithms/find-duplicate-optimize-for-space.py diff --git a/data_structures_and_algorithms/find-rotation-point.py b/scratch/data_structures_and_algorithms/find-rotation-point.py similarity index 100% rename from data_structures_and_algorithms/find-rotation-point.py rename to scratch/data_structures_and_algorithms/find-rotation-point.py diff --git a/data_structures_and_algorithms/find-unique-int-among-duplicates.py b/scratch/data_structures_and_algorithms/find-unique-int-among-duplicates.py similarity index 100% rename from data_structures_and_algorithms/find-unique-int-among-duplicates.py rename to scratch/data_structures_and_algorithms/find-unique-int-among-duplicates.py diff --git a/data_structures_and_algorithms/fixtures.py b/scratch/data_structures_and_algorithms/fixtures.py similarity index 100% rename from data_structures_and_algorithms/fixtures.py rename to scratch/data_structures_and_algorithms/fixtures.py diff --git a/data_structures_and_algorithms/graph-coloring.py b/scratch/data_structures_and_algorithms/graph-coloring.py similarity index 100% rename from data_structures_and_algorithms/graph-coloring.py rename to scratch/data_structures_and_algorithms/graph-coloring.py diff --git a/data_structures_and_algorithms/graph-to-graphviz.py b/scratch/data_structures_and_algorithms/graph-to-graphviz.py similarity index 100% rename from data_structures_and_algorithms/graph-to-graphviz.py rename to scratch/data_structures_and_algorithms/graph-to-graphviz.py diff --git a/data_structures_and_algorithms/highest-product-of-3.py b/scratch/data_structures_and_algorithms/highest-product-of-3.py similarity index 100% rename from data_structures_and_algorithms/highest-product-of-3.py rename to scratch/data_structures_and_algorithms/highest-product-of-3.py diff --git a/data_structures_and_algorithms/inflight-entertainment.py b/scratch/data_structures_and_algorithms/inflight-entertainment.py similarity index 100% rename from data_structures_and_algorithms/inflight-entertainment.py rename to scratch/data_structures_and_algorithms/inflight-entertainment.py diff --git a/data_structures_and_algorithms/knapsack-0-1.py b/scratch/data_structures_and_algorithms/knapsack-0-1.py similarity index 100% rename from data_structures_and_algorithms/knapsack-0-1.py rename to scratch/data_structures_and_algorithms/knapsack-0-1.py diff --git a/data_structures_and_algorithms/kth-to-last.py b/scratch/data_structures_and_algorithms/kth-to-last.py similarity index 100% rename from data_structures_and_algorithms/kth-to-last.py rename to scratch/data_structures_and_algorithms/kth-to-last.py diff --git a/data_structures_and_algorithms/largest-stack.py b/scratch/data_structures_and_algorithms/largest-stack.py similarity index 100% rename from data_structures_and_algorithms/largest-stack.py rename to scratch/data_structures_and_algorithms/largest-stack.py diff --git a/data_structures_and_algorithms/linked-list-cycles.py b/scratch/data_structures_and_algorithms/linked-list-cycles.py similarity index 100% rename from data_structures_and_algorithms/linked-list-cycles.py rename to scratch/data_structures_and_algorithms/linked-list-cycles.py diff --git a/data_structures_and_algorithms/merge-sort.py b/scratch/data_structures_and_algorithms/merge-sort.py similarity index 100% rename from data_structures_and_algorithms/merge-sort.py rename to scratch/data_structures_and_algorithms/merge-sort.py diff --git a/data_structures_and_algorithms/merging-ranges.py b/scratch/data_structures_and_algorithms/merging-ranges.py similarity index 100% rename from data_structures_and_algorithms/merging-ranges.py rename to scratch/data_structures_and_algorithms/merging-ranges.py diff --git a/data_structures_and_algorithms/mesh-message.gv b/scratch/data_structures_and_algorithms/mesh-message.gv similarity index 100% rename from data_structures_and_algorithms/mesh-message.gv rename to scratch/data_structures_and_algorithms/mesh-message.gv diff --git a/data_structures_and_algorithms/mesh-message.py b/scratch/data_structures_and_algorithms/mesh-message.py similarity index 100% rename from data_structures_and_algorithms/mesh-message.py rename to scratch/data_structures_and_algorithms/mesh-message.py diff --git a/data_structures_and_algorithms/norman.py b/scratch/data_structures_and_algorithms/norman.py similarity index 100% rename from data_structures_and_algorithms/norman.py rename to scratch/data_structures_and_algorithms/norman.py diff --git a/data_structures_and_algorithms/nth-fibonacci.py b/scratch/data_structures_and_algorithms/nth-fibonacci.py similarity index 100% rename from data_structures_and_algorithms/nth-fibonacci.py rename to scratch/data_structures_and_algorithms/nth-fibonacci.py diff --git a/data_structures_and_algorithms/optimal-stopping.py b/scratch/data_structures_and_algorithms/optimal-stopping.py similarity index 100% rename from data_structures_and_algorithms/optimal-stopping.py rename to scratch/data_structures_and_algorithms/optimal-stopping.py diff --git a/data_structures_and_algorithms/perm-tree.py b/scratch/data_structures_and_algorithms/perm-tree.py similarity index 100% rename from data_structures_and_algorithms/perm-tree.py rename to scratch/data_structures_and_algorithms/perm-tree.py diff --git a/data_structures_and_algorithms/permutation-palindrome.py b/scratch/data_structures_and_algorithms/permutation-palindrome.py similarity index 100% rename from data_structures_and_algorithms/permutation-palindrome.py rename to scratch/data_structures_and_algorithms/permutation-palindrome.py diff --git a/data_structures_and_algorithms/permutations.py b/scratch/data_structures_and_algorithms/permutations.py similarity index 100% rename from data_structures_and_algorithms/permutations.py rename to scratch/data_structures_and_algorithms/permutations.py diff --git a/data_structures_and_algorithms/plot.py b/scratch/data_structures_and_algorithms/plot.py similarity index 100% rename from data_structures_and_algorithms/plot.py rename to scratch/data_structures_and_algorithms/plot.py diff --git a/data_structures_and_algorithms/product-of-other-numbers.py b/scratch/data_structures_and_algorithms/product-of-other-numbers.py similarity index 100% rename from data_structures_and_algorithms/product-of-other-numbers.py rename to scratch/data_structures_and_algorithms/product-of-other-numbers.py diff --git a/data_structures_and_algorithms/queue-two-stacks.py b/scratch/data_structures_and_algorithms/queue-two-stacks.py similarity index 100% rename from data_structures_and_algorithms/queue-two-stacks.py rename to scratch/data_structures_and_algorithms/queue-two-stacks.py diff --git a/data_structures_and_algorithms/rectangular-love.py b/scratch/data_structures_and_algorithms/rectangular-love.py similarity index 100% rename from data_structures_and_algorithms/rectangular-love.py rename to scratch/data_structures_and_algorithms/rectangular-love.py diff --git a/data_structures_and_algorithms/recursive-string-permutations.py b/scratch/data_structures_and_algorithms/recursive-string-permutations.py similarity index 100% rename from data_structures_and_algorithms/recursive-string-permutations.py rename to scratch/data_structures_and_algorithms/recursive-string-permutations.py diff --git a/data_structures_and_algorithms/reverse-linked-list.py b/scratch/data_structures_and_algorithms/reverse-linked-list.py similarity index 100% rename from data_structures_and_algorithms/reverse-linked-list.py rename to scratch/data_structures_and_algorithms/reverse-linked-list.py diff --git a/data_structures_and_algorithms/reverse-words.py b/scratch/data_structures_and_algorithms/reverse-words.py similarity index 100% rename from data_structures_and_algorithms/reverse-words.py rename to scratch/data_structures_and_algorithms/reverse-words.py diff --git a/data_structures_and_algorithms/second-largest-item-bst.py b/scratch/data_structures_and_algorithms/second-largest-item-bst.py similarity index 100% rename from data_structures_and_algorithms/second-largest-item-bst.py rename to scratch/data_structures_and_algorithms/second-largest-item-bst.py diff --git a/data_structures_and_algorithms/shortest-path-inject-vertices.py b/scratch/data_structures_and_algorithms/shortest-path-inject-vertices.py similarity index 100% rename from data_structures_and_algorithms/shortest-path-inject-vertices.py rename to scratch/data_structures_and_algorithms/shortest-path-inject-vertices.py diff --git a/data_structures_and_algorithms/shuffle.py b/scratch/data_structures_and_algorithms/shuffle.py similarity index 100% rename from data_structures_and_algorithms/shuffle.py rename to scratch/data_structures_and_algorithms/shuffle.py diff --git a/data_structures_and_algorithms/string-reverse.py b/scratch/data_structures_and_algorithms/string-reverse.py similarity index 100% rename from data_structures_and_algorithms/string-reverse.py rename to scratch/data_structures_and_algorithms/string-reverse.py diff --git a/data_structures_and_algorithms/temperature-tracker.py b/scratch/data_structures_and_algorithms/temperature-tracker.py similarity index 100% rename from data_structures_and_algorithms/temperature-tracker.py rename to scratch/data_structures_and_algorithms/temperature-tracker.py diff --git a/data_structures_and_algorithms/test.txt b/scratch/data_structures_and_algorithms/test.txt similarity index 100% rename from data_structures_and_algorithms/test.txt rename to scratch/data_structures_and_algorithms/test.txt diff --git a/data_structures_and_algorithms/top-scores.py b/scratch/data_structures_and_algorithms/top-scores.py similarity index 100% rename from data_structures_and_algorithms/top-scores.py rename to scratch/data_structures_and_algorithms/top-scores.py diff --git a/data_structures_and_algorithms/topo-sort.py b/scratch/data_structures_and_algorithms/topo-sort.py similarity index 100% rename from data_structures_and_algorithms/topo-sort.py rename to scratch/data_structures_and_algorithms/topo-sort.py diff --git a/data_structures_and_algorithms/trickling-water.py b/scratch/data_structures_and_algorithms/trickling-water.py similarity index 100% rename from data_structures_and_algorithms/trickling-water.py rename to scratch/data_structures_and_algorithms/trickling-water.py diff --git a/data_structures_and_algorithms/which-appears-twice.py b/scratch/data_structures_and_algorithms/which-appears-twice.py similarity index 100% rename from data_structures_and_algorithms/which-appears-twice.py rename to scratch/data_structures_and_algorithms/which-appears-twice.py diff --git a/deepmind/part_one/balanced-binary-tree.py b/scratch/deepmind/part_one/balanced-binary-tree.py similarity index 100% rename from deepmind/part_one/balanced-binary-tree.py rename to scratch/deepmind/part_one/balanced-binary-tree.py diff --git a/deepmind/part_one/dijkstra.py b/scratch/deepmind/part_one/dijkstra.py similarity index 100% rename from deepmind/part_one/dijkstra.py rename to scratch/deepmind/part_one/dijkstra.py diff --git a/deepmind/part_one/efficiency.org b/scratch/deepmind/part_one/efficiency.org similarity index 100% rename from deepmind/part_one/efficiency.org rename to scratch/deepmind/part_one/efficiency.org diff --git a/deepmind/part_one/find-rotation-point.py b/scratch/deepmind/part_one/find-rotation-point.py similarity index 100% rename from deepmind/part_one/find-rotation-point.py rename to scratch/deepmind/part_one/find-rotation-point.py diff --git a/deepmind/part_one/inflight-entertainment.py b/scratch/deepmind/part_one/inflight-entertainment.py similarity index 100% rename from deepmind/part_one/inflight-entertainment.py rename to scratch/deepmind/part_one/inflight-entertainment.py diff --git a/deepmind/part_one/kth-to-last.py b/scratch/deepmind/part_one/kth-to-last.py similarity index 100% rename from deepmind/part_one/kth-to-last.py rename to scratch/deepmind/part_one/kth-to-last.py diff --git a/deepmind/part_one/merging-ranges.py b/scratch/deepmind/part_one/merging-ranges.py similarity index 100% rename from deepmind/part_one/merging-ranges.py rename to scratch/deepmind/part_one/merging-ranges.py diff --git a/deepmind/part_one/recursive-string-permutations.py b/scratch/deepmind/part_one/recursive-string-permutations.py similarity index 100% rename from deepmind/part_one/recursive-string-permutations.py rename to scratch/deepmind/part_one/recursive-string-permutations.py diff --git a/deepmind/part_one/reverse-linked-list.py b/scratch/deepmind/part_one/reverse-linked-list.py similarity index 100% rename from deepmind/part_one/reverse-linked-list.py rename to scratch/deepmind/part_one/reverse-linked-list.py diff --git a/deepmind/part_one/stock-price.py b/scratch/deepmind/part_one/stock-price.py similarity index 100% rename from deepmind/part_one/stock-price.py rename to scratch/deepmind/part_one/stock-price.py diff --git a/deepmind/part_one/which-appears-twice.py b/scratch/deepmind/part_one/which-appears-twice.py similarity index 100% rename from deepmind/part_one/which-appears-twice.py rename to scratch/deepmind/part_one/which-appears-twice.py diff --git a/deepmind/part_two/.envrc b/scratch/deepmind/part_two/.envrc similarity index 100% rename from deepmind/part_two/.envrc rename to scratch/deepmind/part_two/.envrc diff --git a/deepmind/part_two/delete-node.py b/scratch/deepmind/part_two/delete-node.py similarity index 100% rename from deepmind/part_two/delete-node.py rename to scratch/deepmind/part_two/delete-node.py diff --git a/deepmind/part_two/misc/matrix-traversals.py b/scratch/deepmind/part_two/misc/matrix-traversals.py similarity index 100% rename from deepmind/part_two/misc/matrix-traversals.py rename to scratch/deepmind/part_two/misc/matrix-traversals.py diff --git a/deepmind/part_two/package-lock.json b/scratch/deepmind/part_two/package-lock.json similarity index 100% rename from deepmind/part_two/package-lock.json rename to scratch/deepmind/part_two/package-lock.json diff --git a/deepmind/part_two/package.json b/scratch/deepmind/part_two/package.json similarity index 100% rename from deepmind/part_two/package.json rename to scratch/deepmind/part_two/package.json diff --git a/deepmind/part_two/reverse-string-in-place.ts b/scratch/deepmind/part_two/reverse-string-in-place.ts similarity index 100% rename from deepmind/part_two/reverse-string-in-place.ts rename to scratch/deepmind/part_two/reverse-string-in-place.ts diff --git a/deepmind/part_two/shell.nix b/scratch/deepmind/part_two/shell.nix similarity index 100% rename from deepmind/part_two/shell.nix rename to scratch/deepmind/part_two/shell.nix diff --git a/deepmind/part_two/todo.org b/scratch/deepmind/part_two/todo.org similarity index 100% rename from deepmind/part_two/todo.org rename to scratch/deepmind/part_two/todo.org diff --git a/third_party/README.md b/third_party/README.md new file mode 100644 index 000000000..29e498a37 --- /dev/null +++ b/third_party/README.md @@ -0,0 +1,5 @@ +# third_party + +The `third_party` directory hosts Nix expressions that package software that I +cannot or have not found in other Nix package repositorys like `nixpkgs` or +`depot`. diff --git a/rfcToKindle/LICENSE b/tools/rfcToKindle/LICENSE similarity index 100% rename from rfcToKindle/LICENSE rename to tools/rfcToKindle/LICENSE diff --git a/rfcToKindle/README.md b/tools/rfcToKindle/README.md similarity index 100% rename from rfcToKindle/README.md rename to tools/rfcToKindle/README.md diff --git a/rfcToKindle/default.nix b/tools/rfcToKindle/default.nix similarity index 100% rename from rfcToKindle/default.nix rename to tools/rfcToKindle/default.nix diff --git a/rfcToKindle/main.go b/tools/rfcToKindle/main.go similarity index 100% rename from rfcToKindle/main.go rename to tools/rfcToKindle/main.go diff --git a/run/.envrc b/tools/run/.envrc similarity index 100% rename from run/.envrc rename to tools/run/.envrc diff --git a/run/README.md b/tools/run/README.md similarity index 100% rename from run/README.md rename to tools/run/README.md diff --git a/run/default.nix b/tools/run/default.nix similarity index 100% rename from run/default.nix rename to tools/run/default.nix diff --git a/run/main.go b/tools/run/main.go similarity index 100% rename from run/main.go rename to tools/run/main.go diff --git a/run/shell.nix b/tools/run/shell.nix similarity index 100% rename from run/shell.nix rename to tools/run/shell.nix diff --git a/tools/symlinkManager/README.md b/tools/symlinkManager/README.md new file mode 100644 index 000000000..b0fc58c8e --- /dev/null +++ b/tools/symlinkManager/README.md @@ -0,0 +1,14 @@ +# Dotfile Symlink Manager + +Find and delete all symlinks to the dotfiles defined in `$BRIEFCASE`. + +Oftentimes I corrupt the state of my configuration files. The intention with +this script is to help me clean things up when this happens. An example workflow +might look like: + +```shell +> symlink-mgr --audit +> symlink-mgr --seriously +> briefcase # changes directory to $BRIEFCASE +> make install +``` diff --git a/tools/symlinkManager/default.nix b/tools/symlinkManager/default.nix new file mode 100644 index 000000000..6500991ba --- /dev/null +++ b/tools/symlinkManager/default.nix @@ -0,0 +1,15 @@ +{ + depot ? import {}, + briefcase ? import {}, + ... +}: + +depot.buildGo.program { + name = "symlink-mgr"; + srcs = [ + ./main.go + ]; + deps = with briefcase.gopkgs; [ + utils + ]; +} diff --git a/scripts/delete_dotfile_symlinks.go b/tools/symlinkManager/main.go similarity index 66% rename from scripts/delete_dotfile_symlinks.go rename to tools/symlinkManager/main.go index 497b2d57b..5d133e37d 100644 --- a/scripts/delete_dotfile_symlinks.go +++ b/tools/symlinkManager/main.go @@ -1,21 +1,3 @@ -// Find and delete all symlinks to the dotfiles defined in $BRIEFCASE. -// -// Oftentimes I corrupt the state of my dotfiles. The intention with this script -// is to write some tooling to help me better manage my dotfile cleanliness. An -// example workflow might look like: -// -// ```shell -// > go run delete_dotfile_symlinks.go --audit -// > go run delete_dotfile_symlinks.go --seriously -// > cd .. -// > make install -// ``` -// -// Outstanding TODOs: -// - Package this with buildGo.nix. -// - How can this be run as script without `go run`? She-bang at the top? -// - See TODOs within this package. - package main import ( @@ -26,25 +8,9 @@ import ( "os" "path/filepath" "strings" + "utils" ) -// Wanted for go tooling: -// 1. jump-to-def -// 2. documentation at point -// 3. autocompletion - -// TODO: Consider adding this to a utils.go package. -func failOn(err error) { - if err != nil { - log.Fatal(err) - } -} - -// TODO: Consider adding this to a utils.go package. -func isSymlink(m os.FileMode) bool { - return m&os.ModeSymlink != 0 -} - var hostnames = map[string]string{ os.Getenv("DESKTOP"): "desktop", os.Getenv("LAPTOP"): "work_laptop", @@ -66,13 +32,13 @@ func main() { } home, err := os.UserHomeDir() - failOn(err) + utils.FailOn(err) count := 0 err = filepath.Walk(home, func(path string, info os.FileInfo, err error) error { - if isSymlink(info.Mode()) { + if utils.IsSymlink(info.Mode()) { dest, err := os.Readlink(path) - failOn(err) + utils.FailOn(err) var predicate func(string) bool @@ -80,7 +46,7 @@ func main() { predicate = func(dest string) bool { var hostname string hostname, err = os.Hostname() - failOn(err) + utils.FailOn(err) seeking, ok := hostnames[hostname] if !ok { log.Fatal(fmt.Sprintf("Hostname \"%s\" not supported in the hostnames map.", hostname)) @@ -99,14 +65,14 @@ func main() { } else if *seriously { fmt.Printf("rm %s\n", path) err = os.Remove(path) - failOn(err) + utils.FailOn(err) } count += 1 } } return nil }) - failOn(err) + utils.FailOn(err) if *audit { fmt.Printf("Would have deleted %d symlinks.\n", count) } else if *seriously {