Skip to content

Instantly share code, notes, and snippets.

View chaddupuis's full-sized avatar

Chad Dupuis chaddupuis

View GitHub Profile
chaddupuis / deepdicomsort-dcm2-fsl.def
Created April 15, 2024 15:46
apptainer build for deepdicomsort-dcm2niix-fsl on rockylinux8
Bootstrap: docker
From: rockylinux:8.9
dnf -y update
dnf -y install epel-release curl wget git file bzip2 which libmng libpng12 libSM gtk2 mesa-dri-drivers mesa-libGL-devel
dnf config-manager --set-enabled powertools
dnf -y install R
# R brings in openblas and dependencies
dnf -y install make cmake
chaddupuis /
Last active November 30, 2023 23:04
macOS Cisco AnyConnect CLI Connect Without Password (using macOS keychain)
VPNNUM=#you might not have a choice here, so possibly not needed
PASS=$(security find-generic-password -a yourusername -l yourkeylistitem -w)
/usr/bin/expect -f - <<EOD
set timeout 20
chaddupuis /
Created November 14, 2023 21:11
Docker - Allow Communication Between Two Bridged Networks On Same Host (via iptables)
## If docker containers are running on two separate bridge networks,
## by default they cannot communicate
## To selectively allow this you can use iptables rules to allow communication.
## This script, connects an app ("webapp") to a database ("postgres") running on separate networks.
postgresip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres)
webappip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' webapp)
chaddupuis /
Created August 7, 2023 14:37
linux - ls files into a csv (without dot files and without the created csv)
find . -type f \( ! -iname ".*" ! -iname "mydir.csv" \) -exec basename {} \; | xargs | tr -s ' ' , > mydir.csv
chaddupuis /
Created August 2, 2023 20:35
Update outdated python packages in docker container and write out new requirements.txt
#!/usr/bin/env bash
#set -euo pipefail
# no set -e has diff results in non-zero
echo "Checking Inside of Container For Outdated Pip"
hostdatetime=$(date +"%d-%m-%y-%H-%M-%S")
docker exec -i yourcontainer /bin/sh -c 'python3 -m pip list --outdated'
chaddupuis /
Last active July 13, 2023 15:10
Recover Data From A Multipass Qemu VM Image That Won't Start on MacOS M1/M2 (using linux)

Multipass on MacOS m1/m2 machines has had some ongoing issues with VM's working for awhile then failing to start. Previously, through some combination of these steps, I could get multipass working again and access my previous builds. After losing some data a couple of times this way, I've decided to ditch multipass for now. Unfortunately, this one time I had some data from an unfinished build that I had to get off one of the vm images that I could no longer start.

I tried a few ways of doing this solely on the mac, but I ended up copying the image file over to a desktop running suse/tumbleweed (distro shouldn't matter for these) and accessing the files there. Here are the general steps:

  • Find your vm image (need sudo). On a mac these should be in /var/root/Library/Application\ Support/multipassd/qemu/vault/instances/ - then in a folder with the name of your vm, grab the .img file and copy it somewhere and chown it to your local account.

  • Copy the

chaddupuis /
Created December 21, 2022 19:26
Django Recaptcha fix for SSL:CERTIFICATE_VERIFY_FAILED unable to get local issuer
There are likely a few fixes for this but you are likely to see this error
if your app needs to reach out to an https server (in this case
and it cannot verify the ssl certificate.
The certifi package ( ) provides a
curated collection of Root Certificates that avoids this.
pip install certifi - then in your settings you just need to set
the environmental variable for REQUESTS_CA_BUNDLE and SSL_CERT_FILE.
chaddupuis / nginx-ansible-server.yaml
Created December 21, 2022 19:23
Ansible to build an nginx server with certbot
# post base server setup
# nginx, pulls confs from git repo
# certbot setup and general firewall conf
- hosts: nginxweb
become: yes
my_ip_range: x.x.x.x/24
my_jump_ip: x.x.x.x
chaddupuis /
Created December 21, 2022 19:21
Lego (acme go client) bash script for renewals (with SAN lists)
# Likely in a cron job to handle cert renewals.
# The acme go client is here -
chaddupuis /
Created December 21, 2022 19:18
Django Full Text Search using Postgres SearchQuery with Faceted and Paginated Results
from django.db import models
from django.utils.text import slugify, Truncator
from django.db.models.functions import Lower
from django.db.models.signals import pre_save, post_save, post_delete, m2m_changed
from import SearchVectorField, SearchVector
from django.contrib.postgres.indexes import GinIndex
from django.db.models import Value
import re