Skip to content

Instantly share code, notes, and snippets.

@mattbell87
mattbell87 / run_in_container.sh
Last active February 28, 2024 02:33
Run a command in a container
#!/bin/bash
# Link this file to /usr/local/bin/<command-name>
exec=$(basename $0)
container="container"
user="root"
dockerCmdNonInteractive="docker exec -u $user $container"
dockerCmd="docker exec -it -u $user $container"
display="🫙 $user@$container:$($dockerCmdNonInteractive pwd)\$ $exec $*"
@mattbell87
mattbell87 / docker-compose.yml
Last active March 5, 2024 02:34
Cmfive minimal docker compose setup
services:
cmfive:
image: ghcr.io/2pisoftware/cmfive:develop
environment:
- TZ=Australia/Sydney
- DB_HOST=mysql
- DB_DATABASE=cmfive
- DB_USERNAME=cmfive
- DB_PASSWORD=cmfive
- ENVIRONMENT=development
@mattbell87
mattbell87 / docker-compose-healthcheck.sh
Created February 21, 2024 13:32
Get unhealthy container logs in a docker-compose project
#!/bin/sh
services=$(docker compose config --services)
for service in $services; do
echo "Service: $service"
container=$(docker-compose ps -q $service)
if docker inspect $container --format='{{.State.Health.Status}}' >/dev/null 2>&1; then
health=$(docker inspect --format='{{json .State.Health.Status}}' $container)
if [ "$health" != "\"healthy\"" ]; then
echo "CONTAINER IS NOT HEALTHY"
echo "==== STATUS ===="
@mattbell87
mattbell87 / install.sh
Created January 31, 2024 00:54
Playwright dependencies for Fedora
sudo dnf install atk at-spi2-atk libXcomposite libXdamage libXfixes libXrandr libgbm alsa-lib
@mattbell87
mattbell87 / keybase.md
Last active September 13, 2023 00:07
Keybase proof

Keybase proof

I hereby claim:

  • I am mattbell87 on github.
  • I am mattbell87 (https://keybase.io/mattbell87) on keybase.
  • I have a public key ASA-J1e_FaU-dfkUv-CmkXW6L1AnDl-JzI541JezR5kLiQo

To claim this, I am signing this object:

@mattbell87
mattbell87 / docker-compose.yaml
Last active November 1, 2022 03:19
Run a React Native Android app in Docker
# Run a react native app on docker
#
# Ensure you have enough space (>32GB) and plenty of CPU power if you're running in Codespaces
#
# 1. docker-compose up -d (or right click this file in VS code and choose Compose Up)
# 2. Once started go to http://localhost:6080 (or right click the dev container and choose Open in Browser in VSCode). You should see the android phone starting up
# 3. Log in to your container with `docker exec -it react-native-dev bash` (or right click the dev container and choose Attach Shell in VSCode)
# 4. Run `npm run android` to start your app (can take quite a while the first time you do this)
services:
@mattbell87
mattbell87 / gist:63f2771b5432c10179530eb9d7a1ffe4
Last active July 14, 2022 23:48
When windows wont give you a port

Sometimes Windows wont let you open a port and there is no process using that port. Usually this is due to WinNat, you just need to restart it.

Open an administrator prompt (powershell/cmd) and:

net stop winnat
net start winnat
@mattbell87
mattbell87 / ort.md
Last active March 28, 2023 23:12
How to convert ONNX to ORT

This example uses Docker to install a specific Python version

One liner version

Given the file /home/matt/mobilenetv2-7.onnx as an example replace /home/matt and mobilenetv2-7.onnx as needed.

docker run --rm -v /home/matt:/mnt python:3.9-buster bash -c "pip install onnx onnxruntime && python -m onnxruntime.tools.convert_onnx_models_to_ort /mnt/mobilenetv2-7.onnx"
@mattbell87
mattbell87 / dummy-audio.md
Created June 16, 2022 06:11
Dummy audio on linux

Enable dummy audio on linux. Can be useful for headless servers.

  1. Install snd-dummy kernel module (might be installed already)
  2. Enable the module with modprobe snd-dummy
  3. To make it persist across reboots add snd-dummy to /etc/modules
@mattbell87
mattbell87 / ImageUtils.java
Created April 1, 2022 06:03
Port of ImageUtil.kt from ONNX Runtime Android Example to Java
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software