Skip to content

Instantly share code, notes, and snippets.

View jack89roberts's full-sized avatar

Jack Roberts jack89roberts

  • The Alan Turing Institute
  • London
View GitHub Profile
@paul-krohn
paul-krohn / docker_x11_macOS.md
Last active March 23, 2024 09:30
Docker X11 macOS

Preamble

There is a longstanding issue/missing feature/bug with sockets on Docker on macOS; it may never work; you'll need to use a network connection between Docker containers and X11 on macOS for the foreseeable future.

I started from this gist and made some adjustments:

  • the volume mappings aren't relevant/used, due to the socket issue above.
  • this method only allows X11 connections from your Mac, not the entire local network, which would include everyone on the café/airport WiFi.
  • updated to include using the host.docker.internal name for the the container host, instead.
  • you have to restart XQuartz after the config change.
@malexer
malexer / configparser_env.py
Last active November 20, 2023 09:38
Python 3: ConfigParser with expanding Environment variables
import configparser
import os
class EnvInterpolation(configparser.BasicInterpolation):
"""Interpolation which expands environment variables in values."""
def before_get(self, parser, section, option, value, defaults):
value = super().before_get(parser, section, option, value, defaults)
return os.path.expandvars(value)
@bhtucker
bhtucker / upsert.py
Last active April 3, 2024 15:56
A demonstration of Postgres upserts in SQLAlchemy
"""
Upsert gist
Requires at least postgres 9.5 and sqlalchemy 1.1
Initial state:
[]
Initial upsert: