Skip to content

Instantly share code, notes, and snippets.

View mducle's full-sized avatar

Duc Le mducle

  • Science and Technology Facilities Council
  • Harwell, UK
View GitHub Profile
#!/bin/bash
args=()
for var; do
[[ $var != '-batch' ]] && args+=("$var")
done
tmpmfile=mlscript_$(mktemp -u XXXXXXXX)
echo "${args[@]}" > ${tmpmfile}.m
runner_path=/home/runner/work/_actions/matlab-actions/run-command/v2/dist/bin/glnxa64/
@mducle
mducle / sabug_cylaxis.diff
Created December 6, 2023 00:39
Mantid solid angle bug change cylinder axis patch.
diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp
index 286d1d953f8..eda0fa258d5 100644
--- a/Framework/Geometry/src/Objects/CSGObject.cpp
+++ b/Framework/Geometry/src/Objects/CSGObject.cpp
@@ -307,8 +307,9 @@ double cylinderSolidAngle(const V3D &observer, const V3D &centre, const V3D &axi
// axis points up the +Z axis and then rotated into their final position
// Required rotation
- constexpr V3D initial_axis(0., 0., 1.0);
- const Quat transform(initial_axis, axis);
@mducle
mducle / gist:51fa7cc2094f9f0c1cf4b6775d879a09
Last active December 5, 2023 13:20
Advent of code 2023
echo $(sed s/[A-z]//g ~/Downloads/input | sed "s/\([0-9]\)/\1 /g" | awk '{print $1, $NF}'| sed "s/ //" | sed "s/$/+/") | sed "s/+$//"|bc
cp ~/Downloads/input tt && for ii in "one,o1e" "two,t2o" "three,t3e" "four,f4r" "five,f5e" "six,s6x" "seven,s7n" "eight,e8t" "nine,n9e"; do cm=$(echo $ii | awk -F, '{print "sed s/"$1"/"$2"/g tt > t2 && mv t2 tt"}'); echo $cm|bash
@mducle
mducle / cf_multisite_segfault.py
Created July 24, 2023 16:40
Mantid crystalfield multi-site segfault
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
import sys, os
from CrystalField import CrystalField, PointCharge, ResolutionModel, CrystalFieldFit, Background, Function
from pychop.Instruments import Instrument
tb1 = {'B20': -0.2431330412981789, 'B22': -0.17569696468779034, 'IB22': 0.19648505887037993, 'B40': -0.000886093463241086, 'B42': -0.016200141304394847, 'IB42': 0.017849375647540782, 'B44': -0.0011331370797592647, 'IB44': -0.014528896930898594, 'B60': 5.487217052410268e-06, 'B62': 3.0859080066753127e-06, 'IB62': -3.1901616555494786e-06, 'B64': -2.3561324645561506e-06, 'IB64': 1.8508497796793596e-05, 'B66': 2.2094823318064904e-05, 'IB66': 1.273979589242308e-05}
@mducle
mducle / pace_neutrons_installer.exe
Created February 28, 2023 15:27
b85 encoded ctf for testing libpymcr
This file has been truncated, but you can view the full file.
@mducle
mducle / pace_neutrons_installer.zip
Created February 28, 2023 10:32
b85 encoded ctf for testing libpymcr
This file has been truncated, but you can view the full file.
@mducle
mducle / test_R2021a.ctf
Last active February 5, 2023 23:56
b85 encoded ctf for testing libpymcr
This file has been truncated, but you can view the full file.
@mducle
mducle / test_R2020a.ctf
Last active February 5, 2023 23:56
b85 encoded ctf for testing libpymcr
This file has been truncated, but you can view the full file.
@mducle
mducle / gist:ce535a8190c63f83d0577f1c695ee0d9
Created January 17, 2023 11:42
easydiffractionapp_wine_error
Unhandled exception: unimplemented function ucrtbase.dll.cexp called in 64-bit code (0x0000007b01384d).
Register dump:
rip:000000007b01384d rsp:000000000010d7d0 rbp:0000000005325660 eflags:00000202 ( - -- I - - - )
rax:000000000010d7f0 rbx:0000000080000100 rcx:000000000010d7f0 rdx:000000000010d810
rsi:000000000010d8e0 rdi:000000000010d820 r8:0000000000000002 r9:000000000010d8d0 r10:000000000010daf0
r11:0000000000000007 r12:0000000000000000 r13:000000000010de10 r14:0000000000000010 r15:0000000000000010
Stack dump:
0x0000000010d7d0: 000000000010d7f0 0000000000000000
0x0000000010d7e0: 0000000038ffb820 0000000000000000
0x0000000010d7f0: 0000000180000100 0000000000000000
@mducle
mducle / unique_con.m
Created March 22, 2022 12:05
Heterogenous matlab container storing only unique objects and indexing to these
classdef unique_con < handle
properties(Access=private)
store_ = {};
hash_ = [];
idx_ = [];
end
methods
function obj = unique_con(varargin)
if numel(varargin) == 1 && iscell(varargin{1})
varargin = varargin{1};