Skip to content

Instantly share code, notes, and snippets.

@aleofreddi
aleofreddi / gist:f800b25fe19e87f89d341ae29edcc36e
Created June 7, 2019 12:52
one liner yaml2json & json2yaml
# yaml2json
ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' < hello.yaml
# json2yaml
ruby -ryaml -rjson -e 'puts YAML.dump(JSON.load(ARGF))' < hello.json
@aleofreddi
aleofreddi / cognito_get_all_users.sh
Last active September 20, 2024 16:13
AWS Cognito: list all users
#!/bin/sh
#
# Dump AWS Cognito users as CSV output.
#
# Thu Jun 20 15:31:10 CEST 2019, Andrea Leofreddi
#
me="`basename $0`"
if [ $# != 1 ]; then
echo Usage: "$me" pool_id >&2
#!/bin/sh
#
# Combine two non-duplex document feeder scansions into a single duplex pdf file.
#
# The input file should be procuded passing the document in the feeder (from the
# first page forward) and then passing it again on the backside (that is from
# the last page on backward).
#
# Tue Aug 8 20:41:26 CEST 2017, Andrea Leofreddi
#
#!/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;
@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 \
@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 / 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 / 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
update-alternatives --set editor /usr/bin/vim.basic
echo ':setlocal indentkeys=' > ~/.vimrc
@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