Commit graph

1112 commits

Author SHA1 Message Date
William Carroll
bfa1aea14f Drop support for irssi
I've been using ERC for awhile, and I haven't switched back to irssi.
2020-03-05 14:19:44 +00:00
William Carroll
87f592750d Drop support for gvcci
I supported gvcci before I switched to EXWM. Now that I'm using EXWM, I prefer
keeping things simple and using Doom's solarized-light theme.
2020-03-05 14:15:52 +00:00
William Carroll
32fb5b9a1b Move gpg.conf to home-manager
- Migrate gpg.conf settings to home-manager
- Delete gpg.conf
2020-03-05 14:14:03 +00:00
William Carroll
28745c5f84 Drop support for Docker
I don't use Docker shells enough to justify maintaining this.
2020-03-05 14:10:23 +00:00
William Carroll
3b689f03de Support gitconfig with home-manager
- Migrate configuration from .gitconfig to home-manager.
- Delete .gitconfig.
- Delete .gitignore because I'm not using OSX anymore.
2020-03-05 14:09:21 +00:00
William Carroll
0cb1086adc Support Nix home-manager
Last night @adisbladis convinced me to try home manager. I'm growing weary of
wrestling with symlinks, so I'm willing to give this a try.
2020-03-05 13:18:17 +00:00
William Carroll
26c340bfd2 Drop support for functions.fish
I'm not using the functions defined in this file, and it is causing me in
trouble.
2020-03-04 20:43:31 +00:00
William Carroll
8695b5b1d1 Drop support for hub
I'm not using hub much lately and it's causing me trouble.
2020-03-04 20:39:37 +00:00
William Carroll
4a1523caba Ensure fish config is compatible with Tramp
Ensure that my config.fish does not interfere with Tramp.
2020-03-04 20:16:53 +00:00
William Carroll
dec005ea34 Consume top-level emacs attribute
Refactor `nix/rebuild-emacs` to consume newly defined top-level emacs
attribute.
2020-03-04 19:49:45 +00:00
William Carroll
b0dfa088a5 Move emacs to top-level nix expression
When I run `nix-build -f '<briefcase>' -iA emacs`, readTree will define...
- pkgs
- depot
- briefcase
...and whatever else I choose to define.
2020-03-04 19:49:45 +00:00
William Carroll
11d8336733 Support custom fish prompt
Today I wrote myself a custom fish prompt. It's mostly what I'd like, but I'd
like to finely tune it a bit. I'd like to create a separate repository to
release this. In that repository, I'll explain why I wrote this.
2020-03-04 19:49:45 +00:00
William Carroll
549e56186b Solve InterviewCake's product-of-other-numbers
This problem challenged me: without using division, write a function that maps a
list of integers into a list of the product of every integer in the list except
for the integer at that index.

This was another greedy algorithm. The take-away is to first solve the problem
using brute force; this yields an algorithm with O(n*(n-1)) time
complexity. Instead of a quadratic time complexity, a linear time complexity can
be achieved my iterating over the list of integers twice:
1. Compute the products of every number to the left of the current number.
2. Compute the products of every number to the right of the current number.

Finally, iterate over each of these and compute lhs * rhs. Even though I've
solved this problem before, I used InterviewCake's hints because I was stuck
without them.

I should revisit this problem in a few weeks.
2020-03-02 16:45:15 +00:00
William Carroll
22d70b52c9 Read Paul Graham article "Taste for Makers"
I'm considering this essay one of my favorites from Paul Graham. The essay
argues that good taste and bad taste exist. Graham argues against relativism in
design and cites a variety of examples of architecture, typography, writing,
sketching, painting, aircraft design, and others that bolster his opinion.

TL;DR - Design should strive to be:
- Simple: Prefer simplicity to complexity when possible.
- Timeless: Design today for tomorrow by pleasing yesterday.
- Pointed: Focus always on the problem; don't work for work's sake.
- Suggestive: Constrain usage without suffocating the user.
- Humorous: Prefer light-heartedness to sobriety.
- Difficult: "Good design" is takes time, effort, and tremendous skill.
- Ostensibly effortless: Solutions should look obviously correct.
- Symmetric Appreciate symmetry.
- Natural: In nature, form ever follows function.
- Iterative: Write; rewrite; rewrite; rewrite; throw away; write; publish.
- Imitative: Be confident enough to copy others' existing, beautiful ideas.
- Communal: Pay attention to "Schelling points" and join the party. Don't be the
  Milanese Da Vinci.
- Fearless: Question the status quo; expect others to challenge your solution.
2020-03-02 13:09:07 +00:00
William Carroll
6eb239dcce Manually require dependencies for <nixpkgs>, <briefcase>
When I build socrates using `sudo nixos-rebuild [...] switch`, my
`nixos-config` (i.e. <briefcase/nixos/socrates/default.nix>) is a simple Nix
anonymous function. Typically readTree populates my pkgs, briefcase, depot
function parameters with <nixpkgs>, <briefcase>, <depot>, but `nixos-rebuild` is
unaware of `readTree`.

For now I'm manually importing these dependencies, and I'm leaving a TODO to
reconsider switching to the `{ pkgs, briefcase, ... }` style when I better
understand NixOS.
2020-03-01 22:44:35 +00:00
William Carroll
3e51bf600a Removing unused parameters in installer.nix
I'm neither using config nor pkgs, so I'm deleteing them.
2020-03-01 22:32:25 +00:00
William Carroll
42c6ad3bb4 Simpify top-level nix expression
When I first created the monorepo, I borrowed @tazjin's monorepo's. I adapted
his depot/default.nix, replacing some of his paths with my paths. This worked
for me until recently.

I attemped to include <briefcase/monzo_ynab/job> as a systemd unit for my NixOS
machine, socrates. NixOS failed to build my changes, and I didn't fully
understand my default.nix since I borrowed most of it from @tazjin. I spent the
past week looking at the `fix` function. I realized that I didn't fully
understand how fixed-point recursion worked. This sent me down a rabbit hole
terminating with me studying the Y and Z combinators.

Ironically, after understanding the `fix` function, I realized that I didn't
need to use it where I was consuming it. I ended up pruning most of my
configuration, which resulted in this commit.

Yours truly,
lambda f: (lambda x: f(x(x)))(lambda x: f(x(x)))
2020-03-01 22:32:25 +00:00
William Carroll
b4689761d9 Solve InterviewCake's highest-product-of-3
Write a function that returns the highest product of three integers within a
list of integers. This solution uses a greedy algorithm that solves for the
answer in linear time. The space complexity is constant.
2020-03-01 22:32:25 +00:00
William Carroll
dff621922c Remove HTML-encoded quote
Prefer ' to &#39;
2020-03-01 22:32:25 +00:00
William Carroll
4d2d19f136 Solve InterviewCake's stock-price problem
Write a function that returns the maximum profit that a trader could have made
in a day. I solved this using a greedy algorithm which constantly sets the
maximum profit by tracking the lowest price we've encountered.
2020-03-01 22:32:25 +00:00
William Carroll
3abee3373c Use doom-modeline
Cleaning up my modeline by using the beautiful doom-modeline package.
2020-03-01 22:32:25 +00:00
William Carroll
710849f3b3 Read Paul Graham's "Five Questions about Language Design"
This article felt like a summary of "Being Popular". I'd suggest reading both of
these.
2020-03-01 22:32:24 +00:00
William Carroll
d2aa66a5b1 Solve InterviewCake's top-scores
Using a counting sort to sort a list of values in linear time.
2020-03-01 22:32:24 +00:00
William Carroll
e4cdb5daed Solve InterviewCake's word-cloud problem
Write a function to count the frequency of words in a sentence. Ignore casing
for words; ignore punctuation.
2020-03-01 22:32:24 +00:00
William Carroll
ef2ce90aa7 Consolidate fish configuration
Months ago when I was revisiting Nix, I decided to nixify my fish
configuration. This was a useful learning exercise. I've had two config.fish
files floating around this repository ever since then. I sometimes update one
and other times I update the other. I'm consolidating these files into one, so I
that this is no longer as issue.
2020-03-01 22:32:24 +00:00
William Carroll
ea5db41722 Read Paul Graham's "Being Popular" essay
Maybe this is my recency bias writing, but "Being Popular" may be one of my
favorite Paul Graham essays that I've read.

"Being Popular" outlines Paul Graham's ideas about what an ideal programming
language would look like. This essay took me 1-2 hours to read, but it was worth
the time.

Here are some quotes that I enjoyed (not sorted in any meaningful order):

"A friend of mine rarely does anything the first time someone asks him. He knows
that people sometimes ask for things that they turn out not to want. To avoid
wasting his time, he waits till the third or fourth time he's asked to do
something; by then, whoever's asking him may be fairly annoyed, but at least
they probably really do want whatever they're asking for."

"In this particular case there is a way to finesse our way out of the
problem. If we treat data structures as if they were functions on indexes, we
could write (a x y) instead, which is even shorter than the Perl form. Similar
tricks may shorten other types of expressions."

"The latest hot language, Python, is a watered-down Lisp with infix syntax and
no macros."

"Hackers would think a lot more highly of Lisp if Common Lisp had powerful
string libraries and good OS support."

"I think language designers would do better to consider their target user to be
a genius who will need to do things they never anticipated, rather than a
bumbler who needs to be protected from himself."

Some take-aways:
- Let's refer to Python as "Diet Lisp" from now until the end of time.
- Fight to keep your user-base small for as long as you can. Only fools want
  large user bases.
- Rich Hickey definitely read this article; he took some ideas with him; he left
  some ideas behind.
- Focus language design efforts around defining rich standard libraries,
  especially for string manipulation.
- Worry little about supporting backwards compatibility; design a language that
  can and is often rewritten.
- Shift the burden of optimizing code performance to the user by designing a
  powerful runtime profiler that is tightly integrated into the language
  runtime.
- Minimize the costs users face when experimenting: ensure that your language is
  interactive; ensure users can create REPLs quickly.
- Support OS-level libraries (think about Go).
- Maximize introspection and hackability.

What a useful read!
2020-03-01 22:32:24 +00:00
William Carroll
93d654df77 Solve InterviewCake permutation-palindrome problem
Write a predicate to test whether any permutation of an input string is a
palindrome.
2020-03-01 22:32:24 +00:00
William Carroll
6249e19cdc Add nixos as top-level monorepo package
I'd like to be able to call...
`nix-build -E '(import <briefcase> {}).nixos.socrates'`
...as part of my efforts to wane my dependence off of `nixos-rebuild`.
2020-03-01 22:32:24 +00:00
William Carroll
9e0fdd3973 Remove default values for Nix expression parameters
I'm not sure if this commit breaks everything in my monorepo. I think it
will.

Why am I doing this? Perhaps it's a bad idea. I don't fully understand how
readTree works. My ignorance is costing me hours of time spent debugging. In an
effort to better understand readTree, I'm removing the default values for my Nix
expression parameters, which I believe have preventing errors from surfacing.
2020-03-01 22:32:24 +00:00
William Carroll
fd720fbe4d Nest configuration beneath socrates directory
Create a socrates directory to store configuration for socrates.
2020-03-01 22:32:24 +00:00
William Carroll
6a076e8329 Expose depot and briefcase to rebuild script
At the moment, I don't think nixos-rebuild is reading $NIX_PATH, which
appropriately sets the paths for depot and briefcase. I'm going to explicitly
expose these values in the rebuild script for now.
2020-02-23 20:11:33 +00:00
William Carroll
0973ca006c Define monzo-token-server as a root systemd service
After I considered the security implications of calling
`systemctl --user cat monzo-token-server`, I realized that monzo-token-server
should be a root service instead of a user service.

This service unit now also explicitly depends on briefcase.monzo_ynab.tokens,
which is a big improvement.
2020-02-23 20:01:33 +00:00
William Carroll
a1a4689ad3 Consume updated kv module
Exposing store_path to the tokens module to support the newly updated kv
module, which requires an explicit storePath parameter.
2020-02-23 20:01:15 +00:00
William Carroll
b5d4f547d2 Prefer explicit path for kv.json
Paying off some tech debt. Instead of relying ./kv.json existing, which is
relative to the directory from which I start a program, I'm preferring that a
consumer explicitly provides this path.
2020-02-23 19:58:19 +00:00
William Carroll
3f46ac6513 Change systemd unit type: oneshot -> simple
"oneshot", according to `man systemd.service`, "will consider the unit up after
the main process exits". Since I designed token-server to run continuously, it
will not intentionally exit; therefore, systemd awaits its exit, which never
comes. "simple", on the other hand, does what I want.
2020-02-23 19:32:52 +00:00
William Carroll
f926b4d61a Expose secrets to Monzo / YNAB service
Here is my first attempt to manage secrets when I deploy onto a NixOS machine.

Background: When I develop, I use direnv, which reads an .envrc file in which I
define my secrets. My secrets are read from `pass` using a pattern like this...

```shell
secret_value="$(pass show path/to/secret)"
```

...Thus far, I've found this pattern convenient. `pass show` invokes GPG, which
asks me for a password to authenticate. This means that when I cd into a
directory with an .envrc file using this pattern, I may be prompted by GPG for a
password. When I'm not, it's because gpg-agent is still caching my
password. This works for development, but I currently do not know how to use
direnv for deployments.

Here is what I'm using until I find a more convenient solution:
- Store the secrets in /etc/secrets on socrates. Ensure that the /etc/secrets
  directory and its contents are only readable by root.
- Use systemd's Environment and NixOS's builtins.readFile to read the files in
  /etc/secrets when I can `sudo nixos-rebuild`.

Ideally I could call a function like `builtins.readFromPasswordStore` within
configuration.nix. This would allow me to skip the step where I run...

```shell
> ssh socrates
> pass show finance/monzo/client-id | sudo tee /etc/secrets/monzo-client-id
> pass show finance/monzo/client-secret | sudo tee /etc/secrets/monzo-client-secret
> # etc
```

...I don't know how to manage secrets using NixOS, but at least this is one
answer.
2020-02-23 19:32:49 +00:00
William Carroll
527b472469 Converge naming of Acer laptop to "socrates"
Prefer "socrates" to "flattop".
2020-02-22 19:04:12 +00:00
William Carroll
695de12482 Incorporate NixOS configuration
TL;DR:
- Move /etc/nixos/configuration.nix -> //nixos/configuration.nix
- Move /etc/nixos/hardware-configuration.nix -> //nixos/harware.nix
- Document installer.nix
- Create rebuild.nix wrapper around `sudo nixos-rebuild switch`

Previously I sketched ideas for the configuration.nix for socrates -- also known
as flattop -- the inexpensive Acer laptop residing in my flat and stored that
configuration.nix file in briefcase. Now, however, I have successfully installed
NixOS onto socrates. By default NixOS saves the configuration.nix and
hardware-configuration.nix files to /etc/nixos/. I'm moving both of these files
into briefcase.

Because the command `nixos-rebuild` looks for the NixOS configuration
file in /etc/nixos, I wrote rebuild.nix, which creates a program to
call `nixos-rebuild` with the new location of my configuration.nix.
2020-02-22 18:44:44 +00:00
William Carroll
b53ae61db2 Read PG's Lisp for Web-Based Applications
Read Paul Graham's notes about the benefits of building Viaweb with Lisp. I
found it interesting how his competitors (in the 90s) were using CGI scripts to
build their web applications. I wonder how much of his advice would hold true
today...
2020-02-21 19:47:54 +00:00
William Carroll
00177d2e65 Read two PG essays
- Programming Bottom-Up: Benefits of writing reusable utility functions and
  amassing a personal utility belt. Specifically how lisp makes this easier than
  most or all languages.
- This Year We Can End the Death Penalty: Voting against the death penalty is
  voting against the killing of killers *and* the killing of innocent people,
  since some estimate that 4% of people on death row are in fact innocent.
2020-02-21 12:29:28 +00:00
William Carroll
0dd3987821 Solve InterviewCake's inflight-entertainment problem
Write a predicate that tests whether two films in a list of films can exactly
fill the duration of a flight.
2020-02-21 11:30:01 +00:00
William Carroll
6895b8b1ef Track which Paul Graham essays I've read and haven't read
As I mention at the top of the org file, I cannot rely on my web browser
informing me which of these essays I've read; it only shows me which of the
links I've clicked.
2020-02-21 09:38:34 +00:00
William Carroll
1fbc80359b Support ssh/{sudo-buffer,cd-home}
- Support command to open a dired buffer with wpcarro's $HOME directory for any
  host defined in ssh/hosts.
- Support opening the current buffer with sudo privileges.
2020-02-20 23:18:59 +00:00
William Carroll
79013316a6 Support installer.nix
The command...
nix-build -A config.system.build.isoImage -I nixos-config=installer.nix nixos
...creates an .iso file in the ./result directory. You can then copy this onto a
USB and use it a custom installer...
cp ./result/iso/*-linux.iso /dev/sda

I needed an installer that used a version of the Linux kernel higher than the
one distributed on NixOS's website: 4.19.? -> 5.4.20+. My Acer laptop needed a
version of the kernel that supported its network controller: Intel 3168NGW.

TODO(wpcarro): Pin the nixpkgs git commit SHA inside of installer.nix.
2020-02-20 19:51:51 +00:00
William Carroll
01f0ebfa32 Support basic nixos/configuration.nix
I'm attempting to configure an old Acer laptop that I bought at a used
electronics store in Shepherd's Bush (~100GBP) as my server. I'd like to install
NixOS on it. The configuration.nix herein defines a starting point for the
configuration for that machine. It isn't currently working.

Troubleshooting and solutions forthcoming...
2020-02-20 19:49:15 +00:00
William Carroll
66c38f8656 Solve InterviewCake's cafe-order-checker problem
Write a predicate that tests if a given list of integers, zs, is a possible
interleaving of two other lists, xs and ys.
2020-02-20 15:20:58 +00:00
William Carroll
737bdd0a23 Solve InterviewCake's merge sorted arrays question
Write a function merging two sorted arrays into one sorted array.
2020-02-19 16:02:38 +00:00
William Carroll
00e3526d9a Support SSH config for acer machine
I'd like to setup a NixOS machine that runs in my flat to host my blog and other
projects. For now it's a slow Acer running Manjaro Linux. I'm hoping that I can
install NixOS on it remotely over SSH. But first! SSH access...

I setup port forwarding from my router to this machine for:
- HTTP
- HTTPS
- SSH
2020-02-19 15:01:42 +00:00
William Carroll
ca6bd29ed8 Solve bonus part of reverse-words
InterviewCake asks "How would you handle punctuation?". Without precise specs
about what that entails, I'm supporting sentences ending with punctuation.
2020-02-19 15:01:42 +00:00
William Carroll
acf1b8c4f0 Solve InterviewCake's reverse-words
Wrote a function to reverse the words in a list of characters. A word is a
space-delimited strings of characters.

The trick here is to first reverse the entire string and then reverse each word
individually.
2020-02-19 15:01:42 +00:00