Notes on enginering leadership and software development.

Daily Notes

Quick notes on things I learned that day. Mostly coding, and some a-ha moment in working with people, or tricks to get projects done on time.

  • December 2nd:

    Advent of Code 2023, in Swift!

    There's a reason you stick with Python for Leetcode-style problems. And yet, I was itching to learn more Swift, so I'll do Advent of Code this year. In Swift!

    Here's the repo.

  • November 29th:

    Next.js is smart about what port to start on, and it's very cool!

    I won't take the prize on the biggest fan of Next.js competition, but I just noticed a thing!

    ~/src/respawn-io main *6 !1 ?1  next dev
      Port 3000 is in use, trying 3001 instead.
    Contentlayer config change detected. Updating type definitions and data...
       Next.js 13.5.4
      - Local:        http://localhost:3001
      - Environments: .env.local
     
      Ready in 6.7s
    ~/src/respawn-io main *6 !1 ?1  next dev
      Port 3000 is in use, trying 3001 instead.
    Contentlayer config change detected. Updating type definitions and data...
       Next.js 13.5.4
      - Local:        http://localhost:3001
      - Environments: .env.local
     
      Ready in 6.7s

    If you start your Next app with next dev, but your default port 3000 is already taken, it'll just gracefully start on 3001, saving you a few minutes of stopping whatever was there. This is so cool! 👏🏼

  • November 24th:

    self.❨╯°□°❩╯︵┻━┻

    I was working on a bringing Crons support for sidekiq-scheduler in sentry-ruby a couple days back, and found this gem of a method.

    Turns out, Sidekiq had the table flip method for a while, but the tech bro debauchery got replaced with zen and calmness.

  • November 19th:

    Contentlayer supports markdown and even MDX formatting in the frontmatter fields of your documents, as long as you specify the field type as mdx or markdown.

    The tricky part is that:

    • markdown fields give you raw HTML code. You'd have to wrap it in __dangerouslySetHTML or something.
    • mdx gives you the code that you have to pass into useMDXComponent to render.
    • Either way, you have to decide where to allow markdown formatting and where to strip it.

    I've just implemented it for the blog here:

    • Posts lists gets new PostDescription component that renders MDX-processed post description.
    • Post metadata and RSS gets raw description, implemented in a little custom field on Contentlayer that strips formatting.
  • July 18th:

    TIL there are beforeprint and afterprint events on window in Javascript, so you can manipulate the DOM to make the print version look nicer beyond what you can do with print styles in CSS.

    Especially helpful to hide a 3rd-party iframe (in our case, Intercom widget) that otherwise caused the printed page to overflow horizontally.

  • July 17th:

    Lattice supports keyboard shortcuts! Try ⌘+K, it's magic. So cool to be able to jump to a person (and the 1:1 logs and agenda items) instead of looking for them in the sidebar. Thank you, Lattice FE team! 💛️

  • July 7th:

    If you use sign your git commits, and then rebase a pull request with your commits in GitHub GUI, it drops the signature from the rebased commits, and they'll have unverified badge on them.

  • July 6th:

    SymbolKit has a nice little command line utility that takes several symbols.json for multuple modules as inputs, and combines them into a chonkier symbols.json, so that later Swift DocC can resolve `` links in DocC comments between symbols in those separate module graphs.

  • July 3rd:

    There are multiple things called tsx in js world. WAT.

    Turns out, modern frontend people have two things called tsx. One is just for the Typescript + components file format. The other one is for this little library that makes Node play somewhat nice with ESM.

    I've long wanted to move the RSS generator into a script, tried a few times, and it always hurt. Of course it hurt this time, too.