Skip to content

Instantly share code, notes, and snippets.

Avatar

jakub-g jakub-g

  • Antibes, France
  • 03:08 (UTC +02:00)
View GitHub Profile
@jakub-g
jakub-g / README.md
Last active November 25, 2022 19:35
Karabiner-Elements: Remap cmd-capslock to cmd-backtick(tilde) (Switch window within an app)
View README.md

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
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
View jq-bash-vs-zsh.txt
$ jq --version
jq-1.6
---
bash-3.2$ jq --null-input --compact-output --raw-output --monochrome-output --arg test 'A\nB' '{test: $test}'
{"test":"A\\nB"}
bash-3.2$ OUT=$(jq --null-input --compact-output --raw-output --monochrome-output --arg test 'A\nB' '{test: $test}'); echo $OUT
{"test":"A\\nB"}
@jakub-g
jakub-g / README.md
Last active September 30, 2022 19:32
Make Firefox on MacOS trust CA certificates from system keychain
View README.md

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
bash firefox_enable_enterprise_roots_macos.sh
@jakub-g
jakub-g / git-log-examples.sh
Last active November 18, 2021 15:30
git log examples
View git-log-examples.sh
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 noreply@github.com
@jakub-g
jakub-g / analyze-trace.mjs
Created November 17, 2021 15:50
analyze-tsc-trace-longest-checkSourceFile
View analyze-trace.mjs
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
jakub-g / macos-energy-drains.md
Last active September 24, 2022 10:21
macos big sur disable all energy drains - MacBookPro 2020
View macos-energy-drains.md

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
jakub-g / vscode.md
Last active November 11, 2021 14:49
vscode mac shortcuts
View vscode.md
Action Shortcut
Show hover infobox cmd-k,cmd-i
@jakub-g
jakub-g / javascript-to-typescript-cheatsheet.md
Last active July 29, 2022 12:58
Migrate/convert JavaScript to TypeScript cheatsheet
View javascript-to-typescript-cheatsheet.md

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.
@jakub-g
jakub-g / wpt_wishlist.md
Last active March 24, 2021 15:39
WebPageTest wishlist 2021
View wpt_wishlist.md

0. Filmstrip page

  • There's no link back to waterfall page
  • Custom end time URL param is not validated. I can put -e:99 and will have 99s worth of filmstrip images (while the test was shorter than that)

1. Re-run the test equivalent which allows changing config

Sometimes I have very elaborate test config which I want to reuse, but slightly change one thing (e.g. add one param to URL). I can easily re-run the test with exact same config, but it's not easy to slightly change config and re-run. You need to re-create the config from scratch by checking multiple checkboxes, and hoping you come up with same exact set of params as before

@jakub-g
jakub-g / intro.md
Last active March 11, 2021 00:18
preact-redux: where can `props` come from
View intro.md
import { compose } from 'redux'
import { connect } from 'react-redux'

compose

compose(func1, func2, func3, func4) === func1(func2(func3(func4))))