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 3, 2025 10:45
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 / README.md
Last active February 26, 2025 14:55
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 January 10, 2025 18:02
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
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 / rails_in_nix-shell.md
Last active March 10, 2023 03:13
Running Rails through nix-shell

Use the following to generate gemset.nix:

nix run nixpkgs.bundix --command bundix

Then run:

nix-shell
@bobvanderlinden
bobvanderlinden / sanitise_rubocop.sh
Created July 9, 2018 09:46
Fix Rubocop configuration by replacing the category of cops
#!/usr/bin/env bash
RUBOCOP_CONF="$1"
cat "$RUBOCOP_CONF" | \
sed -e 's|^DuplicatedGem|Bundler/DuplicatedGem|g' | \
sed -e 's|^InsecureProtocolSource|Bundler/InsecureProtocolSource|g' | \
sed -e 's|^OrderedGems|Bundler/OrderedGems|g' | \
sed -e 's|^DuplicatedAssignment|Gemspec/DuplicatedAssignment|g' | \
sed -e 's|^OrderedDependencies|Gemspec/OrderedDependencies|g' | \
sed -e 's|^RequiredRubyVersion|Gemspec/RequiredRubyVersion|g' | \
@bobvanderlinden
bobvanderlinden / example.html
Last active October 28, 2022 20:41
Simple QR-Code scanner based on jsqrcode
<html>
<head>
<script src="https://webqr.com/llqrcode.js"></script>
<script src="jsqrcode-camera.js"></script>
</head>
<body>
<div id="qrcodescanner"></div>
<div id="message"></div>
</body>
<script>
@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 / 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