Commit graph

15150 commits

Author SHA1 Message Date
Vincent Ambo
b586a04a0a feat(ops/nixos): Add NixOS module for running tailscale
This uses the "legacy" tailscale Linux client, but built from source
as per the previous commits.
2020-02-11 00:53:09 +00:00
Vincent Ambo
78b82c82a2 fix(third_party/tailscale): Add patch to make taillogin work 2020-02-11 00:43:55 +00:00
Vincent Ambo
77085f5876 chore(ops/nixos/nugget): Install tailscale on nugget 2020-02-11 00:09:34 +00:00
Vincent Ambo
9b37bad180 fix(third_party/tailscale): Add default relaynode acl.json to output 2020-02-11 00:09:34 +00:00
Vincent Ambo
04ffc5e66f fix(third_party/tailscale): Build all sub-packages
At the moment it seems like all of them are still required - things
are in flux!
2020-02-10 23:39:38 +00:00
William Carroll
61be808a92 Preferring to start wpcarros-emacs with dbus-launch
When I ran `pass show some/password`, gpg, which uses pinentry would start its
ncurses password prompt. For many this wouldn't be a problem but my current
vterm version cannot send the <return> key to ncurses, so once that prompt
appears, I cannot get rid of it without C-c and killing the shell. For a day or
more I just opened suffered through this.

Today I dug more into the issue and when I ran `pinentry --version` it warned
that it couldn't connect to DBUS. After searching for more information on this,
people with similar issues recommended starting their window managers with
`dbus-launch`. I previously started Emacs with `dbus-launch`, but only because
some i3 documentation told me to do so and I just copied them. Then I switched
to EXWM and copied that pattern over. A friend of mine uses EXWM and starts his
without calling `dbus-launch` but `exec emacs`. I mirrored this thinking that I
no longer needed `dbus-launch`. What I didn't know, however, was that this
friend was using a Nix-built Emacs (like me) except that his wrapped a native
Emacs installation while mine doesn't. His natively wrapped Emacs installation
has the proper variables set to interact with dbus and other important Linuxy
things that I don't fully understand. Since I'm using a Nix-built Emacs, some of
my variables are unset or set to different values than programs expect. This is
why when I try and start `gnome-terminal` or `terminator`, they refuse to start
and warn about many unset or incorrectly variables and not being able to bind to
sockets, etc.

This change reverts back to using `dbus-launch` until I have a better
understanding of Linux, Nix, etc.
2020-02-10 23:24:38 +00:00
William Carroll
e223adfec5 Begin work on YNAB client
After reading these docs
https://api.youneedabudget.com/v1#/Transactions/createTransaction I successfully
made a request to post a transaction to my YNAB account. Hastily created a
client.go that doesn't contain much at the moment.
2020-02-10 23:24:33 +00:00
Vincent Ambo
9e38e02c46 feat(third_party): Add package for tailscale
Adds a package for the now-opensourced tailscale client tailscale
client.
2020-02-10 22:16:41 +00:00
Abseil Team
bf78e97730 Export of internal Abseil changes
--
803abc2dcad8b2354c988e9bf58dac4a17683832 by Gennadiy Rozental <rogeeff@google.com>:

Avoid warning when RTTI is not enabled.

PiperOrigin-RevId: 294247546

--
5a7b0b4d07d1d6e56fbb0b0ffbf4f8fcab772dbf by Derek Mauro <dmauro@google.com>:

Add a public Abseil FAQ

PiperOrigin-RevId: 294226960

--
6945c4a6df7d7679711fea31aacf4fba6ac7baa1 by Gennadiy Rozental <rogeeff@google.com>:

Re-enable type mismatch check, which works in all the cases including shared libraries.

We will use RTTI in case when our hand written approximation of it reports a type mismatch. This way we can ensure that if a flag is defined in one shared object and referenced in another we do not report spurious errors.

PiperOrigin-RevId: 293905563
GitOrigin-RevId: 803abc2dcad8b2354c988e9bf58dac4a17683832
Change-Id: I1a23776d227ed2734c2e7183323786b7a95c3cc7
2020-02-10 13:55:42 -05:00
William Carroll
2e719d1174 Sort items in travel_hitlist
Grouping entries by country and sorting according to Done -> Todo.

I should consider sorting the country groups alphabetically by the country name
and then each entry alphabetically by its city name.

Right now, however, this isn't a priority.
2020-02-10 11:57:18 +00:00
William Carroll
b8700d4fce Add Turkish cities to wish list
I would like to see Istanbul and Ankara one day.
2020-02-10 11:56:57 +00:00
William Carroll
d6fcbb2d85 Add Grenoble and Lyons
In 2013, I lived in Grenoble with a host family. During that time, I visited
Lyons, as well as a few other locations that aren't tracked by this document at
the time of this writing.
2020-02-10 11:56:07 +00:00
William Carroll
29a0af7fef Lint the document
Removing a trailing comma from Dubrovnik, Croatia.
2020-02-10 11:55:24 +00:00
William Carroll
20e2624203 Adding a few cities that I visited in 2019
I spent two weeks on the Spanish islands of Ibiza and Formentera over the
summer.

I went to Hamburg twice to visit Mimi's family - once in the summer; once for
Christmas.

In the Fall, I went to Bordeaux with Mimi where we stayed at a charming Airbnb.

I spent New Years Eve in Amsterdam with Matty, Ryan, and Conor.

I may be missing a few other places that I visited in 2019; it was an active
year.
2020-02-10 11:55:14 +00:00
William Carroll
7333dfe47b Add 'travel_hitlist/' from commit 'a97002bb21425c4d36335e9d70a1ec8bad6b51f2'
git-subtree-dir: travel_hitlist
git-subtree-mainline: 3fa8276816
git-subtree-split: a97002bb21
2020-02-10 11:45:29 +00:00
William Carroll
3fa8276816 Support C-k for upward movement in ivy-switch-buffer-map
Without these KBDs, C-k kills buffers. As an evil-mode user, I expect C-k to
move upwards. As such, adding the `ivy-switch-buffer-map` to my existing ivy
KBDs that handle a similar use-case.

Note: I'm unsure why the KBDs in evil-collection didn't cover this.
2020-02-10 11:36:09 +00:00
William Carroll
52831c7136 Disable ido-mode
For awhile I had a mixture of ivy and ido. Disabling ido and preferring ivy for
everything.
2020-02-10 11:35:27 +00:00
William Carroll
9dd9bce494 Add ts.el to emacs/default.nix
I ran `M-x package-autoremove` that deleted `ts.el`, which wasn't listed in my
default.nix. Adding it...
2020-02-10 11:34:19 +00:00
William Carroll
bd88f40224 Refactor token server initialization
- Move state "gen server" to the top of main/0
- Initialize it as empty
- Ensure that persistTokens/2 is called whenever the state changes
- Support setState/2 (similar in spirit to getState/0)
2020-02-10 10:06:40 +00:00
William Carroll
d35eb5c8f9 Debug os.Signal handling
Problem:

When SIGINT signals we're sent to the token server, it would shut down without
completing the shutdown procedure. The shutdown procedure would persist the
application state (i.e. access and refresh tokens).

This is problematic for the following sequence of events:
t0. Access and refresh tokens retrieved from kv.json and used as app state.
t1. Tokens are refreshed but not persisted. (I'm still unsure how this
    happens). Remember that this means the previous access and refresh tokens
    from t0 are now invalid.
t2. User sends a SIGINT.
t3. Token server shuts down.
t4. Token server is restarted, kv.json is used as the app state even though its
    tokens are now invalid.
t5. Tokens are attempted to refresh, Monzo API rejects the tokens because
    they're invalid.

Now we need to provide the token server with valid access and refresh tokens
otherwise we will repeat the loop described above. This means going through the
client authorization flow again or copying and pasting the tokens logged from
the token server into kv.json. Either scenario is more manual than I'd prefer.

Solution:

Use a buffered channel to receive the os.Signal. I got this idea after reading
these docs: https://golang.org/pkg/os/signal/#Notify and I debugged this issue
shortly thereafter.

I also rearranged the order of operations in main/0 to ensure that
handleInterrupts/0, which registers the event listeners, occurs before
scheduleTokenRefresh/2 is called. This allows the token server to gracefully
shutdown even if it's in the middle of the scheduleTokenRefresh/2 call.
2020-02-10 10:06:40 +00:00
William Carroll
323aa41e0f Sketch Monzo client
None of this code is functional at the moment. I'm just writing some ideas of
how I'd like to work.
2020-02-10 10:06:40 +00:00
William Carroll
c83594fb5a Consume auth library
Consume the newly relocated auth package.

Additionally:
- Debugged error where JSON was properly decoding but not populating the
  refreshTokenResponse struct, so my application was signaling false positive
  messages about token refresh events.
- Logging more often and more data to help my troubleshooting
- Refreshing tokens as soon as the app starts just to be safe
- Clean up the code in general
2020-02-10 10:06:40 +00:00
William Carroll
44dca4a188 Move authorization logic into separate package
Relocated the logic for authorizing clients into a separate package that the
tokens server now depends on. Moving this helped me separate concerns. I removed
a few top-level variables and tried to write more pure versions of the
authorization functions to avoid leaking Monzo-specific details.
2020-02-10 10:06:40 +00:00
William Carroll
4ea5a1bffa Support utils.Debug{Request,Response}
Exposing functions to print HTTP request and response structs.
2020-02-10 10:06:40 +00:00
William Carroll
81271498b6 Ignore kv.json
I'm writing sensitive data here, so I'd like to ignore it instead of encrypting
it and publishing it. Perhaps later on, I can extend the key-value store to
handle encryption and decryption but that feels like overkill for now.
2020-02-10 10:06:40 +00:00
William Carroll
aba0cd7b9d Gracefully shutdown server
Listen for SIGINT and SIGTERM signals and write the current state to the
key-value store before shutting down.
2020-02-10 10:06:40 +00:00
William Carroll
0f914d8aa0 Read tokens from store when server starts
Attempting to read the persisted tokens from the key-value store when the server
begins. The server currently fails when those values are empty.

TODO
- Consider adding logic for knowing if the cached tokens are expired and prompt
  the user to reauthorize the client using a web browser.
2020-02-10 10:06:40 +00:00
William Carroll
248c7a24c6 Nixify tokens.go
- Package tokens.go with Nix
- Add monzo_ynab.{job,tokens} to shell.nix
2020-02-10 10:06:40 +00:00
William Carroll
a5ef9b11a6 Remove dead code
Removing a half-baked Monzo HTTP client. A more fully supported and differently
designed one is forthcoming.
2020-02-10 10:06:40 +00:00
William Carroll
64654d1d6d Create gopkgs directory for golang libs
- Created a gopkgs directory and registered it with default.nix's readTree
- Moved monzo_ynab/utils -> gopkgs
- Consumed utils.go in main.go
- Renamed monzo_ynab -> job
2020-02-10 10:06:40 +00:00
William Carroll
ec4c8472ca Support simple key-value store
In order to persist my access and refresh tokens, I needed a store. I think
using a database like SQLite may have been fine for this but was heavier weight
than what I wanted.

I decided to write a simple key-value store when the state is encoded and JSON
in a file called kv.json.

TODO:
- Support field nesting
- Support better error handling
- Support parameterizing the store path (i.e. ./kv.json)
2020-02-10 10:06:40 +00:00
William Carroll
7f8a5176ce Create server for managing Monzo credentials
I created a server to manage my access and refresh tokens. This server exposes a
larger API than it needs to at the moment, but that should change. The goal is
to expose a GET at /token to retrieve a valid access token. The server should
take care of refreshing tokens before they expire and getting entirely new
tokens, should they become so stale that I need to re-authorize my application.

A lot of my development of this project has been clumsy. I'm new to Go; I didn't
understand OAuth2.0; I'm learning concurrent programming (outside of the context
of comfortable Elixir/Erlang).

My habits for writing programs in compiled languages feels amateurish. I find
myself dropping log.Println's all over the source code when I should be using
proper debugging tools like Delve and properly logging with things like
httputil.Dump{Request,Response}.

The application right now is in a transitional state. There is still plenty of
code in main.go that belongs in tokens.go. For instance, the client
authorization code belongs in the tokens server.

Another question I haven't answered is where is the monzo client that I can use
to make function calls like `monzo.Transactions` or `monzo.Accounts`?

The benefit of having a tokens server is that it allows me to maintain state of
the tokens while I'm developing. This way, I can stop and start main.go without
disturbing the state of the access tokens. Of course this isn't the primary
benefit, which is to abstract over the OAuth details and expose an API
that gives me an access token whenever I request one.

The first benefit that I listed could and perhaps should be solved by
introducing some simple persistence. I'd like to write the access tokens to disk
when I shutdown the tokens server and read them from disk when I start the
tokens server. This will come. I could have done this before introducing the
tokens server, and it would have saved me a few hours I think.

Where has my time gone? Mostly I've been re-authorizing my client
unnecessarily. This process is expensive because it opens a web browser, asks me
to enter my email address, sends me an email, I then click the link in that
email. Overall this takes maybe 1-3 minutes in total. Before my tokens server
existed, however, I was doing this about 10-20 times per hour. It's a little
disappointing that I didn't rectify this earlier. I'd like to remain vigilant
and avoid making similar workflow mistakes as I move ahead.
2020-02-10 10:06:40 +00:00
William Carroll
e3ee0734e5 Document more API requests
I'm continuing to use restclient-mode, and I'm enjoying it. Updating the scratch
file with more endpoints and credentials.
2020-02-10 10:06:40 +00:00
William Carroll
2d3428c809 Practice concurrency in golang
Uploading some snippets I created to help me better understand concurrency in
general and specifically concurrency in golang.
2020-02-10 10:06:40 +00:00
William Carroll
2af05f698c Support vterm-mgt.el
I enjoyed using term-switcher so much that I ended up adopting vterm as my
primary terminal. After reaching for vterm as often as I did, I realized that I
would enjoy supporting cycling through instances, creating new instances,
deleting existing instances, renaming instances. Thus spawned vterm-mgt.el.

I'm particularly excited about the KBD to toggle between vterm instances and
source code buffers.
2020-02-10 10:06:40 +00:00
William Carroll
8584059e7c Support cycle/{append,remove}
Supporting these functions was a little tricky. For example, how should we
handle calling cycle/remove on the item that is currently focused? After
attempting to be clever, I decided to just set the value to nil and let the
consumer decide what is best for them. I can always support a more opinionated
version that fallsback to previous-index if previous-index is set. But until I
have a better idea of how I'm going to consume this, I think nil is the best
option.
2020-02-10 10:06:33 +00:00
Vincent Ambo
042df0b523 docs(web/blog): Add some TODO entries for the draft 2020-02-10 01:34:54 +00:00
Vincent Ambo
541306f1bd docs(web/blog): Rewrite some style issues in the Emacs post 2020-02-10 01:24:34 +00:00
Vincent Ambo
9f75c91adc feat(web/blog): Add draft blog post on Emacs
This post is a draft, i.e. not linked from the index. It's not a
secret, but if you do find it through this commit before its
publication please don't share it too widely yet.
2020-02-10 00:29:51 +00:00
Vincent Ambo
b56b3db2f4 style(web/homepage): Highlight <kbd> elements like buttons 2020-02-10 00:08:53 +00:00
Vincent Ambo
9ed53f4201 fix(web/homepage): Make .uncoloured-link work again 2020-02-10 00:08:43 +00:00
Vincent Ambo
1e770f5d88 feat(web/blog): Add support for draft & unlisted posts
Posts with either `draft = true;` or `listed = false;` will no longer
be included in index generation and will have a warning callout
inserted at the top of the page urging people not to share the links
to them.
2020-02-09 21:44:48 +00:00
Vincent Ambo
0bc2f8995e style(web/blog): Minor formatting fixes in Watchguard post 2020-02-09 21:24:53 +00:00
Vincent Ambo
30e8f59d02 style(web/homepage): Overflow long code lines into scroll bars 2020-02-09 21:24:31 +00:00
Vincent Ambo
bd2d96d053 chore(web/blog): Move Watchguard images into static assets
Rather than sending user data to imgur ... lets get rid of all the
external stuff!
2020-02-09 21:16:03 +00:00
Vincent Ambo
de9f51de82 chore(web/blog): Remove duplicate CSS file 2020-02-09 21:06:37 +00:00
Vincent Ambo
386692d39d chore(web/homepage): Configure caching for fonts & images 2020-02-09 21:05:03 +00:00
Vincent Ambo
74a78de081 style(web/homepage): Unify page max-width at 800px 2020-02-09 20:52:14 +00:00
Vincent Ambo
e70b88b3c2 fix(third_party/cgit): Make vpath & repo available for about cmd
This change makes cgit pass the current repo and vpath inside of the
repo on to the about cmd, which makes it possible for it to correctly
render `tree`, `log` and other links to the same vpath.
2020-02-09 17:01:21 +00:00
Vincent Ambo
fb1b4b9bd3 style(web/homepage): Use somewhat livelier colours
The previous ones looked kind of dull. These are from my gruber-darker
rainbow-delimiters theme.
2020-02-09 13:39:12 +00:00