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 March 14, 2019 13:25
Update gem conservative for Ruby project

Usage

Make sure hub is installed and set up with your user credentials.

./update-gem.sh loofah "Resolves security vulnerability."
@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 / README.md
Last active July 19, 2018 01:10
Run commands in parallel on different servers.

Create a file production that includes the server hostnames of production servers.

Then call for instance:

./run_on.sh production 'tail -f /var/log/nginx/access.log'
@bobvanderlinden
bobvanderlinden / README.md
Created September 3, 2018 12:01
Run commands on multiple servers in parallel

Usage

For example create a file with multiple servers:

echo 192.168.1.1 >> production_servers

Use the file with run_on to execute a command on all servers in parallel:

@bobvanderlinden
bobvanderlinden / vscode-edit.sh
Created September 5, 2018 12:16
Edit files in vscode
#!/usr/bin/env bash
if [[ "$TERM_PROGRAM" = "vscode" ]]
then
code --reuse-window --wait "$@"
else
code --new-window --wait "$@"
fi
@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
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
@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
@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 / 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