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.

@pesterhazy
pesterhazy / emacs-backtrace.md
Last active February 2, 2023 10:45
(wrong-type-argument stringp (require . package))
package--with-response-buffer-1: Wrong type argument: stringp, (require . package)
Debugger entered--Lisp error: (wrong-type-argument stringp (require . package))
  signal(wrong-type-argument (stringp (require . package)))
  package--with-response-buffer-1("https://melpa.org/packages/" #f(compiled-function () #<bytecode 0xc88c9f08cc83354>) :file "0xc-20201025.2105.tar" :async nil :error-function #f(compiled-function () #<bytecode 0x1f4000153e91>) :noerror nil)
  package-install-from-archive(#s(package-desc :name 0xc :version (20201025 2105) :summary "Base conversion made easy" :reqs ((emacs (24 4)) (s (1 11 0))) :kind tar :archive "melpa" :dir nil :extras ((:commit . "5bd6c0c901d03d1f24a3ddcf3a62d3b6d2428c80") (:authors ("Adam Niederer" . "adam.niederer@gmail.com")) (:maintainer "Adam Niederer" . "adam.niederer@gmail.com") (:keywords "base" "conversion") (:url . "http://github.com/AdamNiederer/0xc")) :signed nil))
  mapc(package-install-from-archive (#s(package-desc :name 0xc :version (20201025 2