From 7ad81f33c36b5c23a80204ff76a0a78cf698ce88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6hring?= Date: Sun, 12 May 2024 20:15:27 +0200 Subject: [PATCH] add now and til pages --- bin/til.ts | 58 +++++++++++++++ dist/extended.css | 73 ++++++------------- dist/index.html | 2 +- dist/now/index.html | 99 ++++++++++++++++++++++++++ dist/style.css | 4 +- dist/til.css | 15 ++++ dist/til/2021-08-31.html | 83 ++++++++++++++++++++++ dist/til/2021-09-03.html | 82 +++++++++++++++++++++ dist/til/2021-09-04.html | 82 +++++++++++++++++++++ dist/til/2021-09-05.html | 82 +++++++++++++++++++++ dist/til/2022-02-22.html | 113 +++++++++++++++++++++++++++++ dist/til/2022-03-22.html | 85 ++++++++++++++++++++++ dist/til/2022-03-28.html | 86 ++++++++++++++++++++++ dist/til/2022-04-25.html | 103 +++++++++++++++++++++++++++ dist/til/2022-06-15.html | 83 ++++++++++++++++++++++ dist/til/2024-05-12.html | 87 +++++++++++++++++++++++ dist/til/index.html | 150 +++++++++++++++++++++++++++++++++++++++ layouts/index.html | 2 +- layouts/now/index.html | 79 +++++++++++++++++++++ layouts/til/index.html | 81 +++++++++++++++++++++ now/index.md | 24 +++++++ static/extended.css | 29 ++++++++ static/style.css | 4 +- static/til.css | 15 ++++ til/2021-08-31.md | 5 ++ til/2021-09-03.md | 3 + til/2021-09-04.md | 3 + til/2021-09-05.md | 3 + til/2022-02-22.md | 41 +++++++++++ til/2022-03-22.md | 9 +++ til/2022-03-28.md | 10 +++ til/2022-04-25.md | 30 ++++++++ til/2022-06-15.md | 5 ++ til/2024-05-12.md | 13 ++++ til/index.md | 79 +++++++++++++++++++++ 35 files changed, 1665 insertions(+), 57 deletions(-) create mode 100644 bin/til.ts create mode 100644 dist/now/index.html create mode 100644 dist/til.css create mode 100644 dist/til/2021-08-31.html create mode 100644 dist/til/2021-09-03.html create mode 100644 dist/til/2021-09-04.html create mode 100644 dist/til/2021-09-05.html create mode 100644 dist/til/2022-02-22.html create mode 100644 dist/til/2022-03-22.html create mode 100644 dist/til/2022-03-28.html create mode 100644 dist/til/2022-04-25.html create mode 100644 dist/til/2022-06-15.html create mode 100644 dist/til/2024-05-12.html create mode 100644 dist/til/index.html create mode 100644 layouts/now/index.html create mode 100644 layouts/til/index.html create mode 100644 now/index.md create mode 100644 static/extended.css create mode 100644 static/til.css create mode 100644 til/2021-08-31.md create mode 100644 til/2021-09-03.md create mode 100644 til/2021-09-04.md create mode 100644 til/2021-09-05.md create mode 100644 til/2022-02-22.md create mode 100644 til/2022-03-22.md create mode 100644 til/2022-03-28.md create mode 100644 til/2022-04-25.md create mode 100644 til/2022-06-15.md create mode 100644 til/2024-05-12.md create mode 100644 til/index.md diff --git a/bin/til.ts b/bin/til.ts new file mode 100644 index 0000000..074ccc1 --- /dev/null +++ b/bin/til.ts @@ -0,0 +1,58 @@ +#!/bin/env deno run + +import { globber } from "https://deno.land/x/globber@0.1.0/mod.ts" + +interface FileIndex { + title: string + source: string + date: string +} + +const cwd = './til/' +const outputPath = './til/index.md' + +const fileIndex: FileIndex[] = [] + +const fileIter = globber({ cwd, include: ["????-??-??.md"] }) +const decoder = new TextDecoder('utf-8') +const encoder = new TextEncoder() +const template = `
+ +
+ %TITLE% + (source) +
+
+` + +function render(fi: FileIndex) { + return template + .replaceAll('%DATE%', fi.date) + .replaceAll('%SOURCE%', fi.source) + .replaceAll('%TITLE%', fi.title) +} + +for await (const file of fileIter) { + if (file.isDirectory) { + console.log('ignoring directory', file.relative) + break + } + + const path = file.absolute + const date = file.relative.slice(0, -3) + + const raw = await Deno.readFile(path) + const lines = decoder.decode(raw).split('\n') + + const title = lines[0].slice(2) + const source = lines[2].startsWith('[source](') ? lines[2].slice(9, -1) : '#' + + fileIndex.push({ title, source, date }) +} + +const output = fileIndex +.sort((a, b) => a.date.localeCompare(b.date) * -1) +.map(render) +.join('\n') + +Deno.writeFile(outputPath, encoder.encode(output)) diff --git a/dist/extended.css b/dist/extended.css index 5199151..8ce0472 100644 --- a/dist/extended.css +++ b/dist/extended.css @@ -1,62 +1,29 @@ -#header-tilde, -#header-bracket, -#header-underscore { - fill: var(--highlight-fg-color); -} - -#header-k, -#header-o, -#header-e, -#header-h, -#header-r { - fill: var(--header-fg-color); -} - -#header-underscore { - animation: fade 2s linear infinite; -} - -@keyframes fade { - 0% { - opacity: 1.0; - } - - 50% { - opacity: 0.0; - } - - 60% { - opacity: 0.0; - } - - 80% { - opacity: 1.0; - } - - 100% { - opacity: 1.0; - } -} - #main-menu { + position: fixed; + top: var(--header-height); + width: 100vw; + height: 1.2rem; margin: 0; padding: 0; display: flex; - gap: 2em; - list-style: none; justify-content: center; + align-items: center; + gap: 4rem; + list-style: circle; + background: var(--menu-bg-color); + transition: top .3s ease-in-out; } - -body>header:not(.small) + #main-menu { - position: fixed; - color: red; - top: var(--header-height); - height: 1.2em; - width: 100vw; - padding: .1em 0; - background: black; +#main-menu > li { + padding: 0; } body>header.small + #main-menu { - color: green; - margin: 2em 0; + top: calc(var(--header-height) * var(--header-multiplier)); +} +pre { + background: var(--emboss-color); + padding: .5rem; +} +li.active>a { + color: var(--highlight-fg-color); + font-weight: bold; } diff --git a/dist/index.html b/dist/index.html index a6228a6..aed241c 100644 --- a/dist/index.html +++ b/dist/index.html @@ -147,7 +147,7 @@ + diff --git a/dist/style.css b/dist/style.css index 422eea4..1ad41bf 100644 --- a/dist/style.css +++ b/dist/style.css @@ -5,6 +5,7 @@ --header-multiplier: .25; --page-bg-color: #232425; --page-fg-color: #7e9fbe; + --menu-bg-color: #000; --highlight-fg-color: #eacb8b; --emboss-color: #000; } @@ -21,6 +22,7 @@ :root { --page-bg-color: #efe9d9; --page-fg-color: #261b00; + --menu-bg-color: #fff; --header-fg-color: #143373; --header-bg-color: #a49570; --emboss-color: #fff; @@ -208,4 +210,4 @@ blockquote { 100% { opacity: 1.0; } -} \ No newline at end of file +} diff --git a/dist/til.css b/dist/til.css new file mode 100644 index 0000000..fd532b5 --- /dev/null +++ b/dist/til.css @@ -0,0 +1,15 @@ +main#til > header { + margin: 0 0 2rem 0; + font-size: 1.5em; +} + +article.til { + margin: 1rem 0; +} +article.til>div { + line-height: 2; +} +article.til>time, +article.til>div>a.external { + color: gray; +} diff --git a/dist/til/2021-08-31.html b/dist/til/2021-08-31.html new file mode 100644 index 0000000..bac7854 --- /dev/null +++ b/dist/til/2021-08-31.html @@ -0,0 +1,83 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
TIL -- Today I learned
+ +

There is a HTML tag for "Word Break Opportunity"

+

source

+

For example: Kauf<wbr/>haus.

+ + back +
+
+ + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2021-09-03.html b/dist/til/2021-09-03.html new file mode 100644 index 0000000..f49f50a --- /dev/null +++ b/dist/til/2021-09-03.html @@ -0,0 +1,82 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    Bush refused offer to discuss Osama Bin Laden handover

    +

    source

    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2021-09-04.html b/dist/til/2021-09-04.html new file mode 100644 index 0000000..b00106a --- /dev/null +++ b/dist/til/2021-09-04.html @@ -0,0 +1,82 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    git fetch $repo_url $remote_branch:$new_local_branch

    +

    source

    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2021-09-05.html b/dist/til/2021-09-05.html new file mode 100644 index 0000000..d05895a --- /dev/null +++ b/dist/til/2021-09-05.html @@ -0,0 +1,82 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    E-Mail that isn't spam is called ham!

    +

    source

    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2022-02-22.html b/dist/til/2022-02-22.html new file mode 100644 index 0000000..82c8dd4 --- /dev/null +++ b/dist/til/2022-02-22.html @@ -0,0 +1,113 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    Adding aliases in vite with typescript needs the same alias in tsconfig

    +

    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/*).

    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2022-03-22.html b/dist/til/2022-03-22.html new file mode 100644 index 0000000..40f6580 --- /dev/null +++ b/dist/til/2022-03-22.html @@ -0,0 +1,85 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    There is a file system for EFI vars now

    +

    source

    +

    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
    +
    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2022-03-28.html b/dist/til/2022-03-28.html new file mode 100644 index 0000000..d6645b7 --- /dev/null +++ b/dist/til/2022-03-28.html @@ -0,0 +1,86 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    pwdx command shows the working path of a process

    +

    source

    +

    For example:

    +
    % pwdx 1984
    +> 1984: /home/george/ttlctrl
    +
    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2022-04-25.html b/dist/til/2022-04-25.html new file mode 100644 index 0000000..a386bdf --- /dev/null +++ b/dist/til/2022-04-25.html @@ -0,0 +1,103 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    Jest mocks are ...different

    +

    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()
    +
    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2022-06-15.html b/dist/til/2022-06-15.html new file mode 100644 index 0000000..3f6ce8b --- /dev/null +++ b/dist/til/2022-06-15.html @@ -0,0 +1,83 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    Disallowed Focussed Tests and how it saved my day

    +

    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.

    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/2024-05-12.html b/dist/til/2024-05-12.html new file mode 100644 index 0000000..e2931f2 --- /dev/null +++ b/dist/til/2024-05-12.html @@ -0,0 +1,87 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + +

    Sort list of strings in Javascript

    +

    source

    +
    users.sort((a, b) => a.firstname.localeCompare(b.firstname))
    +
    +

    or reversed order:

    +
    users.sort((a, b) => a.firstname.localeCompare(b.firstname) * -1)
    +
    + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/dist/til/index.html b/dist/til/index.html new file mode 100644 index 0000000..f33dfda --- /dev/null +++ b/dist/til/index.html @@ -0,0 +1,150 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + + + + + + + + + + + + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/layouts/index.html b/layouts/index.html index 32fd028..37edb94 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -119,7 +119,7 @@ + diff --git a/layouts/til/index.html b/layouts/til/index.html new file mode 100644 index 0000000..10b4451 --- /dev/null +++ b/layouts/til/index.html @@ -0,0 +1,81 @@ + + + + + + + Today I learned // the codeartist — programmer and engineer based in Berlin + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    TIL -- Today I learned
    + + @contents + + back +
    +
    + + +
  • home
  • +
  • /now
  • +
  • /til
  • +
  • /projects
  • +
  • /blog
  • +
  • /cv
  • +
  • /stack
  • +
  • /setup
  • +
    + + + + diff --git a/now/index.md b/now/index.md new file mode 100644 index 0000000..76b0934 --- /dev/null +++ b/now/index.md @@ -0,0 +1,24 @@ +*This page shows what I'm up to at the moment, following the idea of the [/now page](https://sive.rs/nowff) introduced by [Derek Sivers](https://sive.rs/). You can find more now pages on [nownownow](https://nownownow.com/).* + +Last updated: 2024-05-12 + +## Priorities + +> I do a lot of things all the time and have a hard time to focus. Most of my energy right now hopefully flows into the following things: + +* This homepage. +* Keeping up the pace professionally by taking up more management responsibilities. +* Fleshing out a long form D&D campaign ("Out Of The Cold Shadow"). +* Writing down more short adventures and one-shots and publish them on [tiskifer.dk](https://tiskifer.dk). +* My wedding and honeymoon in June! + +## Book(s) + +> I'm not really good with taking time for reading, but when I do, I read: + +[Accelerando](https://openlibrary.org/works/OL2465670W/Accelerando) +by [Charles Stross](https://openlibrary.org/authors/OL343157A/Charles_Stross) + +[The Manager's Path](https://openlibrary.org/works/OL19860807W/The_Manager%27s_Path) +by [Camille Fournier](https://openlibrary.org/authors/OL7564045A/Camille_Fournier) + diff --git a/static/extended.css b/static/extended.css new file mode 100644 index 0000000..8ce0472 --- /dev/null +++ b/static/extended.css @@ -0,0 +1,29 @@ +#main-menu { + position: fixed; + top: var(--header-height); + width: 100vw; + height: 1.2rem; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + gap: 4rem; + list-style: circle; + background: var(--menu-bg-color); + transition: top .3s ease-in-out; +} +#main-menu > li { + padding: 0; +} +body>header.small + #main-menu { + top: calc(var(--header-height) * var(--header-multiplier)); +} +pre { + background: var(--emboss-color); + padding: .5rem; +} +li.active>a { + color: var(--highlight-fg-color); + font-weight: bold; +} diff --git a/static/style.css b/static/style.css index 422eea4..1ad41bf 100644 --- a/static/style.css +++ b/static/style.css @@ -5,6 +5,7 @@ --header-multiplier: .25; --page-bg-color: #232425; --page-fg-color: #7e9fbe; + --menu-bg-color: #000; --highlight-fg-color: #eacb8b; --emboss-color: #000; } @@ -21,6 +22,7 @@ :root { --page-bg-color: #efe9d9; --page-fg-color: #261b00; + --menu-bg-color: #fff; --header-fg-color: #143373; --header-bg-color: #a49570; --emboss-color: #fff; @@ -208,4 +210,4 @@ blockquote { 100% { opacity: 1.0; } -} \ No newline at end of file +} diff --git a/static/til.css b/static/til.css new file mode 100644 index 0000000..fd532b5 --- /dev/null +++ b/static/til.css @@ -0,0 +1,15 @@ +main#til > header { + margin: 0 0 2rem 0; + font-size: 1.5em; +} + +article.til { + margin: 1rem 0; +} +article.til>div { + line-height: 2; +} +article.til>time, +article.til>div>a.external { + color: gray; +} diff --git a/til/2021-08-31.md b/til/2021-08-31.md new file mode 100644 index 0000000..2c775fd --- /dev/null +++ b/til/2021-08-31.md @@ -0,0 +1,5 @@ +# There is a HTML tag for "Word Break Opportunity" + +[source](https://www.w3schools.com/TAGS/tag_wbr.asp) + +For example: `Kaufhaus`. diff --git a/til/2021-09-03.md b/til/2021-09-03.md new file mode 100644 index 0000000..9008aef --- /dev/null +++ b/til/2021-09-03.md @@ -0,0 +1,3 @@ +# Bush refused offer to discuss Osama Bin Laden handover + +[source](https://www.theguardian.com/world/2001/oct/14/afghanistan.terrorism5) diff --git a/til/2021-09-04.md b/til/2021-09-04.md new file mode 100644 index 0000000..f775578 --- /dev/null +++ b/til/2021-09-04.md @@ -0,0 +1,3 @@ +`git fetch $repo_url $remote_branch:$new_local_branch` + +[source](https://twitter.com/lucas59356/status/1433507127570669569) diff --git a/til/2021-09-05.md b/til/2021-09-05.md new file mode 100644 index 0000000..d0413dd --- /dev/null +++ b/til/2021-09-05.md @@ -0,0 +1,3 @@ +# E-Mail that isn't spam is called ham! + +[source](https://twitter.com/claranellist/status/1433539284779220997) diff --git a/til/2022-02-22.md b/til/2022-02-22.md new file mode 100644 index 0000000..a730cdc --- /dev/null +++ b/til/2022-02-22.md @@ -0,0 +1,41 @@ +# Adding aliases in vite with typescript needs the same alias in tsconfig + +For example: + +The following vite.config.ts: + +```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: + +```json +{ + "compilerOptions": { + "paths": { + "~/*": [ "./src/*" ], + "~component/*": [ "./src/components/*" ], + "~composable/*": [ "./src/composables/*" ], + "~lib/*": [ "./src/lib/*" ] + } + } +} +``` + +The asterixes in the syntax are important (`alias/*` => `./path/*`). diff --git a/til/2022-03-22.md b/til/2022-03-22.md new file mode 100644 index 0000000..5131e51 --- /dev/null +++ b/til/2022-03-22.md @@ -0,0 +1,9 @@ +# There is a file system for EFI vars now + +[source](https://www.kernel.org/doc/html/latest/filesystems/efivarfs.html) + +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: + +```sh +mount -t efivarfs efivarfs /sys/firmware/efi/efivars +``` diff --git a/til/2022-03-28.md b/til/2022-03-28.md new file mode 100644 index 0000000..aac9716 --- /dev/null +++ b/til/2022-03-28.md @@ -0,0 +1,10 @@ +# pwdx command shows the working path of a process + +[source](https://twitter.com/mani_maranp/status/1508476973529825281) + +For example: + +```sh +% pwdx 1984 +> 1984: /home/george/ttlctrl +``` diff --git a/til/2022-04-25.md b/til/2022-04-25.md new file mode 100644 index 0000000..cc6aae5 --- /dev/null +++ b/til/2022-04-25.md @@ -0,0 +1,30 @@ +# Jest mocks are ...different + +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: + +```js +// 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: + +```js +import { thatFunction } from '@/path/to/module' + +jest.mock('@/path/to/module', () => ({ + thatFunction: jest.fn(() => 'stuff'), +})) + +// ...in test descriptions +expect(thatFunction).toHaveBeenCalled() +``` diff --git a/til/2022-06-15.md b/til/2022-06-15.md new file mode 100644 index 0000000..339997a --- /dev/null +++ b/til/2022-06-15.md @@ -0,0 +1,5 @@ +# Disallowed Focussed Tests and how it saved my day + +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](https://github.com/jest-community/eslint-plugin-jest). diff --git a/til/2024-05-12.md b/til/2024-05-12.md new file mode 100644 index 0000000..37de2c8 --- /dev/null +++ b/til/2024-05-12.md @@ -0,0 +1,13 @@ +# Sort list of strings in Javascript + +[source](https://stackoverflow.com/questions/6712034/sort-array-by-firstname-alphabetically-in-javascript) + +```ts +users.sort((a, b) => a.firstname.localeCompare(b.firstname)) +``` + +or reversed order: + +```ts +users.sort((a, b) => a.firstname.localeCompare(b.firstname) * -1) +``` diff --git a/til/index.md b/til/index.md new file mode 100644 index 0000000..115cb0a --- /dev/null +++ b/til/index.md @@ -0,0 +1,79 @@ +
    + +
    + Sort list of strings in Javascript + (source) +
    +
    + +
    + +
    + Disallowed Focussed Tests and how it saved my day + (source) +
    +
    + +
    + +
    + Jest mocks are ...different + (source) +
    +
    + +
    + +
    + pwdx command shows the working path of a process + (source) +
    +
    + +
    + +
    + There is a file system for EFI vars now + (source) +
    +
    + +
    + +
    + Adding aliases in vite with typescript needs the same alias in tsconfig + (source) +
    +
    + +
    + +
    + E-Mail that isn't spam is called ham! + (source) +
    +
    + +
    + +
    + it fetch $repo_url $remote_branch:$new_local_branch` + (source) +
    +
    + +
    + +
    + Bush refused offer to discuss Osama Bin Laden handover + (source) +
    +
    + +
    + +
    + There is a HTML tag for "Word Break Opportunity" + (source) +
    +