Commit graph

1494 commits

Author SHA1 Message Date
William Carroll
c8330adfcb Solve "Move Zeroes to End"
Write a function to modify an array of integers in-place such that all of the
zeroes in the array are at the end, and the order of the other integers is not
changed.
2020-11-15 13:51:46 +00:00
William Carroll
09cd819a70 Include re-roll strategy for rand7
After seeing the solution that my book advocated, I implemented it using
recursion.
2020-11-14 17:36:04 +00:00
William Carroll
5820f6f459 Solve rand7
Write a random number generator for [0,7) using only a random number generator
for [0,5). Ensure the results are uniformly distributed.
2020-11-14 17:26:00 +00:00
William Carroll
a0e9e2b310 Solve unsorted-substring a second time
This solution operates in O(n) time instead of O(n*log(n)) time, which
surprisingly isn't *that* big of a difference...

Consider a size of n of 10M...
  1) ~10s
  2) ~0.5s

So, yes, the O(n*log(n)) will take 100x longer to complete, but for an enormous
input size of 10M elements, it can still complete in under a minute. The
difference between that and the second, faster, algorithm, is just 9s.
2020-11-14 15:28:23 +00:00
William Carroll
48fde5f278 Solve unsorted-substring
Write a function that returns the indices demarcating a substring, which if
sorted, would make the entire array sorted.
2020-11-14 15:08:25 +00:00
William Carroll
47c5c6ac05 Partially implement a Heap
Defining the insert (or "siftup") function described in the "Programming Pearls"
book.
2020-11-14 14:08:58 +00:00
William Carroll
c841527f61 Write encoded XML parser and pretty-printer
Write a function that reads a string of compressed XML and outputs the
decompressed version.

Note to self: Now that I'm growing more comfortable writing parsers, I'd like to
become equally comfortable writing pretty-printers.
2020-11-14 14:00:00 +00:00
William Carroll
bfd2180e6b Solve tic-tac-toe checker
Write a function that verifies whether or not a tic-tac-toe board is valid.
2020-11-13 17:45:07 +00:00
William Carroll
1b3f1b99f5 Solve box-stacking problem
Write a function to compute the highest stack of boxes that can be created from
a list of boxes.
2020-11-13 16:57:47 +00:00
William Carroll
7672049e1c Solve N queens
After a five year hiatus, I decided to attempt to solve the famous N queens
problem again. This time, instead of modeling the chess board using a
`[[Bool]]`, I'm using `[Integer]` where the `Integer` indicates which column has
a queen. This is a bit lighter in RAM.
2020-11-13 16:56:02 +00:00
William Carroll
14f6169fcf Document subset of BNF for regex engine
Adding some documentation for my future self.
2020-11-13 16:55:39 +00:00
William Carroll
aa66d9b83d Add coding exercises for Facebook interviews
Add attempts at solving coding problems to Briefcase.
2020-11-12 14:37:29 +00:00
William Carroll
d2d772e43e Sort Emacs deps
Group Emacs dependencies like ivy together.
2020-11-12 11:20:27 +00:00
William Carroll
6d26f5b987 Mark additional movies as watched
Making progress...
2020-11-12 11:19:59 +00:00
William Carroll
69b6bda01b Style habit screen to accommodate footer
Add spacing to the bottom to make space for the footer.
2020-11-12 11:19:30 +00:00
William Carroll
2290aac2a8 Tweak styles
Add spacing to help the app breathe.
2020-10-11 16:47:31 +01:00
William Carroll
767fed75c3 Support multiple HabitTypes
I could have and should have broken this change into smaller pieces, but when I
came up for air, I had changed too much, and most of the changes are
intermingled. Oh well... this is an exciting change!

Include habits for:
- Morning
- Evening
- Payday (the 25th)
- First of the Month
- First of the Year

Since the Morning and Evening routines might be a bit noisy, I'm excluding them
from the output using a flag, `include{Morning,Evening}`, which I support in the
UI to toggle their visibility.

I made *much* more progress on this app that I expected to today, and I *think*
-- short of supporting a database and a server -- I'm close to
being *completely* finished.

Wahoo!
2020-10-11 16:40:10 +01:00
William Carroll
abf1875934 Support Msg to clear all completed tasks
Add a simple button to clear all completed tasks.
2020-10-11 15:39:01 +01:00
William Carroll
79cf42abd5 Render time remaining in UI
Show the number of minutes remaining before completing all of the tasks.
2020-10-11 15:17:20 +01:00
William Carroll
5684608fed Move tailwind function into Utils module
Instead of accepting `List (String, Int)`, accept `List Strategy` where
`Strategy` defines whether or not the string of selectors should be applied to
the element.

I'm also renaming it `class` so I can just use `Utils.class`; `tailwind` has
little to do with the function itself.
2020-10-11 14:59:42 +01:00
William Carroll
1c8a8f5d2c Expand Habit type
Include:

- habitType: Daily, Weekly, Yearly... what's the trigger?
- minutesDuration: Estimation of how long it'll take to complete
2020-10-11 14:58:49 +01:00
William Carroll
ea0cd01e18 Watch a few movies
Here's what I watched:
- Ran
- Children of Heaven
- Lawrence of Arabia

Only 78/250 movies to go!
2020-10-11 10:28:46 +01:00
William Carroll
05d52e403c Tweak styles
- Change header to blue
- Change habit to gray when completed
- Prefer app font for footer instead of monospaced font
2020-10-11 10:24:11 +01:00
William Carroll
0a15ea7366 Create UI module for common components
Create UI.elm to house components like `button`, which is a simple HTML button
with `focus:outline-none` applied as a `class`, which is an accessibility
feature that I don't need for this touch-screen application.

I like this pattern more than my more opinionated patterns for UI modules in Elm
where I'd define all of the arguments as a record type (i.e. kwargs).
2020-10-11 10:15:03 +01:00
William Carroll
106457de4b Prefer handwritten font
Use the Google Fonts API to fetch a handwritten font, which gives the app a
modicum of personality. There are more "best practices" ways to do this, such
as:

- Download the font once, and include it in the bundle
- Extend the Tailwind configure to recognize the font
- Ditch the inline <style> block

But I don't need the performance benefits that the first bullet provides. And
the second two bullets are more relevant for a larger application with more than
one font. So I think in this case, the easiest solution is best.

Also:
- Use `container` and `mx-auto` to constrain content for wide screens
2020-10-11 10:09:15 +01:00
William Carroll
19fbdad1c0 Support viewing different days
Allow users to browse the habits of the other days of the week.
2020-10-10 18:20:24 +01:00
William Carroll
487232d1aa Ensure weekday is updated
This ensures us that our view is consistent within ~1 minute of reality.
2020-10-10 17:34:14 +01:00
William Carroll
7d425de48d Tweak styles
- Increase font size for header
- Prefer a bulleted list
- Reduce horizontal padding
2020-10-10 17:31:34 +01:00
William Carroll
bfbe7dc988 Add a footer
With personal information and information about the project's stack.
2020-10-10 17:31:00 +01:00
William Carroll
df8e45681d Remove Nap from Saturday; prefer Yin Yoga
Since Warm Yin Yoga is at 15:00, it's difficult to attend that *and* nap.
2020-10-10 17:30:22 +01:00
William Carroll
9d331f3077 Begin working on Habit Screens project
Created a small MVP for digitizing my weekly habits. Much more to come.

Lots of things happening:

- Copied the boilerplate to get started
- Added a brief project-level README
- Outlined my ambitions in design.md

See README and design.md for more context on this project.
2020-10-10 17:04:24 +01:00
William Carroll
02ce74eada Add elm-format-on-save-mode to elm-mode-hook
Instead of calling this manually.
2020-10-10 17:03:08 +01:00
William Carroll
fbd5e7fb18 Remove evil dependency from window-manager.el
When `keybindings` requires `window-manager`, the `evil-want-integration`
warning emerges. If I remove the `evil` dependency from `window-manager`, it
resolves the issue.
2020-10-04 18:27:38 +01:00
William Carroll
3ba4112849 Enable spell-checking during magit commit
This is another (overdue) change about which I'm quite excited. Add
spell-checking to my Git commit buffers. :)
2020-10-04 16:25:15 +01:00
William Carroll
48d9a70253 Extend "l" -> "L" KBD remapping for magit-{log,revision}-mode-map
Thankfully `general` made this change super easy and maintainable to support.
2020-10-04 16:23:25 +01:00
William Carroll
f3ee628a4c Support display-arrangement macro
I was tired of using `arandr` to manually configure my monitor positions, so I
encoded the settings in Elisp in the `display.el` module.

TL;DR:
- Drop support for `position` kwarg in `display-register` macro
- Support `coords` kwarg in `display-register`.
- `defconst` the `xrandr` arguments and command in `display-register`.
- Define `display-arrangement` macro that consumes the `xrandr` arguments that
  `display-register` defines to create an interactive function,
  `display-arrange-<NAME>`, which -- when invoked -- runs one xrandr command to
  configure a display "arrangement".
2020-10-04 16:20:16 +01:00
William Carroll
4187e888c8 Disable company-mode during git commits
Why didn't I configure this earlier? For years, my workflow involved checking a
buffer's major mode and then extending that major-mode's hook. Confusingly (to
me), the `major-mode` for `COMMIT_EDITMSG` is `text-mode`, and I didn't want to
disable `company-mode` for *all* `text-mode` buffers, which is what the
following would have done:

```elisp
(add-hook 'text-mode-hook (lambda () (company-mode -1))
```

Thankfully I recently invested some time into learning more about Emacs's
offline help system, `Info-mode`, so -- putting that knowledge to work -- I ran
`info-apropos` and searched "magit commit". After ~5 minutes of reading I knew
the recommended way of configuring this was to modify `git-commit-setup-hook`.

How validating!
2020-10-04 14:57:23 +01:00
William Carroll
6df182d45e Move KBDs from window-manager.el to keybindings.el
Assuming (hoping) that this doesn't break anything.
2020-10-04 13:57:01 +01:00
William Carroll
6eac1de187 Debug Emacs initialization
Since "Briefcase" doesn't exist, `window-manager--switch` fails and so does
`exwm-init-hook`. It'd be nice to catch these errors earlier...
2020-10-04 13:54:57 +01:00
William Carroll
562c82f3f2 Bind "g SPC" to #'Info-scroll-up
I'm using the "g <char>" pattern that evil-collection uses, which I think is
okay.
2020-10-03 18:15:32 +01:00
William Carroll
4cd552de28 Alter doom-acario-dark's font for comments
Thanks to my newly acquired `Info-mode` navigation skills, I quickly learned how
to alter fonts in Emacs!
2020-10-03 18:14:34 +01:00
William Carroll
a8704bb54d Define KBDs for ibuffer
I'd like to start using ibuffer more, so I'm making it a more hospitable place
by defining useful KBDs.
2020-10-03 14:51:04 +01:00
William Carroll
990b6278a8 Define KBDs for Info-mode
I took the Info-mode tutorial (finally) and I found some things from
evil-collection that I liked, other things that I didn't like.
2020-10-03 14:50:38 +01:00
William Carroll
4c809ebf59 Set ibuffer's default sort to major-mode
I find this a more intuitive default.
2020-10-03 14:50:10 +01:00
William Carroll
b4b929a55b Define window-manager-swap-workspaces
This is a wrapper around the existing `exwm-workspace-swap` except it's aware of
my `window-manager-workspace` struct.
2020-10-03 14:49:33 +01:00
William Carroll
869bcf3fc8 Define fn for outputting the current workspace's label
This is a useful helper fn, and hopefully something I'll support in my mode line
soon.
2020-10-03 14:49:02 +01:00
William Carroll
8137eed738 Rename workspaces
Prefer "Web Browsing" and "Coding".
2020-10-03 14:48:46 +01:00
William Carroll
174d676c93 Ensure "RET" follows links in Info-mode
Shouldn't this be handled by evil-collection?
2020-10-03 11:01:00 +01:00
William Carroll
0f160a8029 Ignore comments in output for grocery export
TL;DR:
- Ignore lines starting with "#"
- Tidy up the code
2020-10-03 11:00:11 +01:00
William Carroll
3b525e6d63 Mark a few movies as watched
- Spirited Away
- Modern Times
2020-10-03 11:00:05 +01:00