Skip to content

Instantly share code, notes, and snippets.

View ndevenish's full-sized avatar

Nicholas Devenish ndevenish

View GitHub Profile
@ndevenish
ndevenish / lattice_viewer.py
Created November 11, 2026 14:38
Basic prototype of lattice viewer with resolution scaling over X
#!/usr/bin/env python3
"""Spike: a reciprocal lattice viewer that behaves well over remote X.
The 3D view is rendered offscreen on the machine the program runs on, read
back as pixels and drawn into an ordinary wx window as an image. The X server
never sees an OpenGL request.
While the user is interacting (rotating, zooming, resizing, moving a slider)
the scene is rendered at 1/N of the window size. That small image is what is
handed to the toolkit, with a scale transform, so that the X server does the
@ndevenish
ndevenish / convert_bob_to_edl.py
Created April 16, 2026 14:49
Convert phoebus screen to EDL
#!/usr/bin/env python3
"""Convert Phoebus .bob to EDM .edl screen format, using DLS house style."""
import argparse
import os
import xml.etree.ElementTree as ET
GROUP_TITLE_HEIGHT = 25
SECTION_LABEL_HEIGHT = 13
@ndevenish
ndevenish / jenkins_missing_dependencies.py
Last active October 23, 2025 07:57
Jenkins: Find/download all plugins for a given Jenkins version
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "bs4",
# "packaging",
# "requests",
# "rich",
# "typer",
# "tqdm",
@ndevenish
ndevenish / final.cu
Created February 24, 2023 10:40
End result of "Ray tracing in a weekend"
#include <cooperative_groups.h>
#include <fmt/core.h>
#include <lodepng.h>
#include <cmath>
#include <cstdio>
#include <limits>
#include <memory>
#include <random>
@ndevenish
ndevenish / wrapped_mamba_environment.py
Created May 28, 2022 11:57
Build a package directory with mamba, but only expose the requested package to PATH
#!/usr/bin/env python3
"""
Build a wrapped mamba environment
Mamba is used to install a package, but then only the parts of the mamba
environment that come from that package are mirrored into a parent
directory structure. This allows you to use mamba to create and manage
the environment, without completely clobbering every other version of
every dependency that might already exist on the users PATH.
@ndevenish
ndevenish / only_in_site_packages.txt
Created May 26, 2022 09:29
CCTBX Header files only in site-packages and not in include/
/annlib/include/ANN/ANN.h
/annlib/include/ANN/ANNperf.h
/annlib/include/ANN/ANNx.h
/annlib/src/bd_tree.h
/annlib/src/kd_fix_rad_search.h
/annlib/src/kd_pr_search.h
/annlib/src/kd_search.h
/annlib/src/kd_split.h
/annlib/src/kd_tree.h
/annlib/src/kd_util.h
@ndevenish
ndevenish / github_get_automerge_message.py
Last active August 22, 2024 08:40
Get a github automerge message, after it's been activated
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "requests",
# ]
# ///
import os
import sys
# conda create -n test1 python=3.9
# conda activate test1
# conda install -c conda-forge cctbx dxtbx
# python
from matplotlib import pyplot as plt
import dxtbx
img = dxtbx.load('test.cbf')
plt.imshow(img.get_raw_data().as_numpy_array())
plt.show()
@ndevenish
ndevenish / bisect.log
Created February 12, 2022 13:32
Bisecting zigbee2mqtt pairing error
git bisect start
# bad: [6ea61bae2cf441e15612dc68c257797fba46312b] 1.23.0
git bisect bad 6ea61bae2cf441e15612dc68c257797fba46312b
# good: [41b67fdd07792a6c6569341d980ec60c1456c2d7] 1.20.0
git bisect good 41b67fdd07792a6c6569341d980ec60c1456c2d7
# bad: [7a198ce4a319234ae17a646fb46fe428a154f4dd] Update zigbee-herdsman to 0.13.164 (#9385)
git bisect bad 7a198ce4a319234ae17a646fb46fe428a154f4dd
# good: [4125ae08888abd697f475ce5d5562a1d1a7de637] TypeScript refactoring (#8567)
git bisect good 4125ae08888abd697f475ce5d5562a1d1a7de637
# bad: [7ccf781b65e2b37928cde2cd4a21d03ddb1643cb] Update zigbee-herdsman-converters to 14.0.264 (#9003)
@ndevenish
ndevenish / ArchiveTarget.cmake
Created September 12, 2021 13:56
Automatically copy a build target to an archive/ directory after build
#[[.md:
# ArchiveTarget.cmake
Utility function for saving a commit ID on build, then archiving the
output target once it has been built. Designed to make it slightly
harder to accidentally delete fpga-build targets, which generally have a
minumum compile time of ~2 hours.
Usage: