Skip to content

Instantly share code, notes, and snippets.

View ndevenish's full-sized avatar

Nicholas Devenish ndevenish

View GitHub Profile
@ndevenish
ndevenish / cyclom.txt
Created December 11, 2018 22:12
Cyclomatic complexity of dials modules, > 10
$ radon cc -sn C dials
dials/libtbx_refresh.py
F 34:0 _install_dials_autocompletion - C (17)
dials/algorithms/indexing/compare_orientation_matrices.py
F 8:0 difference_rotation_matrix_axis_angle - C (11)
dials/algorithms/indexing/fft3d.py
M 313:2 indexer_fft3d.find_basis_vector_combinations_cluster_analysis - E (38)
M 210:2 indexer_fft3d.find_candidate_basis_vectors - D (25)
dials/algorithms/indexing/indexer.py
M 746:2 indexer_base.index - F (53)
xia2/conftest.py
F 25:0 ccp4 - B (7)
F 46:0 xds - B (6)
xia2/XIA2Version.py
F 14:0 get_git_revision - C (15)
xia2/Applications/xia2_helpers.py
F 9:0 process_one_sweep - B (10)
xia2/Applications/xia2_main.py
F 69:0 get_command_line - B (10)
F 25:0 check_environment - B (6)
@ndevenish
ndevenish / monitor_qsub.sh
Created December 18, 2018 11:07
Small script to monitor qsub whilst waiting for jobs to finish
# Start a monitor thread
(
wc=0
while true
do
sleep 5
## Attempt at being clever with qstat - but problem with
## normal "job x finished" output bumping the offset. Ideally
## I'd also capture those and use them as a refresh signal
# if [[ $wc -gt 0 ]]; then
@ndevenish
ndevenish / fix_show.py
Last active March 7, 2019 00:29
Bowler script to search for show() functions and add __str__
#!/usr/bin/env python3
"""
Finds classes with a show() but no __str__, and adds the method.
Requires the 'bowler' python library.
Usage:
$ bowler run fix_show.py [-- [--do] [--silent]]
@ndevenish
ndevenish / show_log.txt
Created March 7, 2019 00:36
Report of fix_show.py
Running fix_show.py over cctbx https://gist.github.com/ndevenish/47813efb6f94576686495edec94cb0ac.
188 Unique show() functions
79 show() functions didn't qualify
68 Because of non-object bases
9 Already had __str__
2 No str, but already had __repr__
109 show() functions DID qualify
@ndevenish
ndevenish / rewrite_with_black.sh
Created March 19, 2019 12:07
Script to rebase pre-black branches onto post-black tree
#!/bin/bash
cat <<EOF
Rewriting current branch to master, by applying black.
This is only tested for simple, linear branches and results should
be checked thoroughly before abandoning the old history.
EOF
# Find out the combined base commit
# Work out if we're Redhat
if [ -f /etc/redhat-release ] ; then
DIST='RH'
OS_MAJOR=$(lsb_release -r | awk '{print $2;}' | cut -d. -f1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' )
OS_SHORT=$DIST$OS_MAJOR
PS1_OS="\[\e[35m\]RH${OS_MAJOR}\[\e[0m\] "
fi
# This adds 'PHI' to the PS1 if on a Xeon Phi box
if cat /proc/cpuinfo | grep 'name'| uniq | grep Phi > /dev/null; then
@ndevenish
ndevenish / refine_logging.txt
Created March 27, 2019 22:39
dials.refine default logging
<--""
Level WARNING
|
o<--"dials"
| Level DEBUG
| Handler Stream <open file '<stdout>', mode 'w' at 0x1075fa150>
| Level INFO
| Formatter fmt='%(message)s' datefmt=None
| Handler File '/Users/nickd/dials/analysis/betalactamase/dials.refine.log'
| Level INFO
@ndevenish
ndevenish / update_dxtbx.sh
Last active April 4, 2019 12:21
Script to resync dxtbx/cctbx_project branches, before split
#!/bin/bash
# The commit on the current cctbx_project/dxtbx equivalent to dxtbx master
BASE_COMMIT=cbf101d68265777cee933a203ccb683ab54ddf13
set -e
set -x
# Make sure repo exists and we're inside it
if [[ "$(basename $(pwd))" != "cctbx_project" ]]; then
@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