Skip to content

Instantly share code, notes, and snippets.

@xtenduke
xtenduke / 50-system-lenovo.quirks
Created August 18, 2024 21:22
Libinput trackpoint quirk for P1/X1 Extreme missing modelname
#/usr/share/libinput/50-system-lenovo.quirks
[P1 Gen 2 slash X1E Gen2]
MatchUdevType=pointingstick
MatchName=*TPPS/2 Elan TrackPoint*
MatchDMIModalias=dmi:*:*
AttrTrackpointMultiplier=0.4
@xtenduke
xtenduke / .Xmodmap
Last active April 7, 2023 07:33
CapsModmap
# install xmodmap from x11-xserver-utils
# xmodmap ~/.Xmodmap
! Capslock is another escape
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
@xtenduke
xtenduke / build-image.sh
Last active May 3, 2022 12:16
build qemu image
set -x
# create empty image
truncate -s500m build/alpine-vm-arm64.img
# Format the image with a gpt table
parted -s build/alpine-vm-arm64.img mktable gpt
# bootable partiton
parted -s build/alpine-vm-arm64.img mkpart ext4 1 "100%"
@xtenduke
xtenduke / Dockerfile
Last active May 3, 2022 02:26
Dockerx build multiarch node - multistage
FROM node:14.17.0 AS install
WORKDIR /app
COPY ["package.json", "yarn.lock", "./"]
COPY . .
RUN yarn install
RUN yarn build
ENV NODE_ENV=production
FROM node:14.17.0-alpine as run
@xtenduke
xtenduke / module-explorer.ts
Created May 2, 2022 05:41
NestJS get injected instance by name
// Pull out instance of a class from moduleContainer
// 'nicer' alternative to globals
// loops over all instances in a module, so probably don't do this at runtime
import {Injectable, Inject} from "@nestjs/common";
import {ConfigType} from "@nestjs/config";
import {ModulesContainer} from "@nestjs/core";
import {InstanceWrapper} from "@nestjs/core/injector/instance-wrapper";
const config.name = 'MyInjectedClass';
@xtenduke
xtenduke / caps.reg
Created December 11, 2021 16:10
Windows set capslock as esc
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,0
@xtenduke
xtenduke / eject.sh
Created February 1, 2021 04:14
Gnome AMD EGPU eject
# AMD EGPU EJECT GNOME
# I offer absolutely no warranty using this software
# Instructions:
# - Ctrl + Alt + F2 to enter console
# - run script as root
# - wait 5 seconds and unplug your egpu
# - wait for gdm to restart
#!/bin/bash
@xtenduke
xtenduke / dockerStopAll.sh
Last active February 7, 2026 23:10
Stop all docker containers
#!/bin/bash
count='0'
function getRunningCount() {
count=$(docker ps -q | wc -l)
}
echo "Stop all Docker containers..."
getRunningCount
if [ "$count" -eq "0" ]; then
@xtenduke
xtenduke / SectionAdapter.kt
Last active February 7, 2026 23:10
Android Kotlin section recycler adapter
/*
* This class is designed implement a 'similar' structure to TableView sections from iOS UIKit
*/
abstract class SectionAdapter<VH : RecyclerView.ViewHolder> : RecyclerView.Adapter<VH>() {
/**
* Override getItemCount to instead call getItemCount(section: Int)
*/
override fun getItemCount(): Int {
val sectionCount = getSectionCount()