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.
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
about "telescopic" content https://essays.georgestrakhov.com/telescopic-content/ (source, permalink)
(today I learned) about “telescopic” content https://essays.georgestrakhov.com/telescopic-content/
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
Node can run Typescript files now (permalink)
It’s possible since a while with
--experimental-strip-typesflag, 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!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)Rob Pike's 5 Rules of Programming (source, permalink)
- 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.
- Measure. Don’t tune for speed until you’ve measured, and even then don’t unless one part of the code overwhelms the rest.
- 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.)
- Fancy algorithms are buggier than simple ones, and they’re much harder to implement. Use simple algorithms as well as simple data structures.
- 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”.
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
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 theno-focussed-testslinter rule in eslint-plugin-jest.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()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(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
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/*).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 🤔
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
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
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/
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.
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
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
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