Skip to content

Instantly share code, notes, and snippets.

View stevenctl's full-sized avatar

Steven Landow stevenctl

View GitHub Profile
@stevenctl
stevenctl / bot.py
Created March 21, 2019 06:16
Python Selenium Reusable Browser Session
# Sometimes I have some tedious thing to do like data entry
# Sometimes I script that tedious thing using selenium
# Sometimes I have to login to something to enter that data
# This allows you to rerun your script using the same session
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
SELENIUM_SESSION_FILE = './selenium_session'
@stevenctl
stevenctl / sql2csv.py
Last active July 16, 2019 20:34
Quick script for generating a CSV from SQL DDL. Supports simple foreign keys and assumes sql file has formatting as you would get when exporting from datagrip.
#/usr/bin/env python
import re
def parse_fk(fk_str):
res = re.search("foreign key \(([^\)]+)\) references ([^ ]+) \(([^\)]+)\)", fk_str)
return res.group(1), res.group(2), res.group(3)
@stevenctl
stevenctl / imsplit.py
Created August 5, 2019 16:28
Image Splitter
#!/usr/bin/env python
from PIL import Image
image = Image.open("base.png")
def is_empty(line):
for x in range(line.width):
r, g, b, a = line.getpixel((x, 0))
if r + g + b + a > 0:
@stevenctl
stevenctl / .gitconfig
Created August 14, 2019 18:36
git tlog
[alias]
tlog = log --graph --full-history --date-order --pretty=format:'%w(120, 0, 9)%C(yellow)%h%Cred%d%Creset %C(green)%an%Creset %C(white)%s%Creset'
tdlog = log --graph --full-history --date-order --pretty=format:'%w(120, 0, 9)%C(yellow)%h%Cred%d%Creset %C(magenta)(%ci)%Creset %C(green)%an%Creset %C(white)%s%Creset'
@stevenctl
stevenctl / delve-pilot.md
Last active January 20, 2023 20:07
Debugging Pilot in K8S

Debugging Pilot with Delve

First build pilot with GCFLAGS="all=-n -l":

GCFLAGS="all=-N -l" HUB=docker.io/slandow TAG=slandow BUILD_IN_CONTAINER=1 make docker.pilot

Then we can wrap that image in one that includes delve:

# sets up a, b, c deployments with services for a and b
---
apiVersion: v1
kind: Service
metadata:
name: a
labels:
app: a
spec:
ports:
# scales deployment a to 500 replicas
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: a
spec:
replicas: 500
selector:
matchLabels:
# triggers a new "b" pod to be created
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: b
spec:
replicas: 1
selector:
matchLabels:

Writing Good Tests

Keeping test times low

Re-use echos

Spinning up services for tests is one of the slower pieces of writing a test. Wherever possible, keep this setup in your suite's Setup to avoid long test times.

var (
@stevenctl
stevenctl / main.go
Last active October 15, 2020 01:58
Istio Kubeconfig Extension
package main
import (
"fmt"
"encoding/json"
"istio.io/istio/pkg/kube"
"k8s.io/apimachinery/pkg/runtime"
)