Skip to content

Instantly share code, notes, and snippets.

View jakub-g's full-sized avatar

jakub-g jakub-g

  • Antibes, France
  • 11:35 (UTC +02:00)
View GitHub Profile
jakub-g /
Last active January 17, 2024 16:57
Microsoft Sculpt Ergonomic Keyboard x MacOS x Karabiner settings
jakub-g / md5-nodejs.js
Created October 26, 2023 12:43
md5 nodejs
let md5 = str => require('crypto').createHash('md5').update(str).digest("hex")
jakub-g /
Last active November 25, 2022 19:35
Karabiner-Elements: Remap cmd-capslock to cmd-backtick(tilde) (Switch window within an app)

What this rule does

On MacOS, cmd-tab only toggles between different apps. To toggle between different windows of the same app, you need to use cmd-` . However this is cumbersome for regular usage, as it requires stretching your fingers unnaturally. This rule allows to use cmd-CapsLock instead, which is much easier.

To enable the rule

  • Install Karabiner Elements and give it all permissions it asks for
  • cd ~/.config/karabiner/assets/complex_modifications and put the json file below there
  • Restart Karabiner Elements
  • Go to "Complex Modifications > Add rule"
jakub-g / jq-bash-vs-zsh.txt
Last active September 29, 2022 16:41
jq JSON with newlines output formatting madness - bash vs zsh discrepancy
$ jq --version
bash-3.2$ jq --null-input --compact-output --raw-output --monochrome-output --arg test 'A\nB' '{test: $test}'
bash-3.2$ OUT=$(jq --null-input --compact-output --raw-output --monochrome-output --arg test 'A\nB' '{test: $test}'); echo $OUT
jakub-g /
Last active June 6, 2023 16:39
Make Firefox on MacOS trust CA certificates from system keychain

Add a self-signed TLS certificate to MacOS system keychain, and make Firefox trust it

Tested on MacOS 11.6.4

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $FILENAME.crt
jakub-g /
Last active November 18, 2021 15:30
git log examples
git log --since="27 SEP 2021" --until="28 SEP 2021" --pretty='%ci %h %s %cn %ce ' | grep 'Merge pull'
# 2021-09-27 19:22:53 +0200 2bd0ea1b765 Merge pull request #123 from org/repo GitHub
jakub-g / analyze-trace.mjs
Created November 17, 2021 15:50
import * as fsp from 'fs/promises';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
// eslint-disable-next-line no-underscore-dangle
const __dirname = dirname(fileURLToPath(import.meta.url));
const dirNameLen = __dirname.length;
const file = await fsp.readFile('../trace.json');
const trace = JSON.parse(file);
jakub-g /
Last active September 24, 2022 10:21
macos big sur disable all energy drains - MacBookPro 2020

MacOS Big Sur MacBookPro 2020 disable energy drains

Disable settings that prevent the Mac from sleeping or let it wake up overnight in your backpack and drain half of battery.

On top of those, it's probably best to not leave any USB thing plugged to the Mac before putting it to sleep (including YubiKeys).

Enable hibernation (i.e. write to disk)

sudo pmset -a hibernatemode 25  
jakub-g /
Last active November 11, 2021 14:49
vscode mac shortcuts
Action Shortcut
Show hover infobox cmd-k,cmd-i
jakub-g /
Last active February 14, 2024 00:50
Migrate/convert JavaScript to TypeScript cheatsheet

Relevant official docs

Migrating NodeJS CJS files (require, module.exports)

First steps

  1. Rename the file from .js to .ts
  2. Change module.exports = to export =
  3. Change all exports.foobar = to export const foobar =
  4. Update top-level require calls to static import.