When I run `nix-env -f '<briefcase>' -iA emacs`, Nix builds a derivation of
wpcarros-emacs using the path to the Emacs derivation. This doesn't work well on
glinux and causes strange behavior. For instance, Chrome crashes when it tries
to browse for files. Building with `nix-env -iA emacs.glinux` fixes this and
other problems.
Miscellaneous other changes:
- Remove unnecessary fix-point recursion
- Drop support for unused dottime.el
- Remove unused overrideEmacs
- Remove unused withLocalConfig
- Support emacs.glinux and emacs.nixos alternative derivations
TL;DR:
- Prune unused themes
- Prefer "JetBrainsMono" font for all themes
- Remove TODOs that I've either supported or that I'm uninterested in supporting
I'm working off of my laptop but I'm using my 4k monitor. The expression that
sets `fonts/size` could be more sophisticated and detect this, but for now, I'm
just bumping up the size.
When I first switched to EXWM, I wrote a lot of Elisp. I think I was mostly
excited about having a monorepo and, as I had a backlog of ideas that I wanted
to implement, I ended up writing many halfly baked ideas in Elisp. These are
mostly sketches.
I've been trying to read 15 minutes in the mornings. I also recently purchased
some house plants that I have been watering daily before I do my yoga routine.
I'm writing a function that returns the total number of ways a cashier can make
change given the `amount` of change that the customer needs and an array of
`coins` from which to create the change.
My solution conceptually works but it actually does not return the results I am
expecting because I cannot create a Set of Map<A, B> in JavaScript. I'm also
somewhat sure that InterviewCake is expecting a less computationally expensive
answer.
While the "Dynamic programming and recursion" section hosts this problem, the
optimal solution does not use recursion. Many cite the Fibonacci problem as a
quintessential dynamic programming question. I assume these people expect an
answer like:
```python
def fib(n):
cache = {0: 0, 1: 1}
def do_fib(n):
if n in cache:
return cache[n]
else:
cache[n - 1] = do_fib(n - 1)
cache[n - 2] = do_fib(n - 2)
return cache[n - 1] + cache[n - 2]
return do_fib(n)
```
The cache turns the runtime of the classic Fibonacci solution...
```python
def fib(n):
if n in {0, 1}:
return n
return fib(n - 1) + fib(n - 2)
```
... from O(2^n) to a O(n). But both the cache itself and the additional stacks
that the runtime allocates for each recursive call create an O(n) space
complexity.
InterviewCake wants the answer to be solved in O(n) time with O(1)
space. To achieve this, instead of solving fib(n) from the top-down, we solve it
from the bottom-up.
I found this problem to be satisfying to solve.
While the idea of managing the hosts at a per-user level appeals much more to me
that running this as root and managing /etc/hosts, I haven't been able to get it
to work.
TL;DR:
- Write FromJSON instances to decode rules.json file
- Prefer Text to String and use the OverloadedStrings language extension
- Read /etc/hosts and append the serialized rules.json to the end
Notes:
- I can remove some of the FromJSON instances and use GHC Generics to define
them for me.
TODO:
- Define the systemd timer unit for this to run
- Ensure script can run with root privileges
1. I should be using NixOS/nixpkgs-channels instead of NixOS/nixpkgs
2. Instead of refactoring everything, I'm supporting <unstable> and pointing it
to NixOS/nixpkgs-channels
I needed <unstable> to get a more recent version of the Data.Time Haskell
package.
I'd like to ensure that my /etc/hosts file blocks websites at certains times. I
use this to allow / disallow websites at various times of the day.
TODO:
- Add project README
- Add tests
- Publish
- Create a Nix derivation
- Run as a systemd timer unit
- Figure out if I can run this as a user rather than root
I think it might be a good idea to version control my habits, so that I can
audit them as they change.
I'm publishing these on my website, so that I can refer to them wherever I had
internet.
Problem:
prettier-js waits for rjsx-mode. rjsx-mode only runs on .js files. As such,
the hook that installs prettier-js-mode for *all* of my frontend hooks, which
includes more than just js files, does not install until a javascript file is
opened.
Solution:
Do not conditionally load prettier-js.
Bonus:
Remove the .js mode from rjsx.
briefcase's top-level .gitignore ignores node_modules, so I never noticed that
it was missing from my boilerplate .gitignore. I don't *really* need to add it
to that .gitignore, but if I want to cleanly eject directories from this
monorepo, it makes sense to keep the .gitignore files local to each project.
Problem:
Prettier was not running when I saved Emacs buffers.
Why?
- prettier-js-mode needs needs node; lorri exposes node to direnv; direnv
exposes node to Emacs; lorri was not working as expected.
Solution:
Now that I'm using nix-buffer, I can properly expose node (and other
dependencies) to my Emacs buffers. Now Prettier is working.
Commentary:
Since prettier hadn't worked for so long, I stopped thinking about it. As such,
I did not include it as a dependency in boilerplate/typescript. I added it
now. I retroactively ran prettier across a few of my frontend projects to unify
the code styling.
I may need to run...
```shell
$ cd ~/briefcase
$ nix-shell
$ npx prettier --list-different "**/*.{js,ts,jsx,tsx,html,css,json}"
```
...to see which files I should have formatted.
Lorri does not cleanly integrate with my corporate device, which cannot run
NixOS. To expose dependencies to Emacs buffers, I will use nix-buffer.el, which
reads its values from dir-locals.nix. To easily expose dependencies from my
existing shell.nix files into dir-locals.nix, I wrote a Nix utility function.
Write a function to find a duplicate item in a list of numbers. The values are
in the range [1, n]; the length of the list is n + 1. The solution should run in
linear time and consume constant space.
The solution is to construct a graph from the list. Each graph will have a cycle
where the last element in the cycle is a duplicate value.
See the solution for specific techniques on how to compute the length the cycle
without infinitely looping.
By default Parcel prefixes output paths with /. So when Chrome loads
wpcarro.dev/goals it attempts to get the CSS and JS and other assets from
wpcarro.dev/ instead of wpcarro.dev/goals/. Using the --public-url ./ option
makes Parcel output relative paths, which should work better for my needs.
After deploying the version of this application that built everything in the
browser, which originally was the impetus for the entire project, I learned that
the babel in-browser transformer won't work. I'm not sure why, but I need to
move on from this project and do other work.
I ported the code to my boilerplate/typescript, which works. Wahoo!