Skip to content

Instantly share code, notes, and snippets.

View prehensilecode's full-sized avatar

David Chin prehensilecode

View GitHub Profile
@prehensilecode
prehensilecode / apple_epub_to_std_epub.sh
Last active June 21, 2025 16:11
Convert single Apple epub to standard epub
#!/bin/bash
# Based on: https://www.reddit.com/r/Calibre/comments/dza1zi/comment/lxz97q5/
# Except this just does a single Apple epub, which is a directory (folder);
# loop over it to do a directory.
# WARNING: DOES NOT HANDLE BOOKS WITH DRM
# Downloaded Apple Books books are in:
# ~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books
# Books in iCloud are in:
# ~/Library/Mobile Documents/iCloud~com~apple~iBooks/Documents
@prehensilecode
prehensilecode / reinstall_pip_pkgs.sh
Last active April 18, 2025 00:54
Re-install all pip packages retaining the same version
#!/bin/bash
# tested on pip 25.0.1
# XXX this is probably not a good idea
for pkg in $( python3 -m pip list | tail -n+3 | awk '{print $1 "==" $2}' )
do
python3 -m pip install -U --force-reinstall "${pkg}"
done
@prehensilecode
prehensilecode / kindle_bulk_download.js
Last active February 21, 2025 20:02 — forked from lfhbento/userscript.js
Download all your Kindle books before Feb 26, 2025
// ==UserScript==
// @name Kindle Download
// @namespace http://tampermonkey.net/
// @version 2025-02-20
// @description Download all your kindle books
// @author You
// @match https://www.amazon.com/hz/mycd/digital-console/contentlist/booksAll/dateDsc/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.com
// @grant none
// ==/UserScript==
@prehensilecode
prehensilecode / fsl.def
Last active February 18, 2025 19:33
Apptainer def file for FSL
Bootstrap: debootstrap
OSversion: focal
MirrorURL: https://us.archive.ubuntu.com/ubuntu/
%environment
export FSLDIR="/usr/local/fsl"
export DEBIAN_FRONTEND="noninteractive"
export LANG="en_US.UTF-8"
%post
@prehensilecode
prehensilecode / remove_nvidia_from_initramfs.sh
Created December 2, 2024 15:23
Remove Nvidia & Nouveau kernel modules from initramfs and make persistent
#!/bin/bash
# Removes both nvidia and nouveau drivers from initramfs and rebuilds them.
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [[ $( id -u ) -ne 0 ]]
then
echo "This must be run as root"
exit 1
else
kernelversion=$(uname -r)
@prehensilecode
prehensilecode / snapshotter.py
Last active July 18, 2024 20:56
GPFS snapshotter script
#!/usr/bin/env python3.6
# Author: David Chin [email protected]
import sys
import os
import shlex
import subprocess
import argparse
import datetime
import calendar
from pathlib import Path
@prehensilecode
prehensilecode / tunnel_to_cluster_node_mgmt_port.md
Last active March 6, 2024 16:32
Tunnel to cluster node XCC or DRAC

Set up tunnel:

 ssh -L 1443:clusternode-xcc:443 adminuser@adminhost

Then, run web browser on PC connecting to

https://localhost:1443
@prehensilecode
prehensilecode / oh_my_zsh_tips.md
Last active October 26, 2023 19:49
Oh My Zsh tips

Oh My Zsh tips

  • To see all 256 possible colors and their IDs:
    • spectrum_ls
    • spectrum_bls
  • for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
@prehensilecode
prehensilecode / HOWTO_build_NCI-GDC-gdc_client.md
Last active September 11, 2023 14:36
HOWTO build NCI-GDC/gdc_client

HOWTO build NCI-GDC/gdc_client

Notes on building https://github.com/NCI-GDC/gdc-client

Issue

Following their instructions, get error in building lxml Python package:

Building wheels for collected packages: lxml
  Building wheel for lxml (setup.py): started