Skip to content

Instantly share code, notes, and snippets.

Check log sizes
```
docker inspect --format='{{.LogPath}}' $(docker ps -a -q) | sudo xargs -n 1 du -ah | sort -h
```
@ineentho
ineentho / test-dockerignore.sh
Last active August 3, 2020 15:46
List all files sent to a docker build
#!/bin/sh
docker image build -t test-dockerignore -f - > /dev/null . <<EOF
FROM alpine
COPY . /test-dockerignore
EOF
docker run --rm test-dockerignore sh -c 'cd /test-dockerignore; find -mindepth 1'
docker image rm test-dockerignore > /dev/null
@ineentho
ineentho / 1. systemd-as-cron.md
Last active June 14, 2020 16:54
Using systemd services as a cron replacement

Create service file:

sudo EDITOR=nvim systemctl edit --force --full my-cron-service.service

Create timer file:

sudo EDITOR=nvim systemctl edit --force --full my-cron-service.timer
@ineentho
ineentho / docker-commands.sh
Created April 1, 2020 08:19
docker commands
sudo docker ps --format '{{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}' | sed -E 's/PREFIX/REPLACE/; s/-([0-9a-z]{8})([0-9a-z]{32})/-\1/' | column -t -s $'\t'
@ineentho
ineentho / sway-cycle-workspace
Last active March 26, 2020 13:42
Cycle the current workspace between all available outputs in sway
#!/bin/sh
# dependencies:
# - jq (pacman -S jq, apt install jq, etc)
outputs_json=$(swaymsg -t get_outputs)
num_outputs=$(echo "$outputs_json" | jq 'length')
focused_output_index=$(echo "$outputs_json" | jq '[.[].focused] | index(true)')
@ineentho
ineentho / docker-vol-fns.sh
Created March 23, 2020 08:05
Docker volume backup and restore
#!/bin/sh
vol-backup() {
docker run --rm -v $1:/data -v $(pwd):/backup busybox tar cvf /backup/$1.tar /data
}
vol-restore() {
docker create -v $1:/data --name $1 busybox true
docker run --rm --volumes-from $1 -v $(pwd):/backup busybox tar xvf /backup/$1.tar
docker rm $1
@ineentho
ineentho / .vim
Created October 25, 2019 14:49
vim indentation settings
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
// ==UserScript==
// @name T4C Automatic Login
// @namespace http://tampermonkey.net/
// @version 0.1
// @author Henrik Karlsson
// @author You
// @match http://192.168.0.55/*
// @grant none
// ==/UserScript==
'use strict'