Skip to content

Instantly share code, notes, and snippets.

View HendrikPetertje's full-sized avatar

Peter van der Meulen HendrikPetertje

View GitHub Profile
@HendrikPetertje
HendrikPetertje / deferred-promise helper.md
Last active April 23, 2024 07:47
The deferred promise helper

The deferred promise helper is a way to run promise functions in stages while in the test environment. doing so makes it easier to test intermediary states.

DeferedPromiseHelper.ts

class DeferredPromiseHelper<IResolve, IReject> {
  promise: Promise<IResolve>;

  reject: (reason?: IReject) => void = () => {
    throw new Error('reject not working');
  };
@HendrikPetertje
HendrikPetertje / commands.sh
Last active August 29, 2023 07:37
git worktrees
# - Clone the remote first (replace REMOTE, with git url)
# - Setup origin to be fetched/pulled after that.
# this way you'll be able to receive new branches made by other people/machines after the initial clone
git clone REMOTE --bare
# set fetch destinations and a default remote for pushing/pulling
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git config checkout.defaultRemote origin
{ "uid": ["http://schemas.microsoft.com/identity/claims/objectidentifier"], "name": ["http://schemas.microsoft.com/identity/claims/displayname"], "email": ["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"] }
@HendrikPetertje
HendrikPetertje / readme.md
Created September 10, 2020 08:51
type asertion and non-null assertion in Typescript

disclaimer: this is dangerous stuff, typescript is pretty good at infering things and you should probably trust that over these funky things

Aserting a type:

You can force typescript to identify a new variable or a resulting variable to be of a specific type

before:
before

Add a magic "as" asertion and our result is now:

%script{class:'somefoo'}
@HendrikPetertje
HendrikPetertje / promises-and-async.md
Last active September 9, 2019 18:17
promises and async

Let's go over some weird phenomena here:

const init = async () => {

And

 await server.start();
@HendrikPetertje
HendrikPetertje / config.yml
Created August 30, 2019 14:06
basic node config with npm and jest
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:12.7
@HendrikPetertje
HendrikPetertje / sublime-install.md
Last active August 15, 2019 09:34
Installing Sublime with ESLint, Git plugins and other cool tools

Myes, so you noticed Atom is kinda slow on your computer, or You'd like to try something more lightweight in general. This mini-guide will help you install Sublime with all the plugins needed to continue with our ECMA Natives class.

Sublime will not work with Bash for windows. So if you're using that. Refer to the installation guide for NeoVim instead.

1. Installing Sublime

Windows & OSX

If you are on Windows or OSX you can simply download and install Sublime from it's home-page: https://www.sublimetext.com/

Keybase proof

I hereby claim:

  • I am hendrikpetertje on github.
  • I am hendrikpeter (https://keybase.io/hendrikpeter) on keybase.
  • I have a public key ASAC5sJJUkKXUs5miuT1MK34W-X4e1JuzEpH_g5UEYO-eQo

To claim this, I am signing this object:

@HendrikPetertje
HendrikPetertje / alacritty.yml
Last active October 1, 2018 08:37
alacritty config for Swedish OSX 2018-10-01
# ~/.conf/alacritty/alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization.
#
# If this property is not set, alacritty will set it to xterm-256color.