Skip to content

Instantly share code, notes, and snippets.

@wware
wware / 1_kubernetes_on_macOS.md
Last active February 15, 2019 22:19 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@wware
wware / git_ancestors.py
Last active April 18, 2019 20:05
A breadth-first-search decorator to search the history of a git repository to find the most recent commit(s) satisfying some criterion.
import os
from functools import wraps
def cmd(x):
return os.popen(x).read().strip()
def predecessors(hash):
return cmd("git log --pretty=%P -n 1 {0}".format(hash)).split(" ")
def is_a_merge_commit(hash):
@wware
wware / commands.py
Last active May 2, 2019 17:36
A little command infrastructure thing to simplify using argparse.
import argparse
import logging
import os
import pdb
import re
import subprocess
_cmds = {}
_args = []
@wware
wware / widget010.scad
Last active June 15, 2019 20:45
3d-printable widget for Veracode's new "010" logo
$fn = 120;
thickness = 8;
height = 12;
width = 2;
module zero() {
difference() {
translate([0, 0, -.5*thickness])
cylinder(h=thickness, d=height);
translate([0, 0, -.5*thickness-1])
#!/usr/bin/env python
"""
The top five vertices are at 72-degree increments at a height of z=A.
The next five vertices are at the same 72-degree incremenets at a
height of z=B. Next five are offset by 36 degrees, with z=-B, and last
five are also offset by 36 degrees with z=-A. The trick is to make sure
all the lengths are the same, and solve for A and B.
Let Ea and Fa be two adjacent vertices of the top five. Let Eb and Fb
be the vertices below them at z=B. Let Gb be the vertex connecting to

Getting to a Bash prompt from inside PDB

Sometimes I'm doing stuff in PDB, the Python debugger, and I would like to hop out to a Bash prompt. Maybe I want to see what is the current directory, or what files are in the current directory, or I'd like to run some executable in this environment, or see what is on the current path. Anyway the trick is to do this.

$ python -m pdb foo.py 
> /Users/wware/foo.py(3)<module>()
@wware
wware / ansible-summary.md
Last active July 12, 2024 20:06 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7), tweaked by Will Ware in 2019

Configuration file

intro_configuration.html

First one found from of

@wware
wware / 0Gunicorn.md
Last active December 1, 2019 23:17
Wrap my head around this WSGI stuff

Learning about Gunicorn

I need to wrap my head around this WSGI stuff. Let's dockerize this tutorial.

https://en.wikipedia.org/wiki/Gunicorn

The Gunicorn "Green Unicorn" (pronounced jee-unicorn) is a Python Web Server Gateway Interface (WSGI) HTTP server. It is a pre-fork worker model, ported from Ruby's Unicorn project. The Gunicorn server is broadly compatible with a

@wware
wware / trace_func.py
Last active December 13, 2019 18:48
Decorator to show Python control flow thru a function and the functions it calls
#!/usr/bin/env python
import inspect
import linecache
import pprint
import yaml
import re
import os
import sys
import logging

Yet another Python debugger hack

Here is the problem I'm trying to solve here. You have some code running in AWS or running in some far-away server rack. Your access to the machine in question is things like SSH or telnet. The code is running a bunch of jobs as part of a CI/CD system. You would like to kick off a job where the code runs with RemotePdb so that you can step through it and examine variables and set breakpoints and all that, without disturbing any other jobs running at the same time.

You can't change the code. You don't have time to get a merge request approved, and it doesn't make sense to do a merge request to facilitate what might be a very brief one-time debugging session. You need some kind of hooks in your production code that make this remote debugging stuff feasible without a fresh push to your CI/CD stack.