Skip to content

Instantly share code, notes, and snippets.

View berga's full-sized avatar

Marco Bergantin berga

  • TIM - Gruppo Telecom Italia
  • Cagliari, Italy
View GitHub Profile
@berga
berga / aws-ssm-ec2-proxy-command.sh
Created March 24, 2020 10:41
AWS SSM SSH Proxy Command
#!/usr/bin/env sh
######## Usage #################################################################
#
# #1 Install the AWS CLI
# https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
#
# #2 Install the Session Manager Plugin for the AWS CLI
# https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html
#
fields @timestamp, @message
| parse @message '*Query_time: * Lock_time: * Rows_sent: * Rows_examined: *\n*' as host, query_time, lock_time, rows_sent, rows_examined, query
| sort query_time desc
| limit 100
@berga
berga / .promptrc
Created February 18, 2020 09:30 — forked from mortn/.promptrc
byobu git prompt
#!/bin/bash
# modified from byobu's bashrc -- colorize the prompt
# Copyright (C) 2014 Dustin Kirkland
#
# Authors: Dustin Kirkland <kirkland@byobu.co>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
@berga
berga / gist:ffdcaf4b6459f5a6463c1ea8d561b81f
Created December 19, 2019 11:47 — forked from knu/gist:111055
How to mass-rename tags and push them with Git
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done
@berga
berga / test-cloud-init-run.sh
Created November 28, 2019 10:16 — forked from maoueh/test-cloud-init-run.sh
Small script to test changes made to cloud init config without rebooting
rm -rf /var/lib/cloud/instance && rm -rf /var/lib/cloud/instances/* && rm -rf /var/lib/cloud/sem/*
cloud-init init && cloud-init modules --mode config && cloud-init modules --mode final
@berga
berga / gist:15bfad3d1bb7e9ab70f224158254f9be
Created November 12, 2019 13:16 — forked from danilop/gist:6d49e2b6507f748a00a9
Amazon EC2 - user data to automatically mount an Amazon EFS file system at boot (Linux)
#cloud-config
package_upgrade: true
packages:
- nfs-utils
- httpd
- php
runcmd:
- echo "$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).FILE_SYSTEM_ID.efs.us-west-2.amazonaws.com:/ /var/www/html/efs nfs4 defaults" >> /etc/fstab
- mkdir /var/www/html/efs
- mount -a
@berga
berga / gist:6683bb2c3c36531a2762f963ad882eaa
Created April 5, 2019 08:33 — forked from qsun/gist:1247402
ruby integer to/from ip address
require 'ipaddr'
IPAddr.new('1.2.3.4').to_i
IPAddr.new(16909060, Socket::AF_INET).to_s
#############################
### GENERATE CERT AND KEY ###
#############################
# when generating key and cert, use password provided by administrator
cd ~/Workspace/Silvermedia/vpn
kozak127@callisto:~/Workspace/Silvermedia/vpn$ openssl pkcs12 -in michal.wesoly.p12 -nocerts -nodes -out michal.wesoly.key
Enter Import Password:
@berga
berga / _upgrade-pg9.4-to-pg9.5.md
Created December 11, 2018 23:15 — forked from chbrown/_upgrade-pg9.4-to-pg9.5.md
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew

First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml lower down in this gist):

cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Most importantly, note the -D /usr/local/var/postgres argument.

Second, shut down your current PostgreSQL.

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@berga
berga / doit
Created September 27, 2018 21:44 — forked from stantonk/doit
Install python 2.7.3 on CentOS 5.8
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3