Skip to content

Instantly share code, notes, and snippets.

"""
I've modified John Gaines Jr.'s answer to handle lists. I didn't need editing
or the Taglist for what I'm doing so I removed them. They could certainly be
added back. Since lists can introduce duplication of keys, I replaced the keys
with UUIDs while still showing the original key as text on the left side of the
treeview.
UPDATE: My original answer did not include the editing function that John Gaines Jr.
had implemented. I've now added that to mine, with the caveat that I'm not very
expert regarding Tk/Tkinter layout and spacing, so I stopped tinkering once it
import os
import linecache
import pprint
import sys
from functools import wraps
class IncludeExclude(object):
def __init__(self, inclusions=None, exclusions=None):
self._inclusions = inclusions

Making X Windows work for a Docker container

https://stackoverflow.com/questions/49169055

This is because the container couldn't access the x11 socket of the host. so when doing the docker run, need to include these two flag.

-v /tmp/.X11-unix:/tmp/.X11-unix
-e DISPLAY=unix$DISPLAY

and after this, we need to do another operation. because the default settings of X11 only allows local users to print. so we need to change this to all users.

#!/usr/bin/env python
"""
To run these tests remotely with Ansible, add command line arguments:
./ansible_unit_tests.py -i inventory.yaml hostname
./ansible_unit_tests.py -i inventory.yaml group
To convert docstrings into a Markdown file, type:

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.

@wware
wware / trace_func.py
Last active December 19, 2025 18:32
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
@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 / 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

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>()
#!/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