Skip to content

Instantly share code, notes, and snippets.

@silvein
silvein / podman@.service
Last active May 29, 2020 06:00
Podman SystemD service
[Unit]
Description=Podman Container : %I
[Service]
Restart=always
RestartSec=30
StartLimitInterval=600
StartLimitBurst=3
ExecStart=/usr/bin/podman start -a %i
ExecStop=/usr/bin/podman stop -t 30 %i
@silvein
silvein / compress-tables.sh
Created October 31, 2012 19:25 — forked from deviantintegral/compress-tables.sh
Compress MySQL Tables
#!/usr/bin/env bash
# Compress MySQL tables on disk.
# Author: Andrew Berry, andrew.berry@lullabot.com
#
# Compress all tables in a MySQL InnoDB database using compression from the
# Barracuda table format. Tables have to already be in the Barracuda file
# format to actually compress tables, otherwise the table setting is ignored.
#
# innodb_file_per_table = 1 MUST be set in my.cnf for compression to work.
@silvein
silvein / period-sizes.sh
Created April 13, 2011 02:47
This is a one-liner to sum the total size of all files (in gigabytes) in a specific directory and period (monthly).
#!/bin/bash
find $1 -type f -printf "%CY%Cm %s %p\n" |
/usr/bin/awk '{ total[$1] += $2 } END { for (period in total) printf "%s: %f\n", period, total[period]/1024^3 }' |
sort
@silvein
silvein / pre-commit
Created March 26, 2011 07:52
This is a Git pre-commit hook I'm developing to make sure local submodule changes are pushed before committing. This would probably be better as a pre-push hook, but there does not appear to be a facility for that.
#!/bin/bash
function git_submodule_unchanged () {
SUB_MODULE=$1
GSC_RC=0
pushd $SUB_MODULE > /dev/null
SUB_BRANCH=$(git branch | grep '*' | cut -d' ' -f 2)
if [[ "$(git log --pretty=oneline origin/${SUB_BRANCH}..${SUB_BRANCH})" != "" ]]; then
GSC_RC=1
fi
@silvein
silvein / gist:752363
Created December 23, 2010 00:27
A bash function (I keep it in my .bash_profile) for remuxing mkv files to mp4
function mkv2mp4 {
INPUT_FILE="$1"
OUTPUT_FILE="${INPUT_FILE%.*}.mp4"
if [[ "" == "${INPUT_FILE}" ]]; then echo "Usage: mkv2mp4 <file.mkv>" && return 1; fi
if [[ ! -f "${INPUT_FILE}" ]]; then echo "Argument not a file." && return 1; fi
if [[ -f "${OUTPUT_FILE}" ]]; then echo "Output file '$OUTPUT_FILE' already exists." && return 1; fi
ffmpeg -vcodec copy -acodec copy -map_meta_data outfile:infile -i "${INPUT_FILE}" "${OUTPUT_FILE}"
}