Skip to content

Instantly share code, notes, and snippets.

@aleofreddi
aleofreddi / gist:b5edf229bf2fb6d6b028c1c779560716
Created August 1, 2024 17:10
Cloudflare: remove all DNS records for a zone
zoneid=<<zoneid>>
bearer=<<bearer>>
curl \
--header "Authorization: Bearer $bearer" \
-s "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records?per_page=50000" \
| jq -r '.result[].id' \
| xargs -n 1 -I {} -P 20 -- curl --silent --request DELETE \
--header "Authorization: Bearer $bearer" \
"https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/{}"
# Bash array cheatsheet
Declare declare -a array=('a' 'b' 'c')
Length ${#array[@]}
Indices ${!array[@]}
Push n (append) array+=('i_0' ... 'i_n')
Pop n (bash>=4) unset 'array[-n]'
Pop n (bash<4) unset 'arr[${#arr[@]}-n]'
@aleofreddi
aleofreddi / gist:bd23f0f2a7ea41f4aad4a30f5fcdfa86
Created January 18, 2020 16:42
indent an xml file with vanilla vim
:%!xmllint --format -
@aleofreddi
aleofreddi / gist:88696732c3422d55f131a9ca1a40a388
Created January 15, 2020 19:25
ansible show variables defined for an host (with sudo+user)
ansible -i inventory -m setup -s -u user host
update-alternatives --set editor /usr/bin/vim.basic
echo ':setlocal indentkeys=' > ~/.vimrc
@aleofreddi
aleofreddi / virtualenv_macos
Last active August 6, 2024 09:43
macOS: install virtualenv
# I'm always scared of using easy_install and pip on the root python installation as it might screw up things!
#
# So this is a reminder that for pip & virtualenv will work fine on macOS
#
sudo easy_install pip && sudo pip install virtualenv
@aleofreddi
aleofreddi / fuseki-owl-tdb
Created December 12, 2019 03:04
Fuseki OWL+TDB configuration
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@aleofreddi
aleofreddi / gpt_extend_vda1.sh
Last active December 12, 2019 03:05
extend a gpt partition after disk resize
sgdisk /dev/vda -e &&
sgdisk -d 1 /dev/vda &&
sgdisk -N 1 /dev/vda &&
partprobe &&
resize2fs /dev/vda1
@aleofreddi
aleofreddi / fio_test.sh
Created June 23, 2019 20:37
fio commandline to test disk performance
fio \
--randrepeat=1 \
--ioengine=libaio \
--direct=1 \
--gtod_reduce=1 \
--name=test \
--filename=random_read_write.fio \
--bs=4k \
--iodepth=64 \
--size=4G \
#!/usr/bin/perl -p
#
# Perl implementation of envsubst for systems where it does not exist (eg. macOSX).
#
# Wed Apr 18 08:03:05 CEST 2018, Andrea Leofreddi
#
$_ =~ s/\Q${$1||$2}/$ENV{$1?$2:$4}/ while $_ =~ /(\$\{([^}]+)})|(\$(\w+))/g;