Today I Learned

This page contains short notes and sometimes code snippets, of interesting things I just found out. The notes with a source link were posted on Mastodon or Bluesky.

Entries can be opened by tapping/clicking them.

  1. www.frogans.org/en/main.html (source, permalink)
  2. the Apollo-Soyuz docking system is "androgynous", because neither the American nor the… (source, permalink)

    the Apollo-Soyuz docking system is “androgynous”, because neither the American nor the Russian wanted to be the “female” side. #space #patriarchy https://en.wikipedia.org/wiki/Androgynous_Peripheral_Attach_System

  3. about "telescopic" content https://essays.georgestrakhov.com/telescopic-content/ (source, permalink)

    (today I learned) about “telescopic” content https://essays.georgestrakhov.com/telescopic-content/

  4. Text that is garbled, because the wrong encoding is used, is called "Mojibake"… (source, permalink)

    (today I learned) Text that is garbled, because the wrong encoding is used, is called “Mojibake”. https://en.wikipedia.org/wiki/Mojibake

  5. Node can run Typescript files now (permalink)

    It’s possible since a while with --experimental-strip-types flag, but since Node v22.18 it is possible just like this under many circumstances. Check the official docs on how to run typescript natively to learn more!

  6. Javascript's Array.from is neat! (permalink)

    Because it simply executes a function arg1.length times, one can do things like:

    const randomNumbers = Array.from({ length: 75 }, Math.random)
  7. Reading speed is 238 words per minute on average (source, permalink)

    And speech time averages at 183 wpm.

  8. Sort list of strings in Javascript (source, permalink)
    users.sort((a, b) => a.firstname.localeCompare(b.firstname))

    or reversed order:

    users.sort((a, b) => a.firstname.localeCompare(b.firstname) * -1)
  9. Rob Pike's 5 Rules of Programming (source, permalink)
    1. You can’t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don’t try to second guess and put in a speed hack until you’ve proven that’s where the bottleneck is.
    2. Measure. Don’t tune for speed until you’ve measured, and even then don’t unless one part of the code overwhelms the rest.
    3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don’t get fancy. (Even if n does get big, use Rule 2 first.)
    4. Fancy algorithms are buggier than simple ones, and they’re much harder to implement. Use simple algorithms as well as simple data structures.
    5. Data dominates. If you’ve chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.

    Pike’s rules 1 and 2 restate Tony Hoare’s famous maxim “Premature optimization is the root of all evil.” Ken Thompson rephrased Pike’s rules 3 and 4 as “When in doubt, use brute force.”. Rules 3 and 4 are instances of the design philosophy KISS. Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to “write stupid code that uses smart objects”.

  10. Today I learned, that the toilet paper holder was invented in 1982, one hundred years… (source, permalink)

    Today I learned, that the toilet paper holder was invented in 1982, one hundred years after the invention of the automatic dishwasher?! Both invented by smart women, despite a world of men trying to stop them from living to their potential. #TIL #womenshistory

  11. Right after that, I also learned, that Mastodon 4.0 explicitly warns you about missing… (source, permalink)

    Right after that, I also learned, that Mastodon 4.0 explicitly warns you about missing alt-text. Great! #til

  12. that #Rust warnings have gotten so much better since the last time I looked into it! (source, permalink)

    that #Rust warnings have gotten so much better since the last time I looked into it!

  13. https://css-tricks.com/named-element-ids-can-be-referenced-as-javascript-globals/ (source, permalink)
  14. Disallowed Focussed Tests and how it saved my day (permalink)

    Today I was about to push a focussed test. A focussed test, you ask?

    In Jest (and others) one can run only a specific test, by writing it.only(.... Pushing this to production might create some funny or not so funny side effects though. Luckily there is the no-focussed-tests linter rule in eslint-plugin-jest.

  15. Jest mocks are ...different (permalink)

    If you want to mock an imported function in Jest in a way that allows you to check if it has been called, you can not do the seemingly straighforward:

    // mock prefix necessary btw
    const mockThatFunction = jest.fn(() => 'stuff')
    
    jest.mock('@/path/to/module', () => ({
      thatFunction: mockThatFunction,
    }))
    
    // ...in test descriptions
    expect(mockThatFunction).toHaveBeenCalled()

    This way thatFunction will be undefined without anyone telling you why.

    What you need to do instead:

    import { thatFunction } from '@/path/to/module'
    
    jest.mock('@/path/to/module', () => ({
      thatFunction: jest.fn(() => 'stuff'),
    }))
    
    // ...in test descriptions
    expect(thatFunction).toHaveBeenCalled()
  16. pwdx command shows the working path of a process (source, permalink)

    For example:

    % pwdx 1984
    > 1984: /home/george/ttlctrl
  17. There is a file system for EFI vars now (source, permalink)

    On kernel updates I saw a recurring “EFI variables are not supported on this system”, so I investigated and learned that the new EFI variables are provided via a file system that needs to be mounted first:

    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
  18. (actually yesterday) how crazy multiplication algorithms have become… (source, permalink)

    (actually yesterday) how crazy multiplication algorithms have become: https://en.wikipedia.org/wiki/F%C3%BCrer%27s_algorithm#Improved_algorithms

  19. Adding aliases in vite with typescript needs the same alias in tsconfig (permalink)

    For example:

    The following vite.config.ts:

    import { fileURLToPath, URL } from "url"
    import { defineConfig } from 'vite'
    import vue from '@vitejs/plugin-vue'
    
    // https://vitejs.dev/config/
    export default defineConfig({
      plugins: [vue()],
      resolve: {
        alias: {
          "~": fileURLToPath(new URL("./src", import.meta.url)),
          "~component": fileURLToPath(new URL("./src/components", import.meta.url)),
          "~composable": fileURLToPath(new URL("./src/composables", import.meta.url)),
          "~lib": fileURLToPath(new URL("./src/lib", import.meta.url)),
        }
      }
    })

    will need this in tsconfig.json:

    {
      "compilerOptions": {
        "paths": {
          "~/*": [ "./src/*" ],
          "~component/*": [ "./src/components/*" ],
          "~composable/*": [ "./src/composables/*" ],
          "~lib/*": [ "./src/lib/*" ]
        }
      }
    }

    The asterixes in the syntax are important (alias/* => ./path/*).

  20. Die @wasserbetriebe haben eine ungeschützte API um für beliebige Wasserzähler-Nummern die… (source, permalink)

    RT @schmidtwisser

    Die @wasserbetriebe haben eine ungeschützte API um für beliebige Wasserzähler-Nummern die hinterlegten Adressen und letzten Zählerstände abzurufen.

    Bin aber nicht sicher, ob das so gewollt ist 🤔

  21. A TIL by @yov_jakie (source, permalink)

    RT @yov_jakie

  22. E-Mail that isn't spam is called ham! (source, permalink)
  23. git fetch repo_url remote_branch:new_local_branch (source, permalink)

    git fetch $repo_url $remote_branch:$new_local_branch

  24. Bush refused offer to discuss Osama Bin Laden handover (source, permalink)
  25. There is a HTML tag for "Word Break Opportunity" (source, permalink)

    For example: Kauf<wbr/>haus.

  26. that in #Vue3 it makes a difference if you register a component in kebab-case or… (source, permalink)

    that in #Vue3 it makes a difference if you register a component in kebab-case or PascalCase. https://v3.vuejs.org/guide/component-registration.html#name-casing

  27. that in #JavaScript primitve objects are always coerced into their Object counterparts… (source, permalink)

    that in #JavaScript primitve objects are always coerced into their Object counterparts when accessing any their prototype methods. https://es5.github.io/#x8.7.1 #makejavascriptweirdagain

  28. that there's the plan to bring the @midoribrowser to the next level (including mobile)… (source, permalink)

    that there’s the plan to bring the @midoribrowser to the next level (including mobile) https://astian.org/en/

  29. there is a style guide for #Vuejs describing in which order to put component methods… (source, permalink)

    there is a style guide for #Vuejs describing in which order to put component methods: https://v3.vuejs.org/style-guide/#directive-shorthands-strongly-recommended and even an eslint-plugin for it.

  30. ip-tools (the ip command in Linux) set a useless bitmask by default when manually setting… (source, permalink)

    ip-tools (the ip command in Linux) set a useless bitmask by default when manually setting an interface address. Eg 192.168.1.1 will be set as 192.168.1.1/32 which wouldn’t allow any other node in the subnet. Therefore it is necessary to explicitly set 192.168.1.1/24

  31. https://www.man7.org/linux/man-pages/man5/machine-id.5.html and I don't think that is a… (source, permalink)

    https://www.man7.org/linux/man-pages/man5/machine-id.5.html and I don’t think that is a good thing. #wtf

  32. that while viewing a file with less you can simply press v to open it in your editor (v… (source, permalink)

    that while viewing a file with less you can simply press v to open it in your editor (v for visual, uses $VISUAL, $EDITOR or ‘vi’). My life just got a tad smoother.

  33. that, if you send large inline attachments to a #gmail account, they can be bigger than… (source, permalink)

    that, if you send large inline attachments to a #gmail account, they can be bigger than the size limit you can send. Then, in the web interface, you’re getting a popup(!) every few seconds, telling you your mail is too large to be saved, while writing a reply. #notfun

  34. Google has a synonym operator ~ If you want to find results that must contain a synonym… (source, permalink)

    RT @mihar@twitter.activitypub.actor

    Google has a synonym operator ~

    If you want to find results that must contain a synonym of, say, sporadic, you could search for:

    postgres “~sporadic” error 123

  35. that the Read implementation for TcpStream in #Rust only reads two bytes at a time and… (source, permalink)

    that the Read implementation for TcpStream in #Rust only reads two bytes at a time and read_to_string is like read_to_end, so it waits for EOF. There is no read_line.