Skip to content

Instantly share code, notes, and snippets.

@ibressler
ibressler / MDM Profiles on macOS.md
Last active December 9, 2024 07:41
MDM Profiles on macOS

MDM Profiles on macOS

Notes: From Zeno Popovici with edits & tested on a M1 macbook with Ventura (macOS 13).

In macOS you can check the MDM status with the following command in a Terminal:

profiles status -type enrollment

Non-removable MDM profiles cannot officially removed without doing a full system wipe

@ibressler
ibressler / Add LUKS2 support to GRUB bootloader UEFI image.md
Last active November 29, 2023 15:07
Add LUKS2 support to GRUB bootloader UEFI image

Add LUKS2 support to GRUB bootloader UEFI image

  • Assuming a Linux live or rescue system is booted and the new soon-to-be root encrypted partition is accessible on an NVMe drive, 2nd partiton (/dev/nvme0n1p2).
  • The EFI partition is the first on the device (/dev/nvme0n1p1).
  • There is no extra /boot partition since it should be encrypted as well and is included in the partition mounted as root / later.
  • The following requires root privileges, a preceeding sudo -i is assumed.

Inspired by: https://askubuntu.com/questions/1397826/default-embedded-modules-in-bootx64-efi-grubx64-efi-and-mmx64-efi/1466507#1466507

1. Get chroot

@ibressler
ibressler / Setup Python on Win unpriv non-Anaconda.md
Last active November 29, 2023 15:10
Setup Python on Windows for unprivileged non-admin users, replacing Anaconda

Setup Python on Windows for unprivileged non-admin users and replacing Anaconda

  • Uses a recent Miniforge including mamba and the conda-forge channel and is a recommended replacement of the Anaconda distribution which ships a buggy and unreliable package manager (conda)
  • side-effect: Its published under BSD-style license, no trouble with individual vs. corporate use

Install mamba

  1. Download the latest installer from the releases page. The windows installer is often hidden behind the show all assets button and the file name should be something like Miniforge3-x.y.z-1-Windows-x86_64.exe.
  2. Installation should work for an unprivileged user inside their user directory or in the AppData\Local subdirs, for example. In tests it worked with anti-virus enabled but this depends on the restrictiveness of the AV settings, of course.
@ibressler
ibressler / .cookiecutterrc
Created November 1, 2022 17:15
cookiecutterrc-pylibrary
# This file exists so you can easily regenerate your project.
# (last working commit on Sep.9: f47a8cff4)
#
# cookiecutter --overwrite-if-exists --config-file=.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary --checkout f47a8cff4
default_context:
# Verbose project name, used in headings (docs, readme, etc).
project_name: 'Jupyter Analysis Tools'
project_short_description: 'Common Python helpers used in data analysis notebooks (.ipynb) with GIT'
@ibressler
ibressler / 99_ddnss_update
Last active November 15, 2024 14:26
ddnss update script
#!/bin/sh
# derived from https://www.ddnss.de/info.php
# To be stored in /etc/dhcp/dhclient-exit-hooks.d/99_ddnss_update
# Updates the specified subdomain $HOSTNAME with the current IP address.
UPDATE_KEY="<your update key displayed in the dashboard>"
HOSTNAME="<your domain name with ddnss>"
DDNSS_PATH="/var/opt/ddnss" # use a directory which survives a reboot
ALLHOST="" # 'all' for updating all hosts in the account
@ibressler
ibressler / exif_rename_iphone_pics.sh
Created June 16, 2019 18:10
Rename iPhone pictures by embedded timestamp and associated MOV video files
for fn in *.JPG; do
echo "=> $fn"
# get the timestamp from exif, format it accordingly
ts=$(exiv2 -g DateTimeOriginal $fn | awk '{ts=$(NF-1)"_"$NF; gsub(":","",ts); print ts}')
# retrieve the base name as well
basen=${fn%.*}
# rename the image, append its original name
mv -i "$fn" "${ts}_$basen.jpg"
# check if there is video file with the same name (live mode)
if [ -f "$basen.MOV" ]; then
@ibressler
ibressler / fix_broken_exif.sh
Created June 16, 2019 14:57
fix exif metadata containing wrong keys and datetime with binary character
fn="$1"
echo "fn: $fn"
[ -f "$fn" ] || exit 1
str="$(exiv2 -p a "$fn" 2>&1 | grep -a Exif.Image.DateTime | grep -a -o '2019:.*$')"
#echo "'$str'"
# fix datatime first
exiv2 -M"set Exif.Image.DateTime $str" "$fn"
# extract all readable metadata (to .xmp file)
exiv2 -eaX "$fn"
# delete all metadata
@ibressler
ibressler / gist:2bfbda39665e0371c70bb45e1b0d5ccf
Created July 4, 2018 13:42
Optimize PDF files on Linux
# as per https://stackoverflow.com/q/10450120
# PDFSETTINGS: http://milan.kupcevic.net/ghostscript-ps-pdf/
gs -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile=test.pdf "$INFILE"
@ibressler
ibressler / earlygrubcryptoimg.sh
Last active March 10, 2024 22:49
Creates an early grub core image for ESP to cryptmount a LUKS+LVM partition where the grub files /boot/ and the kernel is stored
#!/bin/dash
# Creates a standalone core image with grub to be started by EFI.
# It complements the excellent cryptroot tutorial at
# https://community.linuxmint.com/tutorial/view/2061
# for grub on BTRFS inside LVM inside LUKS.
#
# It initiates decryption of the root device which contains
# LVM with BTRFS on the root volume where grub is installed.
# Therefore, it allows to load grub from an LUKS encrypted BTRFS
# root file system.
@ibressler
ibressler / lcnc_mdi-queue.patch
Last active February 10, 2017 11:51
LinuxCNC MDI queue quick fix
diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c
index da081d4..58cd81d 100644
--- a/src/emc/motion/command.c
+++ b/src/emc/motion/command.c
@@ -1026,7 +1026,7 @@ void emcmotCommandHandler(void *arg, long period)
emcmotStatus->atspeed_next_feed = 1;
}
/* append it to the emcmotDebug->coord_tp */
- tpSetId(&emcmotDebug->coord_tp, emcmotCommand->id);
+// tpSetId(&emcmotDebug->coord_tp, emcmotCommand->id);