Skip to content

Instantly share code, notes, and snippets.

@bendavis78
bendavis78 / capslock_super_esc.md
Last active June 16, 2024 23:07
Mapping Caps Lock to simultaneous Esc and Super (Mod4)

Mapping Caps Lock to simultaneous Esc and Super (Mod4)

The CAPS key can be mapped to an escape key when pressed once, and a super (mod4) key when used in combination with other keys.

Create the file /usr/share/X11/xkb/symbols/custom_opts with the following:

// Make Caps an additional Escape
hidden partial modifier_keys
xkb_symbols "super_esc" {

key { [ Escape ] };

@bendavis78
bendavis78 / paru-find-dep-reason.sh
Created June 12, 2024 23:35
Find packages that are causing issues during paru upgrade
#!/bin/bash
# Require argument for the package name
if [ -z "$1" ]; then
# only show script name in usage
echo "Usage: $(basename $0) <package_name>"
exit 1
fi
pkgname="$1"
@bendavis78
bendavis78 / db_backup.sh
Last active June 6, 2024 19:40
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
@bendavis78
bendavis78 / extract_pdf_images.sh
Created January 16, 2020 19:30
Extracts images from PDF while preserving PNG transparency
#!/bin/bash
usage() {
echo "Usage: $(basename $0) in.pdf dest";
}
[[ -z "$1" ]] && usage && exit 1;
[[ -z "$2" ]] && usage && exit 1;
TMPDIR="$(mktemp -d)";
DIR=$2;
@bendavis78
bendavis78 / seed_pagination.py
Last active April 1, 2024 10:31
Example implementation of randomized pagination in django and django-rest-framework
"""
Adds a `seed` paramter to DRF's `next` and `prev` pagination urls
"""
from rest_framework import serializers
from rest_framework import pagination
from rest_framework.templatetags.rest_framework import replace_query_param
from . import utils
@bendavis78
bendavis78 / chromeos-recovery.md
Created December 20, 2018 04:06
Chrome OS recovery images manual download
@bendavis78
bendavis78 / uwsgi_custom_build.md
Last active November 6, 2023 15:53
Building uwsgi w/ support multiple python versions

Installation

Remove all traces of uwsgi on the system, if previously installed

apt remove uwsgi uwsgi-core
rm /usr/bin/uwsgi
rm /usr/local/bin/uwsgi
rm -rf /usr/lib/uwsgi
rm -rf /usr/local/lib/uwsgi

Any config files in /etc can stay.

@bendavis78
bendavis78 / brick.py
Created October 2, 2023 17:41
Brick tutorial using 123d CAD library
from build123d import *
from ocp_vscode import *
C, MIN, MAX = Align.CENTER, Align.MIN, Align.MAX
pip_count = 6
brick_unit_size = 8
pip_height = 1.8
pip_diameter = 4.8
@bendavis78
bendavis78 / resize-stateful-partition.sh
Last active September 28, 2023 23:17
Script to re-size stateful partition on ChromeOS
#!/bin/bash
red="\E[1;31m";
green="\E[1;32m";
yellow="\E[1;33m";
plain="\e[0m";
error() {
echo -e "${red}${1}${plain}";
}
@bendavis78
bendavis78 / gist:6f7f6bc9c75e21094a54fc020cc054ee
Last active September 25, 2023 01:18
build123d installation on macos apple silicon m1
# As of 9/24/2023
# This requires conda, mamba, or micromamba
micromamba create -n code_cad python=3.10 -c conda-forge
micromamba -n code_cad install -c cadquery -c conda-forge cadquery=master
micromamba -n code_cad run pip install \
'typing_extensions~=4.4.0' 'numpy~=1.24.1' 'svgpathtools~=1.5.1' \
'anytree~=2.8.0' 'ezdxf~=1.0.0' 'numpy-stl~=3.0.0' 'ipython~=8.0.0' \
'git+https://github.com/CadQuery/OCP-stubs@7.7.0#egg=OCP-stubs' \
'git+https://github.com/jdegenstein/py-lib3mf#egg=py_lib3mf'
micromamba -n code_cad run pip install --no-deps git+https://github.com/gumyr/build123d