Skip to content

Instantly share code, notes, and snippets.

@zioproto
zioproto / ossh-alias.sh
Last active January 26, 2024 15:01
ssh and scp without saving and ignoring fingerprints
alias oscp='scp -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no"'
alias ossh='ssh -o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no"'
@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 / chatbot.py
Last active May 24, 2023 07:35
Streamlit chatbot powered by Azure OpenAI
"""
MIT License
Copyright (c) 2023 Saverio Proto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@zioproto
zioproto / bookinfo-gateway-azure.yaml
Last active April 14, 2023 05:54
Istio Bookinfo Gateway that works on Microsoft Azure
---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: bookinfo-gateway
namespace: istio-system
annotations:
service.beta.kubernetes.io/azure-load-balancer-health-probe-request-path: /productpage
# TODO test:
# service.beta.kubernetes.io/azure-load-balancer-health-probe-request-path: /healthz/ready
@zioproto
zioproto / echoserver.yaml
Created March 13, 2023 16:43
Try to disable all envoy logs in Istio
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
spec:
replicas: 1
selector:
matchLabels:
run: echoserver
@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)
@zioproto
zioproto / gitconfig
Last active December 21, 2022 12:38
gitconfig
[user]
name = Saverio Proto
email = zioproto@gmail.com
[core]
editor = vim
autocrlf = input
[color]
diff = auto
@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 ])
@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