Skip to content

Instantly share code, notes, and snippets.

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:

@jslay88
jslay88 / upload_file_ftp.py
Created July 10, 2018 06:51
Simple utility to upload a file via FTP - Python
#!/usr/bin/env python
import ntpath
import argparse
from ftplib import FTP
def upload_file(host, port,
username, password,
file_path, remote_path):
@jslay88
jslay88 / flask_resize_proxied_image.py
Last active December 4, 2018 06:20
Flask - Return Resized Proxied Image
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 / download_chromedriver.py
Last active April 30, 2019 18:28
Download Latest chromedriver. Win/Linux/Mac. 32/64bit
import os
import re
import zipfile
import logging
import requests
import xml.etree.ElementTree as ET
from io import BytesIO
@jslay88
jslay88 / gen_kube_secret.py
Last active May 18, 2019 07:32
Create k8s Secret YAML
#!/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 / master01_init.sh
Last active March 2, 2020 06:31
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)
#!/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 / docker-tls.yml
Last active April 2, 2023 00:34
Ansible Playbook for configuring Docker TLS
---
- name: Setup Docker engine with specific configuration and secure TCP socket
hosts: all
become: yes
vars:
ca_key: /etc/docker/ssl/ca-key.pem
ca_cert: /etc/docker/ssl/ca.pem
server_key: /etc/docker/ssl/server-key.pem
server_cert: /etc/docker/ssl/server-cert.pem
client_key: /etc/docker/ssl/client-key.pem
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 March 16, 2020 17:42
k8s cronjob for doing daily backups of etcd from a master.
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: etcd-backup
namespace: kube-system
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
@jslay88
jslay88 / prune_branches.sh
Created December 2, 2023 18:06
Prune Git Branches
#! /bin/sh
# Pull/Fetch remote branches and prune local branches that have been deleted
# Usage: prune_branches.sh [remote]
# If remote is not specified, it defaults to origin
# If remote is specified, it must be a valid remote name
set -e
# Get the remote name
if [ -z "$1" ]; then
remote="origin"