Today is my first day back in the office at Google (this time at MP2 in
Sunnyvale)! As such, I have a new desk, new monitors, so expect some changes to
my configuration until I stabilize everything.
`sudo systemctl suspend` wasn't working because it required a secure password
prompt to read the user's password for `sudo`. The recommended way to call
`shell-command` with a `sudo` command (from what I read online) is to set
`default-directory` to `/sudo::` before calling `shell-command`. This works just
fine, so I refactored the function, `window-manager-logout`.
This time, I'm excluding languages like CSS,HTML,Markdown,Org, which I think
makes the output a bit noisier than I'd like it to be.
TODO(wpcarro): Automate this process
Re-run `tokei --hidden --type=<comma-sep'd-langs> --sort code .` to update this
table.
Most of the errors at the moment are related to line-lengths exceeding my 80
character limit. While these are valid, the linter doesn't currently support
disabling these checks, which means that my Elisp code always fails this CI
step. This creates too much noise and conditions me to care less about CI
failures.
When the Elisp linter support this feature, I will gladly re-enable this step.
I changed the name of my Pipeline from briefcase -> post-receive, which broke
the URL for the badge.
This is easily fixed by visiting BuildKite's "Pipeline Settings" page.
To make things easier for testing, I setup the /verify endpoint as a GET, so
that I could email myself clickable URLs. With POST /verify, my options are:
- send email with an HTML button and form that POSTs to /verify
- email myself the curl instruction
I'm preferring the latter for now...
It's been awhile since I've updated this list, and I haven't stopped watching
movies. Adding movies like "The Help", "Three Colours: Red" (and the whole
trilogy for that matter), "The Elephant Man", and others. All worth watching.
Wahoo! I need to remember that the inorder traversal of a BST should be
sorted. This piece of trivia comes in handy for a variety of BST related
problems.
I also think being able to do a {pre,in,post}-order traversal recursively and
iteratively is a skill that I need to develop.
Valid Anagram
This one is a classic: `sorted(a) == sorted(b)`
Group Anagrams
Using product of prime numbers to create a key for anagrams is much faster than
sorting the characters in each word. It is also satisfyingly simple.
Encode and Decode Strings
My initial implementation was clumsy and prone to fail for edge-cases. A more
elegant solution is using something like:
```python
def encode(words):
return "".join("{}:{}".format(len(x), x) for x in words)
```
This is tricky because Python has variable-width integers, so relying on two's
complement to support the sum of negative numbers results in infinite
recursion. I know three ways to combat this:
1. Use Java.
2. Conditionally branch and handle either addition or subtraction accordingly.
3. Use a mask to enforce fixed-width integers in Python.
Looks like "Rotate Image" is the only Matrix problem that remains. It was nice
to learn more about "Backtracking" -- a term I often encounter -- while
attempting to solve "Word Search".
From my current understanding, it is like Brute Force but with
short-circuiting. It also seems quite similar to Depth First Search, and I'm
currently unaware of how DFS and Backtracking differ. I'm hoping to learn more
though.
I did these during my flight from LON->NYC without wifi. I managed to get both
correct on the first attempt although I did not find the *optimal* solution for
"Reorder List". IMO "Reorder List" is the best Linked List question I've seen
because it covers a few essential Linked List tricks.
Looks like I should prioritize the following topics:
- Dynamic Programming
- String
- Graph
Although I'm not sure how common DP questions are in interviews, DP is a useful
dragon to slay IMO.
TeamBlind.com hosts a curated list of DS&As questions from LeetCode.com that the
author claims appropriately samples the topics worth exploring. I'm creating an
offline list so that I can track my progress and work while I'm traveling.
At some point I should document or write a script for how I package Elm projects
with Nix to be deployed on my website. For now, I'm modeling everything after my
previous success LearnPianoChords.
Creating a simple HTTP RESTful API for exposing our `Server.semiprime`
function. It supports some help messages, primitive parsing and error handling,
and singular vs. batch processing of arguments.
For more sophisticated parsing and error-checking, I prefer to use Haskell's
Servant library.
- Clear the boilerplate that `mix` generated
- Consume `Math.factor` to test which inputs are semiprimes
- Cache all inputs that are semiprimes as soon as we discover that they are
- semiprimes
I considered a couple things related to the Cache:
- Could save space by storing all semiprime factors in a tree. This would make
the lookups more expensive. Also because the tree's depth would never exceed
two (because all semiprimes only have two factors), the tree would be quite
broad, and we may not be saving enough space for the trade to be worthwhile. I
might be wrong about that though.
- We could consider pre-computing all semiprimes when we start the app, but
without running some tests firsts, I'm not sure whether or not it's worth the
trouble.
Define a simple in-memory key-value store for our cache.
TL;DR:
- Define `Cache` as a simple state-keeping `Agent`
- Define `Sup`, which starts our Cache process
- Define `App`, which starts our Supervisor process
- Whitelist `App` in `mix.exs`, so that it starts after calling `iex -S mix`
In case I want to package this project with Nix. For now, it's useful to store
this at the project root because it help my Emacs's `project-find-file`
function.