Skip to content

Instantly share code, notes, and snippets.

Messing with Ansible and Docker

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.

#!/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
@wware
wware / connect_two_points.scad
Last active August 3, 2018 19:50
OpenSCAD code to create a cylinder connecting two given points in 3-space
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);

Non-blocking

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.

@wware
wware / 0_Instrument_2018.md
Last active October 23, 2018 02:55
Another stupid electronic musical instrument

Instrument for 2018

Before spending time and money building a lot of electronics, let's prototype the thing in Javascript.

Hmm. Maybe a better idea would be to make up a board that accepts a Teensy 3.6, and provides audio hardware, and a bunch of pushbuttons and a few other controllers. Then you can develop code on a real Teensy with representative hardware support. When you go to the real instrument you're only changing the form factor, and maybe the number of buttons or switching to touch-sensitive or whatever.

Prior art - the Tooba, 2015

Can you put LaTeX-style math in a Github Gist? Yes you can.

Use https://www.codecogs.com/eqnedit.php to edit your math. Use the little menu at the bottom to select "HTML (Edit)", and copy the stuff into your Gist. Here is a fairly meaningless example.

Clicking on this will allow your reader to review and edit the source.

@wware
wware / goldbach.py
Last active November 28, 2018 14:30
"""
https://twitter.com/fermatslibrary/status/1067423316095508480
Today's paper is a good example of an unsolved conjecture being disproved by counterexample.
Goldbach stated that every positive odd integer is either prime or the sum of a prime and
twice a square. 5777 and 5993 are the only known counterexamples.
https://fermatslibrary.com/s/a-not-so-famous-goldbach-conjecture#email-newsletter
"""
# this is python 2, not python3
@wware
wware / using_git-svn.md
Last active November 29, 2018 21:08 — forked from rickyah/using_git-svn.md
A simple guide to git-svn

Getting started with git-svn

git-svn is a git command that allows using git to interact with Subversion repositories.git-svn is part of git, meaning that is NOT a plugin but actually bundled with your git installation. SourceTree also happens to support this command so you can use it with your usual workflow.

Reference: http://git-scm.com/book/en/v1/Git-and-Other-Systems-Git-and-Subversion

Cloning the SVN repository

You need to create a new local copy of the repository with the command

"""
There is an unfortunate thing about Python scoping. You can't easily access the variables
of a calling function (as you can do in Scheme) so if you want to use those variables you
need to jump thru silly hoops. See
https://stackoverflow.com/questions/15608987/access-variables-of-caller-function-in-python
The nice thing about using a caller's variables is that it provides a nice way to do closures.
Variable access in closures will work OK as long as you are not ASSIGNING the variable. In
this case, we assign indices of "scope" but we never assign scope itself -- if we did, Python
would conclude that scope belongs to stuff, not to make_thing. Annoying.