Skip to content

Instantly share code, notes, and snippets.

View stigtsp's full-sized avatar
🕊️
peace, pls

Stig stigtsp

🕊️
peace, pls
View GitHub Profile
@stigtsp
stigtsp / gist:b08feec36e16e2260699d7d232d3c68b
Created February 29, 2024 11:30
maxing ubuntu server root partition
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Sometimes bcrypt() returns a hash it cannot validate with the same passphrase.

So the following code fails:

bcrypt_check($pass, bcrypt($pass, "2b", 4, urandom(16)))

I've seen this happen in CI runners, and started to dig a bit deeper. Usually after ~10 invocations of bcrypt() or so from process startup.

#!/usr/bin/env bash
set -eux -o pipefail
cd /cpan-vol
export TZ=UTC
START_DATE=$(date -u --iso)
START=$(date -u -Iseconds)
rsync -va --delete cpan-rsync.perl.org::CPAN /cpan-vol/CPAN/
STOP=$(date -u -Iseconds)
@stigtsp
stigtsp / compare-cacert.sh
Created May 8, 2023 12:44
shell script to compare cacert files
#!/usr/bin/env bash
set -eu
parse_bundle() {
# https://serverfault.com/questions/590870/how-to-view-all-ssl-certificates-in-a-bundle
openssl crl2pkcs7 -nocrl -certfile $1 | openssl pkcs7 -print_certs
}
echo "Comparing certs in $1 and $2" >&2
tmpdir=$(mktemp -d)
parse_bundle $1 > $tmpdir/a
parse_bundle $2 > $tmpdir/b
#! /usr/bin/env nix-shell
#! nix-shell <nixpkgs> -i perl -p perl perlPackages.Mojolicious perlPackages.IOSocketSSL
use ojo;
g("https://www.kernel.org")->dom
->find("table#releases tr")
->each(sub {
my $td = $_->find("td");
printf("%13s %-14s %s\n",
map { $td->[$_]->all_text(0) } 0..2 );
@stigtsp
stigtsp / update-all-the-nix
Last active September 25, 2023 18:11
script for updating all the nixos stuffs
#!/usr/bin/env bash
set -e
function ver2rev {
echo $1 | perl -pe 's/.+\.(.+?)"?$/$1/g'
}
nixver=$(nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version')
$ nix-shell -p libmbim --run "sudo /etc/static/ModemManager/fcc-unlock.d/1eac foo wwan0mbim0"
[/dev/wwan0mbim0] Successfully requested to enable radio
#!/bin/sh
(>&2 echo "######### UNSAFE SSH #########")
set -ex
env TERM=xterm ssh -oCiphers=+aes128-cbc -oKexAlgorithms=+diffie-hellman-group-exchange-sha1 -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $@
print join "\n", map { ($_ % 3 == 0 && "fizz") . ($_ % 5 == 0 && "buzz") || $_ } 1..100'
@stigtsp
stigtsp / metacpan-latest-releases-jsonl.pl
Created August 20, 2022 18:32
create JSONL for all latest CPAN modules
#! /usr/bin/env nix-shell
#! nix-shell -i perl -p "with perl.pkgs; [ perl MetaCPANClient CpanelJSONXS ]"
use v5.36;
use MetaCPAN::Client;
use Data::Dumper;
use Cpanel::JSON::XS;
my $json = Cpanel::JSON::XS->new->ascii;
$json->canonical(1);
my $mcpan = MetaCPAN::Client->new();