diff options
Diffstat (limited to 'users/wpcarro/website/blog')
-rw-r--r-- | users/wpcarro/website/blog/.skip-subtree | 1 | ||||
-rw-r--r-- | users/wpcarro/website/blog/default.nix | 46 | ||||
-rw-r--r-- | users/wpcarro/website/blog/fragments/.skip-subtree | 0 | ||||
-rw-r--r-- | users/wpcarro/website/blog/fragments/post.html | 8 | ||||
-rw-r--r-- | users/wpcarro/website/blog/fragments/posts.html | 10 | ||||
-rw-r--r-- | users/wpcarro/website/blog/posts.nix | 32 | ||||
-rw-r--r-- | users/wpcarro/website/blog/posts/auto-reboot-nixos.md | 40 | ||||
-rw-r--r-- | users/wpcarro/website/blog/posts/cell-phone-experiment.md | 274 | ||||
-rw-r--r-- | users/wpcarro/website/blog/posts/quassel-google-vm.md | 34 | ||||
-rw-r--r-- | users/wpcarro/website/blog/posts/send-mail-as-2fa.md | 43 |
10 files changed, 488 insertions, 0 deletions
diff --git a/users/wpcarro/website/blog/.skip-subtree b/users/wpcarro/website/blog/.skip-subtree new file mode 100644 index 000000000000..3a9dbd4d2b60 --- /dev/null +++ b/users/wpcarro/website/blog/.skip-subtree @@ -0,0 +1 @@ +Subdirectories contain blog posts and static assets only \ No newline at end of file diff --git a/users/wpcarro/website/blog/default.nix b/users/wpcarro/website/blog/default.nix new file mode 100644 index 000000000000..d87b714b6fe1 --- /dev/null +++ b/users/wpcarro/website/blog/default.nix @@ -0,0 +1,46 @@ +{ depot, lib, pkgs, ... }: + +with depot.nix.yants; + +let + inherit (builtins) hasAttr filter readFile; + inherit (depot.web.blog) post includePost renderPost; + inherit (depot.users.wpcarro.website) domain renderTemplate withBrand; + inherit (lib.lists) sort; + + config = { + name = "bill and his blog"; + baseUrl = "https://${domain}/blog"; + footer = ""; + }; + + posts = sort (x: y: x.date > y.date) + (filter includePost (list post (import ./posts.nix))); + + rendered = pkgs.runCommandNoCC "blog-posts" { } '' + mkdir -p $out + + ${lib.concatStringsSep "\n" (map (post: + "cp ${renderPost config post} $out/${post.key}.html" + ) posts)} + ''; + + formatDate = date: readFile (pkgs.runCommandNoCC "date" { } '' + date --date='@${toString date}' '+%B %e, %Y' > $out + ''); + + postsHtml = renderTemplate ./fragments/posts.html { + postsHtml = lib.concatStringsSep "\n" (map toPostHtml posts); + }; + + toPostHtml = post: readFile (renderTemplate ./fragments/post.html { + postUrl = "${config.baseUrl}/posts/${post.key}.html"; + postTitle = post.title; + postDate = formatDate post.date; + }); +in +pkgs.runCommandNoCC "blog" { } '' + mkdir -p $out + cp ${withBrand (readFile postsHtml)} $out/index.html + cp -r ${rendered} $out/posts +'' diff --git a/users/wpcarro/website/blog/fragments/.skip-subtree b/users/wpcarro/website/blog/fragments/.skip-subtree new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/users/wpcarro/website/blog/fragments/.skip-subtree diff --git a/users/wpcarro/website/blog/fragments/post.html b/users/wpcarro/website/blog/fragments/post.html new file mode 100644 index 000000000000..44593094ecdf --- /dev/null +++ b/users/wpcarro/website/blog/fragments/post.html @@ -0,0 +1,8 @@ +<li class="pb-6 md:pb-10"> + <h2 class="text-bold text-xl"> + <a class="font-bold text-blue-600 hover:underline" href="@postUrl@"> + @postTitle@ + </a> + </h2> + <p class="text-gray-500">@postDate@</p> +</li> diff --git a/users/wpcarro/website/blog/fragments/posts.html b/users/wpcarro/website/blog/fragments/posts.html new file mode 100644 index 000000000000..a85a4b71101e --- /dev/null +++ b/users/wpcarro/website/blog/fragments/posts.html @@ -0,0 +1,10 @@ +<div class="max-w-sm md:max-w-prose mx-auto"> + <section class="pt-8 pb-14"> + <p class="font-bold pb-3 text-xl"> + Personal blog by <a class="font-bold text-blue-600 hover:underline" href="@homepage@">Bill</a>. + </p> + <p class="text-gray-500">> Half-baked musings lossily encoded.</p> + <p class="text-gray-500">> - misc reviewer</p> + </section> + <ul>@postsHtml@</ul> +</div> diff --git a/users/wpcarro/website/blog/posts.nix b/users/wpcarro/website/blog/posts.nix new file mode 100644 index 000000000000..5a58c9309ce5 --- /dev/null +++ b/users/wpcarro/website/blog/posts.nix @@ -0,0 +1,32 @@ +# To format the date, run: +# $ date -d "today" +%s +[ + { + key = "cell-phone-experiment"; + title = "Cell Phone Experiment"; + date = 1585800000; + content = ./posts/cell-phone-experiment.md; + draft = false; + } + { + key = "quassel-google-vm"; + title = "IRC, GCP, and NixOS"; + date = 1640404800; + content = ./posts/quassel-google-vm.md; + draft = true; + } + { + key = "send-mail-as-2fa"; + title = "2FA and Gmail's \"Send mail as\""; + date = 1641497483; + content = ./posts/send-mail-as-2fa.md; + draft = false; + } + { + key = "auto-reboot-nixos"; + title = "Automatically Reboot NixOS"; + date = 1643666914; + content = ./posts/auto-reboot-nixos.md; + draft = false; + } +] diff --git a/users/wpcarro/website/blog/posts/auto-reboot-nixos.md b/users/wpcarro/website/blog/posts/auto-reboot-nixos.md new file mode 100644 index 000000000000..24474e6dfe48 --- /dev/null +++ b/users/wpcarro/website/blog/posts/auto-reboot-nixos.md @@ -0,0 +1,40 @@ +## Show me the codes + +Regularly rebooting machines can be a useful, hygienic practice, but quite +frankly I cannot be relied on to remember to regularly reboot my machine. + +Let's free-up some wetware-RAM by automating this with Nix. The following +addition to your `configuration.nix` will schedule daily reboots at `03:00`: + +```nix +systemd.timers.auto-reboot = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 03:00:00"; + Unit = "reboot.target"; + }; +}; +``` + +If you want to fiddle with the date format, `systemd-analyze` is your friend: + +```shell +λ systemd-analyze calendar '*-*-* 03:00:00' +Normalized form: *-*-* 03:00:00 + Next elapse: Tue 2022-02-01 03:00:00 PST + (in UTC): Tue 2022-02-01 11:00:00 UTC + From now: 12h left +``` + +After calling `nixos-rebuild switch`, you can verify that `systemd` started the +timer with: + +```shell +λ systemctl list-timers auto-reboot +# output omitted because I'm writing this from a different machine +``` + +## That's all, folks! + +I wanted to keep this post short-and-sweet, to build the habit of posting more +regularly. Hopefully someone out there found this useful. diff --git a/users/wpcarro/website/blog/posts/cell-phone-experiment.md b/users/wpcarro/website/blog/posts/cell-phone-experiment.md new file mode 100644 index 000000000000..c289954a58f1 --- /dev/null +++ b/users/wpcarro/website/blog/posts/cell-phone-experiment.md @@ -0,0 +1,274 @@ +### TL;DR + +I will not use my cell phone during March to learn more about how much I depend +on it. + +### Explore/Exploit + +Ever since I read Charles Duhigg's book, [The Power of Habit](poh), I try to +habituate as many aspects of my life as I can. + +Making my bed every morning is an example of a habit -- so too is flossing at +night before bed. + +The *exploit* axis of the [explore/exploit tradeoff](exp-exp) endows habits with +their power. Brian Christian and Tom Griffiths explain this concept more clearly +than I can in Chapter 2 of their exceptional book, [Algorithms to Live +By](algos). + +Habits are powerful, but if I overly exploit an activity, I may settle on a +local optimum in lieu of settling on a global optimum; these are the opportunity +costs of exploiting (i.e. habits) versus exploring (i.e. spontaneity). + +But what if it was possible to habituate exploration? + +### Monthly challenges + +Every month since October 2018, I challenge myself to try something new. In the +past, monthly challenges have been things like: +- sign up and take Brazilian Jiu Jitsu classes +- buy a guitar and learn [Freight Train](https://www.youtube.com/watch?v=IUK8emiWabU) +- study Italian +- learn a handstand + +Typically for an activity to qualify as a challenge, I must spend *at least +fifteen minutes* working on it *at least five days* each week. + +This month (i.e. March) I'm challenging myself to avoid using my cell phone. + +My parents gave me a cell phone when when I was a freshman in High School; I was +14 years old. I am now 28, so I have been using a cell phone semi-daily for over +a decade. + +While I enjoy the convenience that my cell phone provides me, I am curious to +suspend my usage to more clearly understand how much I depend on it... + +### April + +Now it is early April, and I completed March's challenge. So how was it? + +Below I outline the parts of using a cell phone that I missed and the parts that +I surprisingly did not miss. I will also mention the two times that I used my +cell phone and why. + +The first three things that I missed all relate to time. + +#### Timekeeping + +On the first day I realized that unless I was near a computer, I did not know +what time it was. + +I exclusively use my cell phone as my watch; I do not wear a watch. To adapt, I +started looking for clocks around my office and while I was taking public +transportation. Thankfully London posts the current time on the digital train +schedules. This oriented me while I was traveling, which was also when I needed +to know the time the most. + +Most of the month, however, I never precisely knew what time it was. + +#### Alarm clocks + +While I anticipated living without an alarm clock prior to the experiment, I +decided against buying a substitute. Prior to this month, I theorized that +morning alarms probably disrupt the quality of my sleep. If I'm tired, shouldn't +I keep sleeping? + +As the month progressed and my 24 hour day morphed into a 25 hour day, I learned +that I would prefer waking up at a set time every day and synchronize my +schedule with the rest of my timezone. + +I am still unsure if alarm clocks are helpful in the long-term. I would have +slept with the curtains drawn to allow the morning sun to wake me +up. Unfortunately, I live on the ground floor nearby a brightly shining street +lamp that spills into my bedroom. + +If I lived somewhere more remote (perhaps even a suburb would do) I would like +to repeat an experiment where I live for a month without an alarm clock. + +For now, I must return to the Temple of Chronology and supplicate until Father +Time restores my sanity. + +#### Timers + +Using timers motivates me to do a bunch of short tasks like cleaning my flat for +fifteen minutes, stretching, or reading before bed. Thankfully, I already owned +a physical timer that I keep in my kitchen. This replaced the timer on my phone +without disrupting my routine. + +#### Maps + +Speaking of being disoriented, what about living without maps software? On the +few occasions where I traveled somewhere that was unfamiliar to me, I had to +memorize the directions from my computer before I departed. + +At least I didn't need to visit gas stations or museums to buy trifold tourist +maps... + +I once left my office mistakenly assuming that I would download the directions +to my destination while commuting. As I awaited the office elevator, I realized +that I had no clue where I was heading. + +Thankfully I wasn't far from the safety, comfort, and familiarity of my desktop +computer -- with its fatty WiFi connection. In no time I was studying Google +Maps in my web browser and memorizing the directions. + +Overall this was hardly an inconvenience, and I think I even enjoyed +stress-testing my memory: a job that I so often outsource to hardware. + +#### Rendezvouses + +A couple of times I met friends in various parts of the city. Organizing these +particular rendezvouses was a novel (read: anachronistic) experience. For all +you young whippersnappers reading, take out your stone tablets and chisels. I'm +going to explain how this works: + +First I would tell my friends where and when to meet me. I emphasized that I +would be quite helpless to any changes they might make to the plans once I began +commuting, which made the commitments unusually more binding. + +On one occasion my friend -- who is characteristically prompt, and even chides +me for when I'm late -- was twenty minutes late for our engagement. My friend is +German, so I figured I should do my civic duty of alerting the German embassy +that my friend had broken German code, is obscenely late, and should therefore +hand-in his passport and renounce his citizenship. After awhile my conscience +advised me to reconsider. + +It was fortunate for both of us that I did not fully understand how late he was. +Remember: I didn't know what time it was. + +I decided this would be a useful opportunity to test my patience, so I loitered +for twenty minutes outside of our meeting point. He couldn't text me to tell me +that he was late. I couldn't listen to music, call family or friends, or partake +in any of the other rituals that modern-day loiterers observe to pass the +time. In the end he showed up, and it was scarcely a big deal. + +This experience made me wonder what the policy for abandoning plans is when +someone is running late. Before smart phones, how long did people wait? Maybe +the proper etiquette is to wait long enough for you to absolve yourself of the +guilt of flaking in the unlikely event that your friend arrives shortly after +you leave. + +So... thirty minutes? I'll call my grandma tomorrow and ask her. + +#### Boredom + +My phone couldn't entertain me while I queued at the grocery store. Same too +when I commuted. + +I also found myself listening to less music than I usually do. I decided to read +to occupy the void when I could; this helped me progress towards completing this +year's [GoodReads challenge][gr-annual]. + +### Cheating + +I used my phone twice during March. + +1. Once to use my bank's mobile app to internationally transfer money from my + U.K. account to my U.S. account. I could have used [TransferWise's][tw] + website, but I didn't. +2. Another time I used my phone to take pictures of an item that I wanted to + sell on [CraigsList][cl]. I could have and perhaps should have used my laptop's + webcam, but at the time, I didn't want to. I am accustomed to using my phone + to take pictures, and I wanted to sell something. + +In both of these cases, prior habits eroded my resolve to stay the course. These +are useful reminders that habits don't distinguish between helpful and hurtful; +they just exist. + +In total I would estimate that I spent somewhere around fifteen minutes using +my phone in March. While not perfect: + +> Better a diamond with a flaw than a pebble without (Confucius) + +### Substitution = Dilution + +While the explicit goal of this challenge was to avoid using my cell phone for a +month, the implicit goal was to disengage from many of the +[nonessential][essentialism] activities that compete for my attention. + +There were some activities that I didn't miss while living without a cell +phone. This wasn't because I don't value these activities, but rather because I +can adequately replace them with alternatives. + +For texting and making phone calls, I used [Telegram][wtf-telegram]. Telegram +helped me sustain a healthy relationship with my girlfriend while still honoring +the constraints of the challenge. + +While I appreciated the convenience Telegram provided, I felt that I remained +about as [available][wtf-availability] during March as I was in February. If I +ever experiment with drastically reducing my availability, I will be more +explicit about my objectives. + +### Distraction displacement (whack-a-mole) + +Because cell phones and other electronics have conditioned my behavior, I +habitually avoid boredom and seek entertainment. On its face this may not sound +like a harmful practice. My generation drills the aphorism "you only live once", +suggesting that we may want to embrace a Hedonistic lifestyle. + +Hedonism may or may not be a wise way to play the game of Life. All I know is +that living a life in which I am often stimulated but proportionately distracted +appeals increasingly less to me as time progresses. + +During March I noticed that once I freed my attention from sending/receiving +texts, my brain quickly reassigned my attention to maintaining a vigil over the +other social media outposts that I maintain. + +I should also admit that I habitually checked Telegram now that it served as my +new cell phone. Didn't see that coming... + +In another case, once I discovered that I could use Instagram in a web browser +instead of on my phone, I filled my newfound time and attention on +[Instagram.com][ig] (don't click!): displacing the time that I spent on an app +on my phone to time that I spent on a website in a web browser. + +Holy whack-a-mole! + +Halfway through the month, I wrote a [program to block websites][url-blocker] on +my computer. Surprisingly this worked and forced me to more deliberately fill +this hard-fought, foreign time with other activities. + +### Easy come, easy go? + +As the saying for making friends goes, "easy come, easy go", implying that +friendships that you easily form can just as easily be destroyed. + +Habits invert this creation/destruction relationship. In my experience "easy +come" implies "difficult to go". + +For example, I could easily form the habit of eating chocolate around 15:00 at +work; curbing this habit would require more effort. When I compare this to the +difficulty I experienced habituating a meditation practice, and how easily I +can dislodge my meditation practice, it seems to me that the laws of habits +dictate "easy come, difficult go; difficult come, easy go". + +I suspect that while my cravings for using a cell phone have temporarily ceased, +they will return shortly after I start using my cell phone. And as if nothing +happened, I return to where I was at the end of February just before I decided +to curb my cell phone usage. + +Because of this, I'm planning on keeping my cell phone in my closet where I +stored it during the month of March. As noted, enough substitutes exist for me +to live a mostly normal life: one where I am not unnecessarily straining the +relationships of my friends and my family. After all these are the people who +matter most to me and those who drive me to explore new ways to improve. + +I recognize that the "self" in self-experimentation is a misnomer. Can you truly +conduct an [N of 1 trial][nof1]? My decisions impact the people in my life, and +I want to thank everyone who tolerates my eccentric and oftentimes annoying +experimentation. + +Thank you for reading. + +[pod]: https://www.goodreads.com/book/show/12609433-the-power-of-habit +[exp-exp]: https://en.wikipedia.org/wiki/Multi-armed_bandit +[algos]: https://www.goodreads.com/book/show/25666050-algorithms-to-live-by +[gr-annual]: https://www.goodreads.com/user_challenges/19737920 +[cl]: http://craigslist.com +[tw]: https://transferwise.com +[url-blocker]: https://github.com/wpcarro/url-blocker +[wtf-telegram]: https://telegram.org +[wtf-availability]: https://landing.google.com/sre/sre-book/chapters/availability-table +[essentialism]: https://www.goodreads.com/book/show/18077875-essentialism +[ig]: https://instagram.com +[nof1]: https://en.wikipedia.org/wiki/N_of_1_trial diff --git a/users/wpcarro/website/blog/posts/quassel-google-vm.md b/users/wpcarro/website/blog/posts/quassel-google-vm.md new file mode 100644 index 000000000000..dd74387f8bf0 --- /dev/null +++ b/users/wpcarro/website/blog/posts/quassel-google-vm.md @@ -0,0 +1,34 @@ +# IRC, GCP, and NixOS + +- "cannot read /var/lib/acme/wpcarro.dev/full.pem" +- `sudo stat /var/lib/acme/wpcarro.dev/full.pem` exists +- `sudo -i` +- `su quassel` # denied +- `sudo --user=quassel stat /var/lib/acme/wpcarro.dev/full.pem` exists +- `groups quassel` quassel +- `usermod -a -G nginx quassel` exists +- `groups quassel` quassel, nginx +- `sudo --user=quassel cat /var/lib/acme/wpcarro.dev/full.pem` exists + +# Firewall + +- `nmap localhost` +- `nmap wpcarro.dev` +- Update `configuration.nix` firewall +- `nmap localhost` +- `nmap wpcarro.dev` +- Edit cloud.google.com Configuration (VPC > Firewall > 6697) + +# Quassel + +- Test connecting, disconnecting, persisted logs? +- Change `~quassel@253.253.209.35.bc.googleusercontent.com` -> `~quassel@wpcarro.dev` + - cloaking? + - rDNS? + - `dig wpcarro.dev` -> `35.209.253.253` + - `dig -x 35.209.253.253` -> `253.253.209.35.bc.googleusercontent.com` + - From within GCP https://stackoverflow.com/a/47060002 (create the PTR record) +- `/msg hostserv take hackint/user/$account` add cloaking +- disconnect/connect from hackint for changes to take affect +- `/msg hostserv drop` remove cloaking +- Test can I log-in from another machine? diff --git a/users/wpcarro/website/blog/posts/send-mail-as-2fa.md b/users/wpcarro/website/blog/posts/send-mail-as-2fa.md new file mode 100644 index 000000000000..5d18935c7aef --- /dev/null +++ b/users/wpcarro/website/blog/posts/send-mail-as-2fa.md @@ -0,0 +1,43 @@ +## Prelude + +This is a short story about how I configured myself out of my own email. Posting +this as an exercise in humility, a tutorial for my future self in case of +amnesia, and penance for my sins. + +## Background + +- I have 2x Gmail accounts: **work** and **personal**. +- I configure **work** to send emails as **personal**. +- I configure **personal** to forward incoming emails to **work**. + +This allows me to use **work** and manage both of my inboxes as one. I recently +added two-factor authentication (2FA) to **personal**, forgot about it, and +spent a few days unable to send **personal** emails from any **work** device. + +## Symptoms + +Whenever I tried to send emails on behalf of **personal**, I'd receive the +following error message as a reply: + +> You're sending this from a different address using the 'Send mail as' feature. +> The settings for your 'Send mail as' account are misconfigured or out of date. +> Check those settings and try resending. + +Useful error message if you ask me (especially in retrospect), but because I had +*forgotten* that I setup 2FA for **personal**, I naively assumed this issue +might magically disappear given enough time... kind of how restarting your +device resets the state and causes the symptoms of a certain class of bugs to +disappear. + +After a few days of mounting frustration, I decided to take a closer look... + +## Solution + +- Create an "App Password" for **personal**: + [instructions](https://support.google.com/accounts/answer/185833?hl=en). +- Login to **work** and delete **personal** from `Settings > Accounts > Send + mail as`. +- `Add another email address` for **personal** using the "App Password" you + just created. + +And now I'm back in business! |