Commit graph

1452 commits

Author SHA1 Message Date
William Carroll
5fd79ce0ff Support parsing second shifts
Parse inputs like -10s into 10 second shifts back in time.
2020-08-20 11:26:30 +01:00
William Carroll
81aa32fe71 Support POST /create-payment-intent
Interact with Stripe's payment_intents API endpoint.

I'm not committing the index.html that contains client-side code that interacts
with the /create-payment-intent endpoint, but it contains sensitive information,
so I'm omitting it for now.

TL;DR:
- Define POST /create-payment-intent endpoint
- Include envStripeAPIKey in Context record
- Define a top-level Stripe module for making API calls
- Define types and instances that align with Stripes request and response types
- Depend on the Req library: a higher-level library than http-client
2020-08-20 11:26:30 +01:00
William Carroll
de723c142b Prefer project.el to projectile
Today @tazjin told me about Emacs's built-in project.el library, which he
recommended that I extend to support monorepo-specific tooling. It worked like a
charm!

Now when I press "<leader>f", it will resolve to either the nearest file named
default.nix or directory name .git.
2020-08-13 18:05:45 +01:00
William Carroll
994a632ac3 Set Emacs current-project to ~/briefcase
I don't rely on this often, so it's best to leave it as the top-level directory
for briefcase.
2020-08-13 18:04:54 +01:00
William Carroll
a4caaba901 Document ghcExtensions argument
Missed documenting this the first time...
2020-08-13 18:04:33 +01:00
William Carroll
2da4b12266 Consume buildHaskell functions
Use the newly defined `buildHaskell` function for a few of my existing Haskell
projects. So far, it works as intended!
2020-08-12 16:28:39 +01:00
William Carroll
4ea55dd013 Support buildHaskell
Use Nix and Briefcase to easily create Haskell executables.

I'd eventually like to support something like: briefcase.buildHaskell.project
that let me define a few top-level values (e.g. ghcExtensions) and would give me
a ghci environment with the proper `.ghci` settings so that my development
environment mirrored my build environment... baby steps, though.
2020-08-12 16:26:17 +01:00
William Carroll
869a20f482 Define alias for cd-ing to ~/briefcase
Small but useful alias.
2020-08-12 14:24:24 +01:00
William Carroll
bba3f16c43 Prefer snake-shift instead of a row-by-row shift
Per the assignment's instructions, the `Shift n` operation should treat
the *entire keyboard* like a cycle and shift that. I was erroneously
treating *each row* like a cycle and shifting those one-by-one.

This change fixes that. In addition, it also:
- Updates README.md with expected inputs and outputs
- Updates test suite
- Adds `split` dependency to {default,shell}.nix
2020-08-12 12:03:35 +01:00
William Carroll
f11b91c985 Adds property tests to generically test keyboard transformations
Tests:
- HorizontalFlip
- VerticalFlip
- Shift n
2020-08-12 11:27:06 +01:00
William Carroll
f3ddd89302 Prefer literal, not computed, examples in the unit tests
TL:DR:
- Remove unused imports: Test.QuickCheck and Control.Exception
- Remove calls to `reverse` and `Utils.rotate` with their results
2020-08-12 11:07:37 +01:00
William Carroll
3d6130c7cf Provide more useful instructions for building this project
TL;DR:
- include a default.nix to allow users to build an named executable
- emphasize in the README that the user needs Nix to build this project
- pin nixpkgs to a specific commit and fetch it from GitHub
2020-08-12 10:28:04 +01:00
William Carroll
17e1764ef8 Generate coords function from existing qwerty keyboard
Per my take-home assignment's reviewer's comments, with which for the record I
agree, I should generate the character->coordinate table from my existing qwerty
keyboard definition.

The best part is: by doing this I found a bug: Notice how the original '0'
character was mapped to the Coordinate (0,0)... thus every subsequent digit
key (i.e. the first row) is off-by-one.
2020-08-12 09:46:36 +01:00
William Carroll
4ff1ea291c Drop support for ServantT transformer type for server
After burning a few hours wrestling with the type system, I decided to revert to
the simpler `Server API` type instead of the `ServantT` transformer type.

The problem is that I couldn't write a MonadError instance for `RIO Context`,
which is my `AppM` (i.e. application monad). Using `throwIO` in the server
handlers results in 500 errors, which is not what I wanted. I'm still pretty
fuzzy about what's happening; I now know that exception handling in Haskell is
pretty gnaryly. I may revisit this at a later time when my knowledge is more
extensive. For now: time to fry bigger fish.

An easier abstract is for me to pass `T.Context` into `server` as an argument,
which after all is what a Reader does.

TL;DR:
- Read server, client ports from .envrc
- Define a top-level Failure type (empty for now)
- Define a top-level Success type
- Define App as RIO Context (Either Failure Success)
2020-08-10 15:02:05 +01:00
William Carroll
f61ed25755 Prefer ServantT for server to consume App context
Long story -> short: I'd like to access my App monad from within my Servant
handlers.

While this code type-checks, I'm not sure it's working as intended. Needing to
change throwError to throwIO fails the "smell test". I expect to refactor this
code, but I'm calling it a night for now.
2020-08-09 23:15:12 +01:00
William Carroll
bbcd0bf27d Replace Prelude with RIO
I believe RIO stands for: "ReaderT <something-something> IO", which is a nod to
the top-level application data type:

```haskell
-- This is a simplification
newtype RIO env a = RIO { runRIO :: ReaderT env a () }
```

I read about RIO from an FP-Complete blog post a few months ago, and now I'm
excited to try it out for a real project. Bon voyage!
2020-08-09 22:17:19 +01:00
William Carroll
7d85ba559d Move Haskell-related shell.nix code into its own shell.nix
I'm getting tired of:

```shell
$ cd <project-root>
$ nix-shell
$ cd src/server
$ ghci Main.hs
```

Instead:

```shell
$ cd <project-root>/src/server
$ ghci Main.hs
```
2020-08-09 22:11:39 +01:00
William Carroll
26b7237aab Sketch database schema
Defining a few tables in init.sql to sketch a few records that I need to
persist.
2020-08-09 10:22:12 +01:00
William Carroll
9df2b49afd Initialize a default.nix for nix-build
As the previous commit mentions, I'm attempting to build and deploy this project
with `nix-shell` and `nix-build` instead of `cabal` and `stack`.

I'm in the Hamburg airport right now, and my internet connection isn't stable
enough to test this, so I'm committing it until I can more robustly test it.
2020-08-09 10:19:36 +01:00
William Carroll
119c8e9df9 Add common language extensions to .ghci
I'd like to see if I can avoid using `cabal` and `stack` and build and deploy
this application using `nix-shell` and `nix-build` only. Let's see how that
goes.
2020-08-09 10:18:46 +01:00
William Carroll
e8f35f0d10 Consume GoogleSignIn.validateJWT
TL;DR:
- Consume GoogleSignIn.validateJWT in the Handler for /verify
- Rename validation fn to validateJWT
- Prefer Text to String type
2020-08-08 17:57:11 +01:00
William Carroll
8a7a3b29a9 Add tests for "exp" field of the JWT
Assert that the exp field of the JWT is "fresh".
2020-08-08 14:47:39 +01:00
William Carroll
f1883b2790 Test that the JWT's iss field meets our expectations
The JWT should match "accounts.google.com" or "https://accounts.google.com". If
it doesn't, we produce a validation error.

TL;DR:
- Group all failed stringOrURI function calls as StringOrURIParseFailure errors
2020-08-08 14:08:11 +01:00
William Carroll
526728eb89 Test that an improperly encoded JWT returns a DecodeError
The subject of this commit message says it all.
2020-08-08 13:46:57 +01:00
William Carroll
d34b146702 Tests valid and invalid JWTs for the "aud" field
Test that when the JWT contains the client ID for my Google app, the JWT is
valid, and when it doesn't, it's invalid.
2020-08-08 13:44:22 +01:00
William Carroll
926d8e643e Update jwtIsValid API to return IO Bool
I need IO for:
- Getting the current time to validate `exp`
- Making an HTTP request to Google's token verifier endpoint
2020-08-08 11:18:49 +01:00
William Carroll
3eaf6e5aea Remove redundant deps from API.hs
Thank you, -Wall. You are truly an unsung hero.
2020-08-08 11:10:28 +01:00
William Carroll
7b8ec4170a Begin work for supporting GoogleSignIn server-side
I'm attempting to be an obedient boy and implement this and future features
using TDD.

TL;DR:
- Defined a few tests
- Defined an empty GoogleSignIn module
- Defined a Fixtures module to quickly create JWTs to test
2020-08-08 11:10:19 +01:00
William Carroll
9dcbd0d067 Define Utils module
Dumping grounds for personal, stylistic functions intended to improve readabily
and writability (in that order).
2020-08-08 11:06:53 +01:00
William Carroll
a7ddb56b9b Support echo server to test POST /verify
TL;DR:
- Add common dependencies like Servant, Aeson, Warp, Cors
- Define a POST /verify endpoint for our client to hit
- POST to /verify client-side onSignIn
2020-08-06 22:23:06 +01:00
William Carroll
1fc1087014 Support Google Sign-in client-side
TODO: Support Google Sign-in server-side

Also:
- Add Haskell to project's shell.nix
- Add stubbed Main.hs and Spec.hs
- Add common .ghci file
2020-08-06 21:54:25 +01:00
William Carroll
5f52077492 Re-type type using the altered keyboard
Remember: always read the instructions; that's the most important part.
2020-08-06 00:18:44 +01:00
William Carroll
e14fff7d4b Support Transforms.optimize
Partially optimize inputs and document rules for further optimizations we can
make.
2020-08-06 00:15:31 +01:00
William Carroll
d45685e245 Apply a series of transformation to a QWERTY keyboard
TL;DR:
- Accept input from the CLI
- Add a project README.md
2020-08-05 23:36:04 +01:00
William Carroll
244503bba9 Support App.transform
Apply the transform to a Keyboard. Onwards to the final demonstration!
2020-08-05 23:21:08 +01:00
William Carroll
61a2fb108d Support parsing the list of transforms
Using Haskell's Text.ParserCombinators.ReadP library for the first time, and I
enjoyed it thoroughly! It's nice avoiding a third-party library like MegaParsec.
2020-08-05 22:54:50 +01:00
William Carroll
d948ed9ebf Define an instance for Show for a Keyboard
This will help me debug.
2020-08-05 21:52:10 +01:00
William Carroll
1af0007a7d Create a Utils module
To stylize things...
2020-08-05 21:51:55 +01:00
William Carroll
40753e9f3b Add some the scaffolding for testing
As I attempt to habituate TDD, I should have some examples of tests to minimize
all friction preventing me from testing.
2020-08-05 21:37:08 +01:00
William Carroll
c4299558a7 Include instructions for building Tailwind CSS in README.md
After consuming my Elm boilerplate, I realized that I was missing this.
2020-08-04 16:37:45 +01:00
William Carroll
b1c403f6b9 Create small command line program that parses arguments
Before starting my take-home assignment, the instructions advised me to create a
"Hello, world" program in the language of my choice. Since I'm choosing Haskell,
I created this example as my starter boilerplate.
2020-08-04 16:36:31 +01:00
William Carroll
ef40622a87 Mark Dangal as watched
Many Bollywood movies have excellent acting, excellent directing, excellent
storytelling, but in my opinion, they spoil this with unnecessary musicals
interspersed throughout the films.

Dangal is a notable exception here. Overall, I'd say that this movie is
appropriately rated!
2020-07-30 09:35:01 +01:00
William Carroll
1e82ea4b26 Mark Hitchcock's Vertigo as watched
Watched the famous "Vertigo" with the timeless Jimmy Stewart. Overall I'd say
that the film is overhyped, but worth watching nevertheless.
2020-07-30 09:33:52 +01:00
William Carroll
8042c1e216 Watch "Hacksaw Ridge"
I don't plan on writing movie reviews in my Git commit message.
2020-07-26 23:00:33 +01:00
William Carroll
32e9f7f56d Add query for the productive directors
Show the movies from directors that appear more than once in the list.
2020-07-26 15:53:07 +01:00
William Carroll
6ca531116f Create a scratch buffer for common queries
Defining some commonly used criteria for selecting movies as SQL queries.
2020-07-26 15:52:59 +01:00
William Carroll
c36ae072d2 Mark Andhadhun as watched
What a confusing movie this was... I may need to watch it a second time to
better understand what happened, but I found watching it once already so
exhausting that I'm not sure I'll ever watch it again.
2020-07-26 12:23:36 +01:00
William Carroll
445763b5d9 Update schema for Movies table
Added the following fields (would be cool if `git` could show this):
- rating
- haveWatched
- director
- isCartoon
- requiresSubtitles
2020-07-26 12:22:17 +01:00
William Carroll
6981db2439 Create //playbooks/sqlite3.md
Write a playbook for using SQLite to capture some trivia that I often forget in
between my ~infrequent uses of SQLite.
2020-07-26 12:21:12 +01:00
William Carroll
a29ed22a83 Create //playbooks/shell.md
Taken from the overview:
> I'm making this as an offline reference for some of the commands that I use
> often enough to need to remember but not often enough to *actually* remember.
2020-07-26 11:26:05 +01:00