Skip to content

Instantly share code, notes, and snippets.

View scivision's full-sized avatar
💭
I will be slow to respond.

scivision

💭
I will be slow to respond.
View GitHub Profile
@scivision
scivision / _redirects
Last active February 15, 2021 08:40
Netlify public/_redirects for bot log diversion
# This file is for use with a Hugo blog.
# be careful using this on real-life site, so that the patterns below don't dump legitimate traffic!
# we use 410 to be more aggressive than 404, and to unclutter Netlify statistics
/.env /bot.html 410
/blog.zip /bot.html 410
/.git/* /bot.html 410
/browserconfig.xml /bot.html 410
/OLD/* /bot.html 410
/404.html /bot.html 410
@scivision
scivision / ci_cmake.yml
Last active February 22, 2023 11:27
GitHub Actions CI MSYS2 with MS-MPI on Windows
name: CI CMake
env:
CMAKE_BUILD_TYPE: Release
CMAKE_GENERATOR: Ninja
CTEST_PARALLEL_LEVEL: 2
on:
push:
- "**/CMakeLists.txt"
@scivision
scivision / TestAll.m
Created February 17, 2021 20:47
Matlab CI on Azure Pipelines
% this script is run on Azure (or local)
import matlab.unittest.TestRunner
import matlab.unittest.Verbosity
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.XMLPlugin
import matlab.unittest.plugins.codecoverage.CoberturaFormat
name = "MyProject";
suite = testsuite(name);
@scivision
scivision / CMakeLists.txt
Last active February 16, 2024 11:09
CMake pkg-config .pc.in generate template
# this fragment generates build/my_package.pc
#
# cmake -B build -DCMAKE_INSTALL_PREFIX=~/mylib
cmake_minimum_required(VERSION 3.0)
project(mylib
LANGUAGES C
HOMEPAGE_URL https://github.invalid/username/mylib
DESCRIPTION "example library"
@scivision
scivision / image_stack_hdf5.m
Last active February 18, 2021 02:56
HDF5 image stack writing, suitable for HDFView video player
Simg = load('clown');
imgs = Simg.X;
file = 'img.h5';
name = '/img';
h5create(file, name, size(imgs))
h5write(file, name, imgs)
h5writeatt(file, name, 'CLASS', 'IMAGE')
@scivision
scivision / configure.output.mpich
Last active February 22, 2021 04:24
Intel oneAPI MacOS 11.x: Trying to get MPI library working (MPICH, or OpenMPI)
$ git clone https://github.com/pmodels/mpich.git
$ git checkout v3.4.1
$ ./configure --prefix=$HOME/mpich-3.4.1 --disable-cxx
# NOTE: if CPPFLAGS not set, configure will fail in HWLOC. There is some bug in mpich/configure that just requires CPPFLAGS.
#
# configure complete, but make fails instantly:
$ make
@scivision
scivision / CMakeLists.txt
Last active January 24, 2024 21:30
GCC static exe linking
cmake_minimum_required(VERSION 3.14)
project(demo Fortran)
# --- static flags avoid users needing libgfortran etc. on their Windows system
# MacOS and Linux needs more caution as true static linking is an advanced topic.
# this does not guarantee a portable executable, careful testing is needed and possibly further options
set(static_link_flags)
if(MINGW AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(static_link_flags -static -static-libgfortran)
# MinGW / MSYS2 special considerations: https://www.msys2.org/news/#2021-01-31-aslr-enabled-by-default
@scivision
scivision / cpack.cmake
Last active November 16, 2022 15:28
CPack template
# do this after all install(...) commands so that all targets are finalized.
# Essentially, the last thing included at the end of the top-level CMakeLists.txt
set(CPACK_GENERATOR "TBZ2")
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package)
set(CPACK_SOURCE_IGNORE_FILES .git/ .github/ .vscode/ .mypy_cache/ _CPack_Packages/
${CMAKE_BINARY_DIR}/ ${PROJECT_BINARY_DIR}/
)
@scivision
scivision / AddGitSubmodule.cmake
Last active March 18, 2024 14:02
CMake: init/update a Git submodule and add_subdirectory()
find_package(Git REQUIRED)
function(add_git_submodule dir)
# add a Git submodule directory to CMake, assuming the
# Git submodule directory is a CMake project.
#
# Usage: in CMakeLists.txt
#
# include(AddGitSubmodule.cmake)
# add_git_submodule(mysubmod_dir)
@scivision
scivision / extract_zstd.m
Last active June 29, 2023 13:56
Matlab extract .zst Zstd compressed files
function extract_zstd(archive, out_dir)
% extract a zstd file "archive" to "out_dir"
arguments
archive (1,1) string {mustBeFile}
out_dir (1,1) string {mustBeFolder}
end
tar_arc = tempname;
ret = system("zstd -d " + archive + " -o " + tar_arc);