Skip to content

Instantly share code, notes, and snippets.

@richard-scott
richard-scott / ec2-fingerprint-key
Created December 7, 2016 14:38 — forked from jtriley/ec2-fingerprint-key
Simple Python script that computes both public and private RSA key fingerprints as used by Amazon EC2
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(
@richard-scott
richard-scott / 00_description
Created December 13, 2016 10:52 — forked from halberom/00_description
ansible - example of using filters to change each item in a list
The problem:
I wanted to use the jinja 'map' filter to modify each item in a string, in this simple
example, adding '.conf' to each item.
The 'format' filter in jinja takes arguments (value, *args, **kwargs). Unfortunately,
it uses 'value' as the pattern. When called inside map 'value' is the current item in
the list, or in other words *args as far as format is concerned. So it's the wrong way
around.
@richard-scott
richard-scott / lambdaAMIBackups.py
Created January 26, 2017 10:32 — forked from bkozora/lambdaAMIBackups.py
AWS Lambda AMI Backups
# Automated AMI Backups
#
# @author Robert Kozora <bobby@kozora.me>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
#
@richard-scott
richard-scott / disable_troublesom_scaling_processes.py
Created March 2, 2017 14:13 — forked from simon-weber/disable_troublesom_scaling_processes.py
disable ASG scaling processes during CodeDeploy deploys
"""
Suspend an auto scaling group's scaling processes that can interfere with CodeDeploy deploys.
It assumes a single ASG per deployment group.
To use this:
* create a lambda function with this code, then hook up it up to an SNS topic that receives all deployment events (but not host events).
* attach that topic as a trigger in your deployment groups.
Unlike AWS's in-appspec approach, this supports arbitrary deploy concurrency.
@richard-scott
richard-scott / debian-vps-configuration.md
Created March 11, 2017 21:40
VPS Debian Configuration

Debian

Locale

Annoying message?

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
@richard-scott
richard-scott / mk-eph.sh
Created April 24, 2017 10:36 — forked from taavituisk/mk-eph.sh
Make ephemeral swap and tmp.
#!/bin/bash
# mk-eph.sh
# Creates a lvm volume over all ephemeral devices.
# Swap related operations
function SwapEnabler() {
local swapdev='/dev/ephemeral/swap'
local swapon="$(swapon -s | wc -l)"
# See if some swap is enabled already.
@richard-scott
richard-scott / extract-123-reg-zonefile.js
Created January 24, 2018 09:19 — forked from biinari/extract-123-reg-zonefile.js
Script to extract the DNS entries from 123-reg advanced dns page
var table = document.getElementsByClassName('advanced_dns')[0];
var rows = table.getElementsByTagName('tr');
var i, len, row;
var hostname, type, priority, ttl, destination;
var output = '';
output += '$TTL 600\n'; // start with default TTL
// skip header and last two rows (add new entry, delete all entries)
for (i = 1, len = rows.length - 2; i < len; i++) {
@richard-scott
richard-scott / restic-backup.service
Created April 12, 2018 09:22 — forked from erikw/restic-backup.service
My restic backup solution using Backblaze B2 storage, systemd timers and email notifications on failure
[Unit]
Description=Backup with restic to Backblaze B2
OnFailure=status-email-user@%n.service
[Service]
Type=simple
Nice=10
ExecStart=/usr/local/sbin/restic_backup.sh
# $HOME or $XDG_CACHE_HOME must be set for restic to find /root/.cache/restic/
Environment="HOME=/root"
@richard-scott
richard-scott / nodejs_installer.ps1
Created April 20, 2018 14:42 — forked from nweldev/nodejs_installer.ps1
Powershell script installing nodejs (with git) and some npm packages
write-host "`n ## NODEJS INSTALLER ## `n"
### CONFIGURATION
# nodejs
$version = "4.4.7-x64"
$url = "https://nodejs.org/dist/latest-v4.x/node-v$version.msi"
# git
$git_version = "2.9.2"
@richard-scott
richard-scott / results.txt
Created May 17, 2018 14:45 — forked from dropwhile/results.txt
python compression comparison
Data Size:
Input: 2074
LZ4: 758 (0.37)
Snappy: 676 (0.33)
LZF: 697 (0.34)
ZLIB: 510 (0.25)
LZ4 / Snappy: 1.121302
LZ4 / LZF: 1.087518
LZ4 / ZLIB: 1.486275
Benchmark: 50000 calls