Skip to content

Instantly share code, notes, and snippets.

View bobvanderlinden's full-sized avatar

Bob van der Linden bobvanderlinden

  • The Netherlands
View GitHub Profile
@bobvanderlinden
bobvanderlinden / README.md
Last active November 21, 2024 09:22
apply-ts-expect-error.js

For each tsc error, this adds a comment:

// TODO: Resolve type error
// @ts-expect-error
...

For each Unused '@ts-expect-error' directive error it removes the @ts-expect-error comment as well as any TODO: comment above.

@bobvanderlinden
bobvanderlinden / README.md
Last active April 7, 2024 11:00
devenv+python+git regression

devenv git+python regression

This is an example where devenv+python will fail when the git binary from the system is based on an older libc than the libc that is used in devenv. The system git is provided here by nix develop . to simulate an older system.

$ nix develop .
# This loads an older version of git (based on an older libc).
$ devenv shell
# This uses python to run `pip install -r requirements.txt` and will try to clone a git repository from there.
# Python uses a newer libc, which is passed through to subprocesses using `LD_LIBRARY_PATH` to `git`. `git` cannot run because of an incompatible libc.
@bobvanderlinden
bobvanderlinden / README.md
Created May 15, 2023 20:32
devenv.yaml JSON Schema

Add to the top of devenv.yaml:

# yaml-language-server: $schema=<url/path to devenv.schema.json>
@bobvanderlinden
bobvanderlinden / README.md
Last active July 20, 2022 09:59
Rename Git commits in batch using interactive rebase

When working on a merge/pull request and want your Git commit history to look nice afterwards, you often need to rename commit messages. For larger merge/pull requests you might need to rename a bunch of them.

The git rebase interactive reword command comes close, but it only allows you to change commit messages one by one in sequence, instead of changing the messages in an editor in one go.

Below is the most practical way of rewriting the commit messages I have found. It uses git interactive rebase, vscode and multiple cursors.

Note that the method below doesn't work for multiline commit messages!

@bobvanderlinden
bobvanderlinden / Dockerfile
Last active October 13, 2021 06:52
docker-compose host access test
FROM ubuntu
RUN apt-get update
RUN apt-get -y install netcat
CMD nc -zv -w 1 $ADDRESS 8888
@bobvanderlinden
bobvanderlinden / http_server.sh
Last active May 14, 2020 13:13
NodeJS HTTP server one-liner
node --eval 'require("http").createServer((req, res) => { res.end(); console.log(req.method, req.url, req.rawHeaders); }).listen(8080)'
@bobvanderlinden
bobvanderlinden / experiment.lua
Created October 30, 2019 16:40
HTTP path pattern matching for HAProxy using LUA
local function matches(input, pattern)
local index = 1
return function()
local match = input:match(pattern, index)
if match then
index = index + match:len() + 1
return match
else
return nil
end
@bobvanderlinden
bobvanderlinden / README.md
Last active March 9, 2023 16:39
Example GraphQL call towards GitHub using curl and jq

This is an example how to do GraphQL queries in a somewhat sane way in bash using curl and jq.

The example does an query towards GitHub to fetch the commit SHAs of open pull requests for a specific repository.

The example needs the environment variables REPO_OWNER, REPO_NAME and GITHUB_TOKEN to be set.

@bobvanderlinden
bobvanderlinden / README.md
Created November 30, 2018 20:48
Ad-hoc dnsmasq DHCP server

This script is handy for setting up an ad-hoc DHCP server for instance when starting up a Raspberry PI for the first time. dnsmasq will output when it has given a client an address:

dnsmasq-dhcp: DHCPACK(enp0s25) 192.169.1.109 b8:27:eb:86:2f:ed nixos
This file has been truncated, but you can view the full file.
these derivations will be built:
/nix/store/30fribf3xpmiivys1mzqp007m70p4h4v-node-v11.0.0.tar.xz.drv
/nix/store/k1ww35ij6c9r0vxxrqpmid1lpmhpq3zm-nodejs-11.0.0.drv
these paths will be fetched (95.06 MiB download, 553.67 MiB unpacked):
/nix/store/0ingn8cwwnl84i374hcl6nafsm2c5m2p-perl-5.28.0
/nix/store/0pcxv5mzn1fz7z8aa1frczkm4gpy7dkc-libgcrypt-1.8.3
/nix/store/10yq7kwlvbc6h658izmrlsspry1g9f3c-gcc-wrapper-7.3.0
/nix/store/1vb4m694aj9bdm7aq3911yjjb73gn4ii-attr-2.4.47
/nix/store/22zwmxhd41a1j3cf7rxjwd75w4hmxdrv-libev-4.24
/nix/store/2brlr94ahy3a9mvcjy0qbqpv8zrb7b7s-python-2.7.15