Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
@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 / 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
#!/usr/bin/env python
"""
Server
"""
import SocketServer
import BaseHTTPServer
import requests
import os