Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / tech-interviews.md
Last active June 1, 2024 19:43
Interviewing for Jobs in Tech: a Reading List

Behavioral questions (aka "Tell me about a time when...")

@pesterhazy
pesterhazy / macos-setup.md
Last active January 25, 2024 15:39
Setting up macOS

This guide helps me set up my macOS laptop in a fairly simple manner. I'll need to go back to this guide roughly every 2–3 years. Maybe it'll help you, too!

Smart Caps Lock

Use Karabiner Elements

Map Caps Lock to Ctrl (when long-pressed) or Escape (when tapped). See this guide

Put backtick/tilde character to the left of 1 key

@pesterhazy
pesterhazy / .zshrc
Created November 13, 2023 15:26
ZSH: show current git branch on enter
# This prints the current git branch when you submit an empty
# line (i.e. press enter) in zsh
#
# Less distracting than adding it to your prompt, but still
# very easy to run.
git-status-on-enter () {
if [ ${#${(z)BUFFER}} -eq 0 ]; then
if git rev-parse --git-dir > /dev/null 2>&1 ; then
echo
@pesterhazy
pesterhazy / third-party-failures.md
Created November 2, 2023 12:58
HTTP endpoints and handling third party service failures

Let's say I'm building a backend endpoint /find-icon?q=apple as part of a large monolithic app. What it does is simply forward the request to a 3rd party service, FindIcon.com. Essentially it's a proxy except that it adds FindIcon.com API credentials.

What should this endpoint do in the case of an 400–599 status response from the 3rd party service? Specifically:

First, what status code should /find-icon return in case of a third-party error? Each class of codes seems to have downsides:

  • 20x hides the error from the client. For example, it doesn't show up in red in the browser tab, making debugging harder.
  • 40x seems semantically wrong, given that, according to the HTTP spec, "the 4xx (Client Error) class of status code indicates that the client seems to have erred".
  • 50x on the backend or Load Balancer typically causes backend alerts, which are set to trigger when X amount of 50x errors occur in a given time frame. This will cause an on-call incident, waking up people, which may or may not be what
@pesterhazy
pesterhazy / README.md
Last active October 10, 2023 16:25
Clojure: timing for namepsace loading

This is intended to help with profiling slow Clojure startup times:

  • Create a csv with start/end times for loading namespaces
  • Analyzer script that measures how long each namespace take (substracting time that's needed for loading its dependencies)

Requires building your own patched version of Clojure

Sample output (time in milliseconds):

@pesterhazy
pesterhazy / headers-wat.js
Last active July 6, 2023 19:15
JS Headers iteration wat
headers = new Headers([["a","A"],["b","B"]]);
headers.forEach((_,k) => headers.delete(k));
console.log([...headers].length);
// expected: 0
// actual: 1 (Chrome 114)
// actual: 1 (Bun.js v0.6.13)
// actual: 1 (Safari 16.4)
// actual: 0 (Node v18.12.1)
@pesterhazy
pesterhazy / ausfluege-in-berlin.md
Last active April 20, 2023 07:24
Ausflüge rund um Berlin
  • Liebnitzsee (Spazieren um den See, Strandbad, Fähre zur Insel mit Gasthof)
  • Bernsteinsee (See mit Karibikflair)
  • Chorin (Wandern, Seen, Kloster)
  • Buckow (Wandern)
  • Harz-Berlin-Express: Direktzug in 3h vom Alex nach Wernigerode
(ns bb-test-runner.core
"Wrap cognitect.test-runner but expands stackframes to show
file and line number of the babshka sources"
(:require [babashka.fs :as fs]
[clojure.stacktrace :as stacktrace]
[clojure.string :as str]
[clojure.test :as test]
[cognitect.test-runner]
[sci.core :as sci]))
@pesterhazy
pesterhazy / slack-messaging.md
Last active February 21, 2023 10:52
Messaging on Slack — some pitfalls

These days a lot of communication in organizations takes place on Slack. Because it's such an intuitive tool, it's easy to forget that, like any other communication medium, Slack has its own set of (often implicit) rules.

In fact, even with the best intentions, it's surprisingly easy to cause offense with an innocuous-seeming Slack message. So before you hit send, consider the following:

  • Take the size of the forum into account

    If you're sending a message to a channel with 50 participants, you're addressing a crowd. True, the very same channel may have been a place for unguarded, unfiltered communication years ago, when the organization was smaller. But as the channel grew, the environment changed - you're now in an large conference room, not a small, intimate team room.

    In other words, a message to #dev or #general is an announcement or public statement. So put as much care and attention into the message as you would with any kind of announcement to a large group of people.