Skip to content

Instantly share code, notes, and snippets.

View jtheo's full-sized avatar

Matteo Marchelli jtheo

View GitHub Profile
@jtheo
jtheo / jq.md
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
jtheo / main.tf
Created November 30, 2020 15:04
Terraform for keyword used in locals
#
variable "params" {
default = {
vols = [
{
name = "one",
path = "/sub/path1"
},
{
@jtheo
jtheo / gist:e144785c32333e778e299c7afc4619fb
Created July 23, 2020 16:54
AWS List Public IP of an AWS Account in a region
# via http://eosrei.net/articles/2017/09/list-all-public-ip-addresses-aws-account
# 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
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'
<html>
<body>
<head><title> the disney family </title>
</body>
<div>
pippo <em> pluto </em> paperino <a href='http://google.com'>topolino </a>
</div>
</body>
</html>
@jtheo
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
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 profile.id, profile.name, config.value from profile join config on profile.id = config.profile_id where config.name = 'pvt_google_auth_secret' and profile.name = 'jtheo';
or as oneliner
read -p 'vpn username? ' VPN_USER; echo "select profile.id, profile.name, config.value from profile join config on profile.id = config.profile_id where config.name = 'pvt_google_auth_secret' and profile.name = '${VPN_USER}';" | ../../bin/sqlite3 userprop.db
@jtheo
jtheo / optimise.md
Last active May 11, 2017 15:44
Stuff I use sometimes

Snippets and chunks of code I use sometimes

Rename addic7ed.com 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/').eng.srt";done

Keybase proof

I hereby claim:

  • I am jtheo on github.
  • I am jtheo (https://keybase.io/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: