Skip to content

Instantly share code, notes, and snippets.

View Roadmaster's full-sized avatar

Roadmaster Roadmaster

  • Montreal, QC, Canada
  • 20:19 (UTC -04:00)
View GitHub Profile
@Roadmaster
Roadmaster / gist:08c44bf715feb80017720317bbdfd42f
Created October 5, 2018 20:05
how to ssh into local lxd containers
# snippet for .ssh/config
Host *.lxd
#User ubuntu
#StrictHostKeyChecking no
#UserKnownHostsFile /dev/null
ProxyCommand nc $(lxc list --format csv -c s4 $(echo %h | sed "s/\.lxd//g") %h | python3 -c "import csv,sys; print([ip for ip in [e.split('\n') for s,e in list(csv.reader(sys.stdin)) if s == 'RUNNING'][0] if
'eth' in ip][0].split(' ')[0])") %p
https://discuss.linuxcontainers.org/t/lxd-netplan-static-ips-in-same-subnet-how-to/1074/7
$ lxc profile show lan
config: {}
description: ""
devices:
br0:
nictype: bridged
parent: br0
type: nic
@Roadmaster
Roadmaster / gist:6a4814ee253d055475e4b2cc64e688e1
Created January 31, 2018 23:32
Fix for kuard's build.sh script because npm/node/etc is suck a brainfuckery
diff --git a/build/build.sh b/build/build.sh
index 485c6ca..df82658 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -45,6 +45,8 @@ export GOARCH="${ARCH}"
(
cd client
npm install --loglevel=error
+ chmod 755 ./node_modules/webpack/bin/webpack.js
+
@Roadmaster
Roadmaster / snap-lxc.sh
Created October 27, 2017 21:21
snap-lxc.sh
#!/bin/bash
# Create lxc profile that allows using snaps in the container
NAME=snap
lxc profile create $NAME &> /dev/null || true
cat << EOF | lxc profile edit $NAME
name: $NAME
description: Set up snaposity
config:
security.nesting: "true"
user.vendor-data: |
env PROMETHEUS=/usr/bin/prometheus
env CONFIG=/etc/prometheus/prometheus.yml
env USER=prometheus
env GROUP=prometheus
env DEFAULTS=/etc/default/prometheus
env RUNDIR=/var/run/prometheus
env PID_FILE=/var/run/prometheus/prometheus.pid
pre-start script
[ -e $DEFAULTS ] && . $DEFAULTS
@Roadmaster
Roadmaster / google-chrome-lxc.sh
Created October 18, 2017 21:16
Set up an lxc container with google chrome so it runs confined but displays on localhost.
#!/bin/bash
# Set up an lxc container with google chrome so it runs confined but displayed on the
# localhost.
# Adapted from https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/
# Assume setguid/setid for root is properly setup
# root:1000:1
# Assume aptcache profile exists, see https://gist.github.com/Roadmaster/754110f3f49fef19ec89ae29f29edd11
LXC_NAME=chrome-container
@Roadmaster
Roadmaster / aptcaching.sh
Last active February 4, 2024 00:20
Create an lxc profile enabling use of an apt cache
#!/bin/bash
# Create lxc profile with apt caching
# Requires installing apt-cacher-ng to 10.0.4.1 (your host)
# Could be improved by making the actual apt cache host tunable
# Then use like:
# lxc launch -p default -p aptcache ubuntu:16.04 my-cached-container
NAME=aptcache
CACHE_IP=$(ip addr list lxdbr0 | grep -Po 'inet \K[\d.]+')
if ! ping -c 1 "$CACHE_IP" -w 1 >/dev/null 2>&1; then
@Roadmaster
Roadmaster / gist:c00f8aa205ccbe003f6fd24549effe02
Created October 5, 2017 18:52
snap building scripts and yamls
namespace=${1:-tomechangosubanana}
name=${2:-1}
rev=${3:-2}
cat > snapcraft.yaml <<EOF
name: hello-$namespace-$name
version: $rev
summary: say hello
confinement: strict
grade: stable
name: lsdalton-roadmr
version: '1.3'
summary: LsDalton quantum chemistry program
description: |
LsDalton quantum chemistry program or computing Hartree-Fock and DFT wave
functions, energies, and molecular properties. For correlated models, MP2
geometry optimizations and CCSD energies (not linear-scaling) are available.
Most parts of lsDalton employ linear scaling and massively parallel
implementations, which makes it suitable for calculations on large molecular
systems, in particular when the calculations are carried out on large super
@Roadmaster
Roadmaster / bisecter.py
Created October 4, 2017 21:31
Python unit test bisecter
#!/usr/bin/python3
"""
Find which test in the test list is causing the failure of a known-failing
test. That is - Given a test list which dictates a specific test order,
under which a test X (which passes when run in isolation) is failing, find
out which of the tests that, on the list, run before X, are causing it to
fail.
Many of our test runs use parallelization to run faster. Sometimes we see test
failures which we can't reproduce locally, because locally we usually run