Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / capslock_super_esc.md
Last active October 25, 2023 22:11
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 / 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

Using Python w/ Minecraft on Ubuntu

These instructions should work on any Ubuntu-based OS, but have only been tested on GalliumOS.

Install required packages

Copy and paste the following line into a terminal and press enter to install all the dependencies (you might already have some installed):

sudo apt update
sudo apt install python-software-properties python3 python3-pip idle3 git
sudo apt install openjdk-8-jre-headless openjdk-8-jdk maven
{
"home_assistant": {
"installation_type": "Unknown",
"version": "2022.12.3",
"dev": false,
"hassio": false,
"virtualenv": false,
"python_version": "3.10.8",
"docker": false,
"arch": "x86_64",