Commit graph

1196 commits

Author SHA1 Message Date
William Carroll
7d340689ba Delete the stale tests
While this project would benefit from having test coverage, the current tests
are not providing any useful coverage.
2020-03-29 20:39:39 +01:00
William Carroll
946764f6bd Read and write to /etc/hosts
TL;DR:
- Rename website-blocker to url-blocker
- Add a README.md
- Reads and writes to /etc/hosts
2020-03-29 20:39:39 +01:00
William Carroll
75595b0126 Parse and serialize rules.json
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
2020-03-29 18:49:45 +01:00
William Carroll
059af12bea Experiment with user /etc/hosts
I have not been able to get this to work yet, but I hear that it is possible to
maintain a user-specific /etc/hosts.
2020-03-29 00:01:51 +00:00
William Carroll
ef5eda4015 Implement isToday predicate
Use the Data.Time package to implement the isToday predicate.
2020-03-29 00:00:47 +00:00
William Carroll
561cb619a1 Add <unstable> to NIX_PATH
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.
2020-03-28 23:58:37 +00:00
William Carroll
37bb04eb5d Start social-fasting app
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
2020-03-28 19:36:13 +00:00
William Carroll
778114e6a8 Digitize daily habits
Create a web app off the post-its that I keep near my bathroom mirror.
2020-03-27 18:26:27 +00:00
William Carroll
1aefbf7be3 Add timestamps to habits.org
Add approximations to the duration of each activity.
2020-03-27 16:10:55 +00:00
William Carroll
c68b3ba021 Change srcs to src for website.goals derivation
Debug the typo.
2020-03-27 16:02:44 +00:00
William Carroll
48cdb69efb Publish habits as a webpage
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.
2020-03-27 16:02:44 +00:00
William Carroll
f2ba5aca31 Ensure Emacs prettier hook activates
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.
2020-03-27 10:59:57 +00:00
William Carroll
0281eb58aa Add node_modules to .gitignore of boilerplate/typescript
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.
2020-03-27 10:59:50 +00:00
William Carroll
514136c99a Run Prettier across projects
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.
2020-03-27 10:59:50 +00:00
William Carroll
f4f7f454fa Delete nut-score
In the spirit of minimalism, I would like to delete this half-baked project from
my repository.

Do less, but better.
2020-03-27 10:59:50 +00:00
William Carroll
6b224a9e31 Drop support for lorri
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.
2020-03-27 10:59:50 +00:00
William Carroll
47a0b45f5f Change theme to doom-one
TL;DR
- Prefer doom-one theme to solarized light
- Prefer colorscheme/set to themes/set
2020-03-26 23:34:40 +00:00
William Carroll
2f817e4dd7 Solve InterviewCake's recursive string permutations problem
Write a function that returns the set of all of the possible permutations of an
input string. This function should be solved recursively.
2020-03-26 19:43:40 +00:00
William Carroll
062af32e4e Solve InterviewCake's find duplicate beast mode
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.
2020-03-26 11:55:06 +00:00
William Carroll
3ff6ae3697 Use Parcel's --public-url option when building
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.
2020-03-25 17:18:51 +00:00
William Carroll
06d2467c56 Use boilerplate/typescript for goals
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!
2020-03-25 17:04:41 +00:00
William Carroll
cd06990fe3 Debug typescript/default.nix
TL;DR
- Change derivation name
- Point to $src/index.html instead of non-existent index.html
- Prefer defining pkgs as a function argument
2020-03-25 17:01:17 +00:00
William Carroll
d7cc1f03de Remove math.ts from boilerplate/typescript
This file is only a distraction.
2020-03-25 16:47:03 +00:00
William Carroll
89cd77a64b Create wpcarro.dev/goals
Create a simple React app to define my goals. See the goals/README.md for more
context.
2020-03-25 16:30:22 +00:00
William Carroll
265b691c9b Add @types/node to typescript boilerplate
Parcel uses process.env to expose environment variables. Since process.env is a
Node concept and this boilerplate is for TypeScript projects, we need
@types/node to support these Node types.
2020-03-24 13:29:57 +00:00
William Carroll
527aeeeced Add sandbox project using Contentful CMS
I used the boilerplate/typescript project as a starting point. This project
fetches and renders books that I'm defining in a Contentful CMS that I created.
2020-03-24 13:27:30 +00:00
William Carroll
57b58e9b2f Move nut-score into website/sandbox
Also move some .gitignore entries from the top-level .gitignore into a
subdirectory .gitignore.
2020-03-24 12:29:34 +00:00
William Carroll
2551b41d73 Delete mail/
I do not use this. In the interest of trimming fat, I'm removing it.
2020-03-24 12:27:00 +00:00
William Carroll
9fdf4d00fa Support boilerplate for TypeScript projects
I would like to support boilerplate code for ReasonML, TypeScript,
ClojureScript, and Elm projects before I specialize in any of these
frameworks. All of my projects should use TailwindCSS.

All of this boilerplate should offer:
- Same command to start developing
- Same API to build and deploy
- TailwindCSS support
- Basic boilerplate for components, state, and routes

This TypeScript boilerplate is not complete, but I would like to commit the
progress in case I do not return to this for awhile.
2020-03-23 22:43:36 +00:00
William Carroll
1cc1ce5ccf Change the value of constants/current-project
Yesterday evening, I moved the blog directory to website/blog; I forgot to
update this value.
2020-03-20 16:56:46 +00:00
William Carroll
ae9e83f5d7 Solve InterviewCake.com's mesh-message problem
Write a function that returns the shortest path between nodes A and B in an
unweighted graph.

I know two algorithms for finding the shortest path in a *weighted* graph:
- Use a heap as a priority queue instead of the regular queue that you would use
  when doing a BFT. This is called Dijkstra's algorithm. You can also use
  Dijkstra's algorithm in an unweight graph by imaginging that all of the
  weights on the edges are the same value (e.g. 1).
- Map the weighted graph into an unweighted graph by inserting N nodes between
  each node, X and Y, where N is equal to the weight of the edge between X and
  Y. After you map the weighted graph into an unweighted graph, perform a BFT
  from A to B. A BFT will always find the shortest path between nodes A and B in
  an unweighted graph.

I had forgotten that a BFT in an unweighted graph will always return the
shortest path between two nodes. I learned two things from InterviewCake.com's
solution:
1. I remembered that a BFT in an unweighted graph will return the shortest
   path (if one exists).
2. I learned to use a dictionary to store the edge information and then
   back-tracking to reconstruct the shortest path.
2020-03-20 16:49:49 +00:00
William Carroll
117f0be7c2 Unbind <SPC> in evil's motion map
By default this just advances the point one character, which I don't use nor
want especially because my leader key is the space key.
2020-03-20 12:12:42 +00:00
William Carroll
d0d77baafb Support KBD for toggling linum-mode
I would like to restore the good practice of jumping precisely to line numbers
within buffers.
2020-03-20 12:12:09 +00:00
William Carroll
f4fea2346e Move sandbox into website
Nest the sandbox work under ./website.
2020-03-20 00:52:05 +00:00
William Carroll
1d5ab45303 Move learn to website/learn
Nest the learn directory in the website directory.
2020-03-20 00:47:21 +00:00
William Carroll
95e761e59b Move blog into website/blog
Nest the blog work within the website directory.
2020-03-20 00:46:29 +00:00
William Carroll
54d1a0048a Add sitemap to wpcarro.dev
- Create ./website directory
- Add a sitemap to wpcarro.dev
- Move covid-uk directory to sandbox directory

TODO: Next sandbox, blog, and learn in the website directory
2020-03-20 00:22:13 +00:00
William Carroll
76210a217c Attempt to serve sandbox.wpcarro.dev/covid-19
Right now my website is serving at sandbox.wpcarro.dev, but I would rather
people view it at sandbox.wpcarro.dev/covid-19.

I previously tried to accomplish this with the following Nginx configuration:

```nix
locations."/covid-19" = {
  root = briefcase.covid-uk;
}
```

I am now trying `alias = ...` instead of `root = ...`. I got the idea from this
SO question, https://stackoverflow.com/questions/10631933/nginx-static-file-serving-confusion-with-root-alias.
2020-03-19 12:48:03 +00:00
William Carroll
380a6a352c Solve InterviewCake's graph-coloring problem
Write a function that colors the nodes of a graph such that no two neighbors
share a color.
2020-03-19 12:31:24 +00:00
William Carroll
1d45f14615 Update COVID-19 webpage
- Prefer hosting on sandbox.wpcarro.dev; I would prefer to host it at
  sandbox.wpcarro.dev/covid-19, but I haven't figure out how to use Nginx to do
  serve locations like /covid-19 yet.
- Splice the src directory: When I develop locally and index.html exists within
  ./src, I cannot access ./node_modules because ./node_modules is in a parent
  directory. I could fix this if I used a bundler like Parcel or Webpack, but I
  do not want to set that up at this time.
- Introduce Tailwind for CSS. This complicates my build a bit as well. For now,
  I'm including output.css even though ideally I should not version-control this
  file. I haven't figured out how to `yarn install` and run commands like `npx
  tailwindcss build styles.css -o output.css` in a Nix derivation yet. Hopefully
  I will learn and refactor this.
- Add some content about why I made this chart
- Add some content about some of my covid-19 predictions
- Add a footer to the webpage
- Delete timeseries.json and prefer fetching the published data instead
2020-03-19 12:30:49 +00:00
William Carroll
c627fa9cbd Prefer live timeseries.json
When I was first developing this, and I attempt to access
https://pomber.github.io/covid19/timeseries.json, the browser prevents me from
reading the data because it violates the same origin policy.

I'm learning more about CORS, and I'm going to try consuming this from...
https://wpcarro.dev -> https://pomber.github.io
...instead of...
http://localhost:8000 -> https://pomber.github.io
...because the http -> https protocol violates CORS.

I will not know unless I try, so... bombs away.
2020-03-19 10:25:25 +00:00
William Carroll
abd2dcc6a3 Remove git.wpcarro.dev entry fron Nginx config
This is not currently working and it is causing Nginx to enter a retry loop. I
am removing it until I choose to focus on it.
2020-03-18 22:08:14 +00:00
William Carroll
dd9788fa73 Create line chart of UK confirmed corona virus cases
I was having trouble tracking the growth of corona virus cases in the UK.
Thankfully someone is publishing some daily COVID data as JSON. I downloaded
that data manually and plotted it using the chart.js library as a programming
exercise with Mimi.

Now I'm attempting to deploy to https://wpcarro.dev/covid-uk.

TODO(wpcarro): Prefer the live API data instead my soon-to-be-stale downloaded.
2020-03-18 22:08:09 +00:00
William Carroll
79b5fce68a Scatter blog post ideas for "Let's Learn Nix"
I may not use any of these. I'm just scrawling notes as blog posts to see if
anything sticks.
2020-03-17 22:42:22 +00:00
William Carroll
209fdf5726 Add ReasonML boilerplate
After some toil, I finally support basic ReasonML starter code.

I'm adding it to the nut-score directory because I would like to make a simple
webpage that render some nutritional facts about nuts with respect to the
ketogenic diet.

I'm not sure if I should include or exclude te .bs.js files.

See the README.md for more information.
2020-03-17 22:40:48 +00:00
William Carroll
166aed6e80 Disable redshift's fading animation
I originally passed the options `[ "-o" "-P" ]` to disable redshift's fading
animation, but what I wanted originally was the `[ "-r" ]` option.
2020-03-17 18:29:08 +00:00
William Carroll
862c695900 Work on "Let's Learn Nix: Dotfiles" blog post
It has been awhile since I have written a tutorial. I have spent 2-3 hours
working on this post, but I think I need to spend another 2-3 hours before I
publish it.

I expect to be able to write these posts faster as I practice.

I would like to create a few resources that I can reuse in each article for
things like:
- "Let's Learn Nix" reproducibility: Where I list all of the tutorials'
  dependencies: nix version, <nixpkgs> version, OS type and version, etc.
- Haskell type signature convention for Nix
- Ad hoc vs. declarative configuration for Nix
- Troubleshooting Nix: <nixpkgs> search, nix repl, searching the Nix codebase
2020-03-16 20:17:24 +00:00
William Carroll
eb402bca74 Create derivation for learn.wpcarro.dev
Creating a derivation to abstract over the build process for learn.wpcarro.dev.
2020-03-16 16:54:16 +00:00
William Carroll
ebf0ef7e34 Delete .xsessionrc
Nix home-manager generates an .xsession file for me. I believe there are a few
files for managing X-sessions:
- .xinitrc
- .xsession
- .xsessionrc: Only exists on Debian systems, which is why home-manager
  generates an .xsession file instead. gLinux is a Debian system.

Whenever I close Emacs, another Emacs initializes. I believe this is because
after I allowed home-manager to manage my X-sessions, I unintentionally
supported two X-session configuration files: .xsession and .xsessionrc; both of
these files initialize Emacs.

I'm deleting my .xsessionrc, and I'm hoping that will remove the issue.
2020-03-16 15:28:24 +00:00
William Carroll
1487d06660 Support autorandr
Enable autorandr with Nix home-manager. I discovered autorandr when looking
through the home-manager source code. I was hoping it would automatically
enable/disable my external monitor when I connect/disconnect my HDMI cable, but
it doesn't.

With autorandr, I run...

```shell
> autorandr --load mobile
```

...to load my randr settings for just my laptop without the external monitor,
and I run...

```shell
> autorandr --load docked
```

...to load my randr settings for my external monitor.

I'm not sure if this brings much more value than my existing display.el module,
but I'm willing to try it for now.
2020-03-16 13:59:20 +00:00