Skip to content

Instantly share code, notes, and snippets.

@zioproto
zioproto / genesis_public_key
Created March 13, 2018 20:47
genesis_public_key
04b5d60c1db6371eec9515a8a60a2e58f0fba2cf90c1a847e8768d61ccc5b258fd468f11c4648c5966416c42fbfe946846216e5a08c9f7bf57c1fbb3eabc7810d2;haniehrajabi
@zioproto
zioproto / gitconfig
Last active December 21, 2022 12:38
gitconfig
[user]
name = Saverio Proto
email = [email protected]
[core]
editor = vim
autocrlf = input
[color]
diff = auto
@zioproto
zioproto / pre-commit
Created July 4, 2018 11:50
Git hook to avoid committing a decrypted ansible vault
#!/bin/bash
git show :group_vars/all/vault | grep ^'$ANSIBLE_VAULT'
export encrypted=$?
if [ $encrypted -ne 0 ]; then
echo Ansible Vault not encrypted, refusing to commit
exit 1
fi
@zioproto
zioproto / server_with_floatingip.yaml
Created August 6, 2018 08:28
Openstack Heat Server with Floating IP
heat_template_version: 2013-05-23
description: HOT to deploy a single instance, within its network, with a floating IP
parameters:
vm_key:
type: string
label: "SSH key name (must exist)"
default: macsp
vm_flavor:
@zioproto
zioproto / redis-delete-old-keys.py
Last active March 3, 2023 18:45
Delete Redis Stale Keys
#!/usr/bin/env python
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
# To debug code on a single key you can use this instead of the for loops:
# key = r.randomkey()
# Delete all keys not accessed since 'idletime'
for key in r.scan_iter("*"):
idle = r.object("idletime", key)
#!/usr/bin/env python
"""
Server
"""
import SocketServer
import BaseHTTPServer
import requests
import os
@zioproto
zioproto / vimrc
Created September 24, 2018 08:13
set number
set noai
set noautoindent
set fo=
set background=dark
syntax on
"set tabstop=4 shiftwidth=4 expandtab
set nocompatible
set backspace=2
autocmd BufWritePre * %s/\s\+$//e
@zioproto
zioproto / split-yaml.py
Created May 24, 2019 19:55
Split a Yaml file in multiple files
import sys, os
i = 0
print sys.argv[1]
f = open(sys.argv[1])
for line in f.readlines():
if line.startswith('---'):
i = i+1
filename = "%02d-%s" % (i,sys.argv[1])
w = open(filename,'a')
w.write(line)
@zioproto
zioproto / inputrc
Last active September 2, 2022 07:13
input rc for iTerm2 arrow navigation on Mac. Remember to disable mission control shortcuts
# If using bash add to ~/.inputrc
"\e[1;5D": backward-word
"\e[1;5C": forward-word
# If using zsh add to ~/.zprofile
bindkey -e
bindkey '^[[1;5C' forward-word
@zioproto
zioproto / restart-on-http-500.py
Last active November 25, 2022 08:08
Restart Wordpress if it is serving HTTP 500s
#! /usr/bin/env python3
import requests
from requests.adapters import HTTPAdapter, Retry
import os
s = requests.Session()
retries = Retry(total=5,
backoff_factor=0.1,
status_forcelist=[ 500, 502, 503, 504 ])