QOTD

“Online we need to read things sincerely but not seriously” - @rpasetes

Creative Coding

Late night, making paint splatters and listening to Nala Sinephro - Endlessness:

This was to explore `randomGaussian`. I might play with this some more and use the mouse to let a creator throw more paint at the canvas by clicking on it.

Arduino Day

“If something can be played or worked, always play it” - @shenaichan

Setting up arduino

  1. Install the arduino software: yay arduino (Arch delights me that the command for getting software from the community is yay)
  2. Install the board software in arduino
  3. Give access to the serial port to the arduino software sudo chmod a+rw /dev/ttyACM0

First Sketch

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}
 
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(200);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(200);                      // wait for a second
}

This blinks the light on the board!

Simon

Circuit board with resistors, push buttons and LEDs sitting on a black desk

I worked on a little simon says game. I got buttons and lights wired but ran out of time to implement the game. Maybe next week.

Euler Problem

Today’s problem is “What is 10,001 prime number”. And my solution looks like this:

nthElement(primes(), 10_001)

Which I feel really happy about. The generator code for primes is the same that I’ve used in previous days:

function isPrime(n: number, knownPrimes: number[]): boolean {
    if (n == 2) {
        return true
    }
 
    for (const prime of knownPrimes) {
        if (n % prime == 0) {
            return false
        }
    }
 
    return true
}
 
function* primes() {
    yield 2
 
    const knownPrimes: number[] = [2]
    let currentNumber = 3
 
    while (true) {
        if (isPrime(currentNumber, knownPrimes)) {
            knownPrimes.push(currentNumber)
            yield currentNumber
        }
 
        currentNumber += 1
    }
}

The bit that I had to write as new was the nthElement function. I was careful to make sure it’s generic because I’ve noticed that functions I’ve written previous days have turned out to be useful later on:

function nthElement<T, TReturn, TNext>(generator: Generator<T, TReturn, TNext | undefined>, n: number): T | undefined {
    let index = 1;
 
    for (const val of generator) {
        if (index === n) {
            return val
        }
        index += 1
    }
 
    return undefined
}

I’m not quite certain on the generator’s type signature. I know the first value is the type that will come out of the generator. The next piece is the return value but the last one is fuzzy. One my prime generator its any and when I look at the interface for iterators (which generator is using), it looks like:

interface Generator<T = unknown, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
    // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
    next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
    return(value: TReturn): IteratorResult<T, TReturn>;
    throw(e: any): IteratorResult<T, TReturn>;
    [Symbol.iterator](): Generator<T, TReturn, TNext>;
}

Which I think means its being used as Next? But even when I follow the value all the way through I don’t quite understand.

Mouse Walker

This isn't quite there yet. The goal is to get the dot to "kind of" follow the mouse cursor. Kind of because the closer the mouse, the more it will follow.

Notes System

Dates

I noticed when my notes get published they were all getting marked as having been created on the same day. It looks like this is happening because I’m using git and building on a server somewhere. The filesystem says that the file was definitely created in the last 30 seconds before the page was built. There are a couple of ways to fix this in quartz but the easiest for me is to add a property to my yaml frontmatter with the date that a note was created. As long as I’m there I’m also adding a title with format that feels good me.

Templatermakes this pretty easy (and I’m super grateful that momentjs is included as part of templater):

---
tags:
  - recurse
publish: true
date: <% tp.file.title %>
title: <% moment(tp.file.title, "YYYY-MM-DD").format("MMMM Do, YYYY") %>
---

Images in published notes

I really wanted to be able to include images but couldn’t get quartz to publish them. This is what worked for me in the end:

  1. I set Obsidian to store all assets in a root folder called /assets/
  2. I installed obsidian image converter and set it to to resize images to a width of 2000 and to use markdown links

So now when I drag an image into my vault it gets converted into a smaller image and then when it publishes it seems to show up ok!

End of day

QOTD:

  • “Online we need to read things sincerely but not seriously”
  • “If something can be played or worked, always play it”

Worked on Today

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

Tomorrow

I need a small rest. I tried working late last night. I was excited and it felt right but today I’m sluggish and my brain isn’t fully there. I’m going to try resting tomorrow, maybe talking a walk in nature, riding the ferry of visiting the library, and see how I feel.

PS: I wasn’t on zullip at all today. I promise I didn’t miss your message, I just was busy in the hub.