Skip to content

Instantly share code, notes, and snippets.

View ndevenish's full-sized avatar

Nicholas Devenish ndevenish

View GitHub Profile
@ndevenish
ndevenish / git-find-local-commits
Created January 14, 2021 15:00
Find and list commits that are not present upstream
#!/bin/bash
#
# Finds and lists commits that are not present upstream.
#
# Searches in and under the current directory for all .git repositories.
# These are then checked for any local commits that are not present in
# any of the upstream repositories, e.g. commits that have been made
# locally and do not have a known backup anywhere else.
#
# This is helpful to know if e.g. a repository can be safely deleted
@ndevenish
ndevenish / README.md
Last active September 3, 2020 22:09
Example of isort not adhering to configuration in worktree

Basic repo to demonstrate worktree error in isort

clone this. Run isort - no change. Make a worktree:

  $ git worktree add ../second_tree
  $ cat a.py
  import sys

  import c
@ndevenish
ndevenish / bm.cxx
Created April 21, 2020 10:11
Simple benchmark of loop
#include <benchmark/benchmark.h>
#include <scitbx/array_family/accessors/c_grid.h>
#include <scitbx/array_family/tiny_types.h>
#include <scitbx/array_family/versa.h>
using namespace scitbx;
static void BM_loop_inside(benchmark::State& state) {
af::versa<bool, af::c_grid<3> > base(af::c_grid<3>(af::tiny<int, 3>(14, 14, 5)));
PRFX=$(HOME)/autobuild/build-Linux-pre-release-gtk3-python
CXXFLAGS=-I$(PRFX)/include/python3.6m/
LDFLAGS=-L$(PRFX)/lib -lpython3.6m -Wl,-rpath=$(PRFX)/lib
all: standalone-python-test
standalone-python-test: standalone-python-test.cc
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
@ndevenish
ndevenish / CMakeLists.txt
Last active April 7, 2020 17:23
Example of failing ispc bool passing
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(ispc_bool)
add_custom_command(OUTPUT booltest.o booltest.h
COMMAND ispc ${CMAKE_SOURCE_DIR}/booltest.ispc -o booltest.o -h booltest.h
DEPENDS booltest.ispc)
add_executable(booltest booltest.cxx booltest.o)
target_include_directories(booltest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
@ndevenish
ndevenish / read_yum_repo.py
Last active February 28, 2020 15:34
Read a yum repo and fetch the version and URL of latest package
"""
Read a yum remote repo and get the latest version and url of a package
Prints output to stderr and to stdout:
<version> <url>
"""
import sys
import os
import argparse
import requests
from __future__ import absolute_import, division, print_function
import glob
import sys
import time
from dials.command_line.find_spots_server import work
FILENAMES = "/path/to/test/files/*.cbf"
@ndevenish
ndevenish / new_dials_command.py
Last active September 12, 2019 11:12
Standard DIALS command_line program boilerplate
"""
dials.new_dials_command
Put a description of your program in the top docstring. This will be
used in the OptionParser to display program help.
"""
from __future__ import absolute_import, division, print_function
import pickle
@ndevenish
ndevenish / remove_head.py
Created September 6, 2019 15:10
Removes header lines from all python files in the current directory
import os
from pathlib import Path
# Presence of these means we should keep
EXCLUSIONS = {"LIBTBX", "FIXME", "DIALS", "pytest"}
EXCLUDE_FILES = {
"conftest.py",
"util/image_viewer/slip_viewer/frame.py",
"util/installer.py",
@ndevenish
ndevenish / all_included.txt
Last active July 30, 2019 20:30
Everything included by math_ext.cpp
/usr/include/stdc-predef.h
/dls/science/users/mep23677/dist/build/include/scitbx/array_family/boost_python/flex_fwd.h
/dls/science/users/mep23677/dist/modules/boost/boost/python/detail/prefix.hpp
/dls/science/users/mep23677/dist/modules/boost/boost/python/detail/wrap_python.hpp
/dls/science/users/mep23677/dist/base/include/python2.7/pyconfig.h
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h
/usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h
/usr/include/gnu/stubs-64.h /usr/include/bits/posix1_lim.h