Skip to content

Instantly share code, notes, and snippets.

View tbnorth's full-sized avatar

Terry Brown tbnorth

View GitHub Profile
@tbnorth
tbnorth / piwigo docker password reset .md
Last active August 8, 2020 21:17
piwigo docker password reset

Piwigo docker password reset

Most of the Piwigo password reset instructions assume you're familiar with MySQL or have access to phpAdmin. Here's how to reset a password in a docker deployment of Piwigo, without those assumptions.

  1. Get the MD5 hash of the password you want to use
    echo -n password1234 | m5dsum
@tbnorth
tbnorth / docker.sh
Last active October 3, 2022 14:10
Docker tricks
# compact docker ps
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Names}}"
# *** START: MAINTENANCE ******************************
# remove non-running containers
docker rm $(docker ps -a -q -f status=exited -f status=dead)
# remove untagged images, selects column {2} (zero based) from lines starting with <none>
docker images | grep '^<none>' | sed -nE 's/^(\S+\s+){2}(\S+).*/\2/; p' | xargs docker image rm
# rebase "BRANCH" onto "MAIN", change these as needed
MAIN=main
BRANCH=tmp/docs
# should be no changed files before you start
[ -z "$(git status --porcelain --untracked-files=no)" ] || echo "Changed files in repo."
git checkout "$MAIN"
git pull
git checkout "$BRANCH" # before diff in case no local branch $BRANCH
git diff "$MAIN..$BRANCH" # just to inspect
# "compound 'compound .compound but not <spac>compound or compounds
cexpr system("find PATH -name \\*.py | xargs grep -n [.\\'\\\"]compound\\\\b")
# get list of files from a broken session
sed -n '/^cd / p; /^badd / {s/^badd [^ ]* //; H}; $ {x; s/\n/ \\\n/g; p}' /path/to/sessionfile.vim
# some paths will be relative to a folder, this prints the command to cd to the folder first
@tbnorth
tbnorth / config
Last active December 22, 2019 01:52
HP Intel laptop screen backlight control when xbacklight doesn't work
# i3 config
bindsym XF86MonBrightnessUp exec /home/tbrown/bin/undim # increase screen brightness
bindsym XF86MonBrightnessDown exec /home/tbrown/bin/dim # decrease screen brightness
# /home/tbrown/bin/undim
LVL=$(cat /sys/class/backlight/intel_backlight/brightness)
LVL=$(((LVL+20)%648))
echo $LVL >/sys/class/backlight/intel_backlight/brightness
# dim as above but -20
# check /sys/class/backlight/intel_backlight/max_brightness for % term
# sudo chown a+rw /sys/class/backlight/intel_backlight/brightness
@tbnorth
tbnorth / recgit.py
Created December 3, 2019 15:39
Show git status of all files in folder recursively.
#! /usr/bin/env python
"""
Show git status of all files in folder recursively.
Looks at files git status ignores because they're in
folders with no tracked files.
Handles nested repos.
"""
@tbnorth
tbnorth / .screenrc
Last active December 3, 2019 15:31
Launch multiple named screen sessions, offset date display, etc.
backtick 1 60 60 date -d-1hour +%H:%M
caption always
caption string "%{gk}%-w%{= ky}%45>*%t%{-}%+w%<"
# leave the above in so install_env doesn't re-add it
caption string "%{gk}%1` %-w%{= ky}%45>%t%{-}%+w%<"
# screen bash
shell "/usr/bin/bash"
# bind ^a^c screen bash
@tbnorth
tbnorth / uniqify.sql.sh
Created August 22, 2019 18:06
Script that generates SQL to remove duplicate records from a table
# change these bits then run the script to generate the SQL, e.g.
# <edit file>
# <save file>
# bash uniqify.sql.sh >fix_mytable.sql
# then execute the SQL line by line checking the results, preferably in
# a transaction you can roll back or a copy of the DB
# START OF THINGS TO CHANGE
# the table containing duplicates
"""
docstrings.py - show docstrings for .py files
Terry N. Brown terrynbrown@gmail.com Tue Aug 20 16:25:39 EDT 2019
"""
import argparse
import ast
import os
from functools import reduce
@tbnorth
tbnorth / conflict_notes.md
Last active August 14, 2019 14:13
Notes on conflicts

First thing you usually see is a message like this when you try and push:

TBrown02@LZ2626XTBROWN02 MINGW64 /r/conflictdemo2 (master)
$ git push
To https://github.com/tbnorth/conflictdemo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/tbnorth/conflictdemo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing