The System.lang.Runtime.exec() method is non-blocking, so you call it and it spawns a background process.
Unfortunately the java.lang.Process thingy in Java 8 has no way to get a PID, so you need a cheesy hack to find it.
| v1 = [0, 2, -1]; | |
| v2 = [1, 3, 3]; | |
| y = [v2[0] - v1[0], v2[1] - v1[1], v2[2] - v1[2]]; | |
| translate(v1) | |
| rotate(-acos(y[2] / norm(y)), cross(y, [0, 0, 1])) | |
| cylinder(h=norm(y), d=0.1); |
| #!/usr/bin/env python | |
| # https://en.wikipedia.org/wiki/Isomorphic_keyboard | |
| # any hexagonal layout is defined by two offsets (the value of the third is forced by the first two) | |
| import sys | |
| many = [20 * [None] for _ in range(20)] | |
| def display(): | |
| width = 4 |
Nobody can remember how to use Docker, it is far too confusing. So here are some hints.
sudo docker build -t simple_flask:dockerfile .
sudo docker run -p 5000:5000 simple_flask:dockerfile python hello.py
My actual intention is to learn Ansible. But in order to run Ansible you need Docker, unless you happen to have a rackful of machines at your disposal which I do not.
| #!/bin/bash | |
| wait_all() { | |
| # As soon as one of the background processes creates the EPIC_FAIL file, | |
| # kill all background processes, rm EPIC_FAIL, and stop looping. | |
| while [ $(jobs | grep -v Done | wc -l) -ne 0 ]; do | |
| sleep 1 | |
| if [ -f EPIC_FAIL ]; then | |
| rm -f EPIC_FAIL | |
| echo OUCH |
| #!/usr/bin/env python | |
| import argparse | |
| import logging | |
| import os | |
| import sys | |
| import pprint | |
| from textwrap import dedent | |
| HERE = os.path.dirname(__file__) |
| #!/usr/bin/env python | |
| import logging | |
| from flask import Flask | |
| from twisted.internet import ssl, reactor | |
| from twisted.web.wsgi import WSGIResource | |
| from twisted.web.server import Site | |
| from twisted.python.threadpool import ThreadPool | |
| from twisted.application import service |
This is a feature toggle scheme for the system I maintain at my job. The goal is to be able to easily toggle functions that have been recently pushed to production, so if things go bad, we have an easy mitigation plan.
Create a database table with three columns, Key (string), Value (boolean), LastChanged (timestamp). The purpose of the LastChanged column is just for record keeping to decide when a feature is deemed trustworthy. The several for a given key string present the history of switching the feature on and off,
| import os | |
| import logging | |
| from contextlib import contextmanager | |
| logging.basicConfig( | |
| format='%(asctime)-15s %(levelname)s %(filename)s:%(lineno)d %(message)s', | |
| level=logging.INFO | |
| ) | |
| def __LINE__(): |
| #!/bin/bash | |
| help() { | |
| echo "Bash script that parses cmd line args without getopt(s)" | |
| echo "Adapted from https://stackoverflow.com/questions/192249" | |
| echo " -h, --help print this help message" | |
| echo " -f, --foo set FOO variable" | |
| echo " -b, --bar set BAR variable" | |
| echo " -d, --debug enable debug (doesn't really do anything here)" | |
| echo " <anything else> becomes a positional argument" |