Euler Problem 002

Today’s problem was to get the sum of all even numbered Fibonacci numbers below four million. There’s a bunch of support code but here’s my solution:

const result = allFibonacciLessThan(4_000_000)
	.filter(isEven)
	.reduce(sum)
 
console.log(result)

This was a good chance to play with generators in JavaScript. Generators are a fancy iterator that can generate an infinite sequence which is perfect for Fibonacci numbers.

One thing that’s disappointing, though, is that I hoped I could use map/filter/reduce right on a generator and that turns out not to be possible. If it had been possible I would love to have written a takeUntil function that took a generator and a condition and stopped when the condition was fulfilled. That could have looked like

takeUntil(fibonacci, (n) => n > 4_000_000)
	.filter(isEven)
	.reduce(sum)

Which is maybe a little bit cleaner?

Working from the NY Public Library

I’m writing this right now from the NY Public library research and study room. Pictures aren’t allowed. Around me people are working quietly, mostly on laptops, although a few are writing in books or pouring over notes. All of the room is dark wood and old. The walls rise through a course of wood then thunder into blocks of stone with huge cutouts for windows where the afterlight of the sunset is pouring in before finally exploding an ornate ceiling with a mural of clouds in the middle.

The room smells of old books and study but unfortunately there don’t seem to be many books remaining. Ahead of me are gold lettered words that say “Library Catalog” but for the most part the shelves beneath are empty.

There is a murmur of conversation but it’s pouring in through the open door. No one here is talking now.

The room is lit with chandeliers descended from the ornate ceiling with rows and rows of bulbs. On the table are brass lamps. Although since most of us are writing on laptops they are mostly going unused.

To my left are rows of counters that say “Information” on them. I imagine in previous times that reference librarians would have worked at those counters. Behind them is a clock slowly sweeping its way towards 5pm.


I’m in a MUCH BIGGER room now. I’m at seat #105. The tables are all low and there are probably 200 people working quietly here. Still mostly laptops but the woman to my left is doing pencil sketching. This room does have books. The walls are full of them.


It’s magic to remember that all of this is free and anyone is welcome here (no matter how many scowls the woman checking bags at the door give them. SHE IS VERY GRUMPY)

Publishing Notes

I want a way to share my notes as I take them. I had some ideas that I wanted to try out vimwiki or emac’s org mode for my duration at Recurse but it’s also seems clear, even in the first day, that there is so much to do and learn and be involved with and I don’t think I want to spend my time exploring notetaking. I’ve used Obsidian in the past and even though I mostly only use it for managing a folder of daily notes it’s been helpful. So I think I’ll keep on using it.

Quartz

I was thinking that I might use hugo or another static site generator to publish my notes but then I found Quartz. Quartz is specifically setup to publish obsidian notebooks with many of the features available in the app also available on the web. So yes!

A couple of things I don’t love about quartz:

  • You have to fork the project into your own github and then commit changes. I guess this ok since mostly I won’t ever need to sync with the upstream? As long as my blog is publishing that’s good enough
  • Quartz would really like your obsidian notes to be a folder in the project. I don’t love mixing the code and my notes together. I want them to be separate repos. I maybe wants notes to be private and for not every note to be published. (I think quartz can let that happen?)

I worked around this by copying a single note in quartz and then doing all of the customization that I needed for my writing (mostly colors and turning off features). Then i wrote a github action that builds the site.

It was NO fun writing this because I had to push to Github everytime I made a change. Here’s the script for building the notes to HTML and publishing it:

name: Build website
on: push
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: nicolecomputer/quartz
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "npm"
      - run: "rm -rf content"
      - uses: actions/checkout@v4
        with:
          repository: nicolecomputer/nicole-notes
          path: "content"
      - run: npm i
      - run: npx quartz build
      - run: "ls public"
      - name: Upload static files as artifact
        id: deployment
        uses: actions/upload-pages-artifact@v3
        with:
          path: public/
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    permissions:
      pages: write
      id-token: write
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Auto Syncing obsidian with git

There’s a git plugin for Obsidian that lets it automatically commit and push changes to git. I have it setup to run every 10 minutes. This might end up being annoying or generating too many requests to keep building and publishing the site. We’ll see?

Templating

To have some control over what’s public and what’s private I want all notes to have a publish property which can be true or false. For daily notes it defaults to true. For other notes it defaults to false.

For daily notes Obsidian supports a template that gets used by default. Right now the template is just front-matter but if I end up having a consistent structure to my days I might incorporate that. My template looks like:

---
tags:
  - recurse
publish: true
---

Templating for just notes is a little harder. I’m using templater which allows setting a default template for a folder. I have a default template for all notes that land in the / folder of my notebook. It’s very similar to the note template:

---
title:
tags:
publish: false
---

The only additional property set on this note is the title attribute which lets me override the page title. This is especially helpful when there’s a page called index but I want it to have a real title.

Hosting

Right now this is hosted on Github Pages. I will probably change that pretty soon because Github doesn’t you publish a pages site from a private repository unless you pay for Github Pro (and after you go private it just silently break).

Github is providing free hosting so its hard to be tooooo upset but it’s frustrating that this feature is gated behind a package I mostly won’t use.

Linux Annoyances

I’m still getting used to Linux as my main working computer. It feels strange that so much of my muscle memory isn’t working. A couple of things I will need to figure out:

  • 🏆 I need to rebind caps lock to escape This is making everything harder
  • I need to figure out VSCode keybindings. I’m used to <ctrl>+a going to the start of a line <ctrl>+e going to the end of a line and <ctrl>+k deleting the line and putting it into a buffer. None of that works in VSCode on Linux because ctrl is kind of the command key.

Caps lock to escape

Oh my gosssshhhhh this was a struggle to get working. In the end I’m using keyd with a config that looks like:

[ids]

*

[main]

# Maps capslock to escape when pressed and control when held.
capslock = esc

This was NOT my first choice. Running an extra program feels like a lot? Here’s a list of things that did not work

  • Putting config in .xinitrc to do the remapping:
xmodmap -e "clear lock"
xmodmap -e "keycode 9 = Caps_Lock NoSymbol Caps_Lock"
xmodmap -e "keycode 66 = Escape NoSymbol Escape"
  • Writing a script that does the same thing as above but putting it in a “Application Autostart” in XFCE
  • Remapping the keyboard symbols in /usr/share/X11/xkb/symbols
  • I wasn’t able to figure out what Option would do it in etc/X11/xorg.conf.d/00-keyboard.conf

Setup for Creative Coding

Some of my batch-mates are excited about creative coding and I am too.

First Sketch

This is my first sketch- hello and it’s just playing with p5.js. I haven’t started working through the book yet.

Undo Project

I didn’t make any progress on the undo project today.

End of Day summary

Quick Summary:

Notebook page for today: https://notes.nicole.computer/daily/2024-11-05

Tomorrow

  • First day in the office
  • Pairing for at least an hour with one of my batch mates
  • Get “Hello world” done for Undo project and published somewhere (probably paint.nicole.computer)