Skip to content

Instantly share code, notes, and snippets.

View jtheo's full-sized avatar

Matteo Marchelli jtheo

View GitHub Profile
jtheo /
Created August 13, 2021 13:32
Transform key value pair like AWS Tags, or list of environment variables in task definition with jq to environment variables.
jq . env.json
  "environment": [
      "name": "SOMEVAR1",
      "value": "6"
 "name": "SOMEVAR2",
jtheo /
Created November 30, 2020 15:04
Terraform for keyword used in locals
variable "params" {
default = {
vols = [
name = "one",
path = "/sub/path1"
jtheo / gist:e144785c32333e778e299c7afc4619fb
Created July 23, 2020 16:54
AWS List Public IP of an AWS Account in a region
# via
# List of public ip in a specific region for a specific AWS account
aws ec2 describe-network-interfaces --query NetworkInterfaces[].Association.PublicIp | jq -r 'sort_by(.) | .[]'
jtheo / trim.txt
Created April 11, 2019 16:23
trim spaces for text between tags (html, probably xml too)
cat test.html; printf '\n\n'; cat test.html | perl -pe 's/<(\w+)([^>]*)>\s*([^<>\s].*?[^<>\s])\s*<\/\1>/<\1\2>\3<\1>/gm'
<head><title> the disney family </title>
pippo <em> pluto </em> paperino <a href=''>topolino </a>
jtheo / git-show-branch-sorted
Last active March 27, 2019 13:13
Show local git branch with date, commit and author sorted by last commit date
for branch in $(git branch -l | tr -d '*'); do printf "%-15s %-120s\n" "${branch}" "$(git show --oneline --pretty='format:%h %at %aD %cn %s' ${branch} -- | head -1)";done | sort -nr -k3
jtheo / get_google_otp_openvpnas.txt
Last active March 11, 2019 13:21
Extract seed for OTP from OpenVPN AS without using sacli
vpn_server:/usr/local/openvpn_as/etc/db# ../../bin/sqlite3 userprop.db
sqlite> select,, config.value from profile join config on = config.profile_id where = 'pvt_google_auth_secret' and = 'jtheo';
or as oneliner
read -p 'vpn username? ' VPN_USER; echo "select,, config.value from profile join config on = config.profile_id where = 'pvt_google_auth_secret' and = '${VPN_USER}';" | ../../bin/sqlite3 userprop.db
jtheo /
Last active May 11, 2017 15:44
Stuff I use sometimes

Snippets and chunks of code I use sometimes

Rename subtitles removing unnecessary information from the filename.

for s in *.srt;do mv "$s" "$(echo $s | perl -pe 's/^(.* - \d{2}x\d{2} - .*?)\..*\.srt/\1/')";done

Keybase proof

I hereby claim:

  • I am jtheo on github.
  • I am jtheo ( on keybase.
  • I have a public key whose fingerprint is DBC1 80CC 5C3C 0C2C CDB8 8C64 EDB7 BB1C C6C1 BEFB

To claim this, I am signing this object: