Skip to content

Instantly share code, notes, and snippets.

View Get User Data Directory - Python
import sys
import logging
import pathlib
from typing import Optional, Union, List, Tuple
logger = logging.getLogger(__name__)
def get_user_data_dir(appending_paths: Union[str, List[str], Tuple[str, ...]] = None) \
@jslay88
jslay88 / k8s-etcd-backup.yaml
Created Mar 16, 2020
k8s cronjob for doing daily backups of etcd from a master.
View k8s-etcd-backup.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: etcd-backup
namespace: kube-system
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
@jslay88
jslay88 / master01_init.sh
Last active Mar 2, 2020
Simple shell script to initialize the first k8s master. This was needed, because of some networking discrepancies with minikube testing in relation to a production cluster. This allows you to fire up a single node master/worker, single master multiple workers, or HA k8s via kubeadm. Installs Flannel and MetalLB (cause layer2 for local devel)
View master01_init.sh
#!/bin/bash
# Simple shell script to initialize the first k8s master.
# This was needed, because of some networking discrepancies with minikube testing in relation to a production cluster.
# This allows you to fire up a single node master/worker, single master multiple workers, or HA k8s via kubeadm.
# Installs Flannel and MetalLB (cause layer2 for local devel)
# Pardon my terrible shell coding skills. Whipped this up on a late night.
### Settings ###
FLANNEL_MANIFEST="https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml"
@jslay88
jslay88 / gen_kube_secret.py
Last active May 18, 2019
Create k8s Secret YAML
View gen_kube_secret.py
#!/usr/bin/env python3
import base64
from getpass import getpass
def create_secret_yaml(secret_name, **kwargs):
"""
Create k8s Secret Yaml with key: value
Value must already be base64 encoded and in utf-8 encoded bytes
@jslay88
jslay88 / download_chromedriver.py
Last active Apr 30, 2019
Download Latest chromedriver. Win/Linux/Mac. 32/64bit
View download_chromedriver.py
import os
import re
import zipfile
import logging
import requests
import xml.etree.ElementTree as ET
from io import BytesIO
@jslay88
jslay88 / flask_resize_proxied_image.py
Last active Dec 4, 2018
Flask - Return Resized Proxied Image
View flask_resize_proxied_image.py
from PIL import Image
from io import BytesIO
from flask import send_file
from urllib.request import urlopen
from tempfile import NamedTemporaryFile
from urllib.error import URLError, HTTPError, ContentTooShortError
@web.route('/snapshot')
def snapshot():
@jslay88
jslay88 / upload_file_ftp.py
Created Jul 10, 2018
Simple utility to upload a file via FTP - Python
View upload_file_ftp.py
#!/usr/bin/env python
import ntpath
import argparse
from ftplib import FTP
def upload_file(host, port,
username, password,
file_path, remote_path):
View keybase.md

Keybase proof

I hereby claim:

  • I am jslay88 on github.
  • I am jslay (https://keybase.io/jslay) on keybase.
  • I have a public key ASApcqHfaMA2ZcVJS7LiTZx8cV1fcY9xQ1EVNJMvd_5DGgo

To claim this, I am signing this object: