Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / shipit.py
Created January 27, 2017 09:31 — forked from josvazg/shipit.py
Ship it with --no-ff & comment conventions
#!/usr/bin/env python3
"""
Shipit script will shipt all commits from a given feature branch
as a single non fast forward merge, while adding the proper agreed upon
commit message formatting.
You must sit on a local clone of the target branch.
If you are happy with how shipit merged, you just "git push" the result
to the remote branch.
"""
@philroche
philroche / change_cloudinit_datasource.sh
Created February 7, 2017 14:43 — forked from rcj4747/change_cloudinit_datasource.sh
An exmple of changing the datasource in cloud-init
# Get the Ubuntu cloud image of your choosing (this example uses the latest Xenial daily)
wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
# Set the cloud-init datasource to use explicitly (this example uses the EC2 datasource)
sudo mount-image-callback xenial-server-cloudimg-amd64-disk1.img -- \
sh -c 'echo "datasource: Ec2" > $MOUNTPOINT/etc/cloud/ds-identify.cfg'
# Confirm the current datasource configuration
sudo mount-image-callback xenial-server-cloudimg-amd64-disk1.img -- \
chroot _MOUNTPOINT_ cat /etc/cloud/ds-identify.cfg
@philroche
philroche / aws_pricing.py
Created June 8, 2017 18:54 — forked from rcj4747/aws_pricing.py
Here is a log (from ipython) from toying with the pricing API for Amazon EC2. Not sure that this is still supported. I played around exploring the data with the intent of using this to derive a list of supported instance types per region. That information is contained within and is quite rich; instance types have properties reflecting features s…
# log from ipython as I played with the pricing api
#index.json from https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json
# Per http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html#download-the-offer-index
# But this may no longer be supported as it (EC2) is not part of the parent index of all services any longer
import json
with open('index.json', 'r') as foo:
data = json.read(foo)
with open('index.json', 'r') as foo:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
cat <<EOF > meta-data
instance-id: iid-local01
local-hostname: cloudimg
EOF
cat <<EOF > user-data
#cloud-config
ssh_import_id: [ yourlaunchpadid ]
@philroche
philroche / aws_7d_s3_lifecycle.sh
Created November 9, 2017 15:53 — forked from rcj4747/aws_7d_s3_lifecycle.sh
AWS Bucket Lifecycle for AMI testing (delete after 7 days)
#!/bin/sh
cat > lifecycle.json <<EOF
{
"Rules": [
{
"Expiration": {
"Days": 7
},
"ID": "Expire, delete, and cancel",
@philroche
philroche / private_ppa_addition.sh
Created January 27, 2018 11:53 — forked from rcj4747/private_ppa_addition.sh
Add a package from a private PPA to a chroot and strip references to the private PPA
REPO_LINE="deb https://${LP_USER}:${PPA_PASSWORD}@${PRIVATE_PPA_URL} ${SUITE} main"
REPO_KEY_FINGERPRINT=832749327429CADB77842973ED72947203471037
# Add the private ppa to the system
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-add-repository "${REPO_LINE}"
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key adv --keyserver keyserver.ubuntu.com --recv ${REPO_KEY_FINGERPRINT}
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get update
# Install from private PPA HERE
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get install -qqy awesome_package_but_super_secret
@philroche
philroche / zncbackup.sh
Created February 13, 2018 10:44
Backup ZNC config and chat logs
#!/bin/bash
### Facultatif change :
DIR=/data/znc # This will most likely change for you
TAR_PATH=`whereis tar | cut -d ' ' -f 2`
p7zip_PATH=`whereis 7za | cut -d ' ' -f 2`
DATEI1=$(date +%Y-%m-%d)_znc_backup.tar
DATEI2=$(date +%Y-%m-%d)_znc_backup.tar.7z
DATUM=$(date +%Y-%m-%d)
sevenzp="a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -mhe=on"
### no Change after here
@philroche
philroche / recursive-m4a-convert-to-mp3.sh
Created April 11, 2018 11:55
Recursive convert m4a files to mp3
#!/bin/bash
#
#
#set -ux
set +e
if [ -z "$1" ] ; then
TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
@philroche
philroche / instance-types.sh
Last active September 25, 2018 04:52 — forked from trestletech/instance-types.sh
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
all_az+=($az)