Skip to content

Instantly share code, notes, and snippets.

View ndevenish's full-sized avatar

Nicholas Devenish ndevenish

View GitHub Profile
@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:
@ndevenish
ndevenish / refl_loader.py
Last active January 31, 2022 09:56
Loading DIALS reflection tables with only Numpy
"""
DIALS .refl file loader
This loads msgpack-type DIALS reflection files, without having DIALS or
cctbx in the python environment.
Note: All modern .refl files are at time of writing msgpack-based. Some
much older files might be in pickle format, which this doesn't read.
Usage:
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function
"""
Watcher
Implementation of a utility class to efficiently watch a folder/tree of
folders for new files appearing, with options for ignoring/timeout.
"""
@ndevenish
ndevenish / printf_regex.py
Created January 25, 2021 17:06
regex for parsing python printf-style-formatting
re.compile("""
% # Percent
(?:\((?P<mapping>[^)]*)\))? # Mapping key
(?P<flag>[#0\-+ ])? # Conversion Flag
(?P<width>\*|\d+)? # Field width
(?P<precision>\.(?:\*?|\d*))? # Precision
[hlL]? # Unused length modifier
(?P<format>[diouxXeEfFgGcrsa%]) # Conversion type