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 / Readme.md
Last active June 1, 2025 19:26
GCC Gfortran 15.1.0 new bug with -Wall flag

GCC Gfortran 15.1.0 has a new bug that is fixed in Gfortran 15.2.0 release on any operating system (Windows, macOS, ...) that is triggered by -Wall

gfortran -Wall wall.f90 && ./a.out

wall.f90:38:12: >

@scivision
scivision / Readme.md
Created May 25, 2025 06:31
PyPI upload from GitHub Actions without API token

For each package, go into PyPI projects and add a publisher.

This uses separate jobs for build and publish as recommended to avoid a poisoned package from hijacking the publish to put hostile code in a package.

@scivision
scivision / CMakeLists.txt
Created May 25, 2025 05:50
Maidenhead locator in Fortran. See https://github.com/space-physics/maidenhead/ for Python
cmake_minimum_required(VERSION 3.14...4.0)
project(Maidenhead LANGUAGES Fortran)
enable_testing()
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fno-backtrace -fimplicit-none)
endif()
add_library(maidenhead OBJECT maidenhead.f90)
@scivision
scivision / CMakeLists.txt
Last active March 31, 2025 21:50
CMake file permissions for find_library, find_file, find_path
cmake_minimum_required(VERSION 3.29)
project(find_perm LANGUAGES NONE)
set(noread_shared ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}noread_shared${CMAKE_SHARED_LIBRARY_SUFFIX})
set(noread_static ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}noread_static${CMAKE_STATIC_LIBRARY_SUFFIX})
# EXISTS requires read permissions
# https://cmake.org/cmake/help/latest/command/if.html#exists
# no read permissions means can't touch the file
@scivision
scivision / CMakeLists.txt
Last active May 25, 2025 03:58
time_t Year 2038 test with CMake, including _TIME_BITS=64
cmake_minimum_required(VERSION 3.20)
project(lang LANGUAGES C)
include(CheckSourceRuns)
include(CheckTypeSize)
check_type_size("time_t" TIME_T_SIZE)
if(NOT TIME_T_SIZE GREATER_EQUAL 8)
@scivision
scivision / BaslerPyPylon.py
Created March 10, 2025 20:25
PyPylon with Basler camera
#!/usr/bin/env python3
import pypylon
from matplotlib.pyplot import figure,draw,pause
#
Nblock = 10 # TODO workaround for Basler too many frames error
Nblocks = 100 # arbitrary number of frames to plot
def connect(camdev,camind=0):
@scivision
scivision / CMakeLists.txt
Last active February 11, 2025 19:08
MUMPS example via find_packge(MUMPS CONFIG)
cmake_minimum_required(VERSION 3.19)
project(MUMPS_example
LANGUAGES C Fortran
)
enable_testing()
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/.gitignore CONTENT "*")
@scivision
scivision / CMakeLists.txt
Last active February 5, 2025 14:51
Fix find_package(Curses) in CMake to work with a minimal example in C
cmake_minimum_required(VERSION 3.18)
project(CursesDemo LANGUAGES C)
include(curses.cmake)
add_executable(test_curses test_curses.c)
target_link_libraries(test_curses PRIVATE Curses::Curses)
@scivision
scivision / execute_process_win32.cmake
Created January 30, 2025 13:48
CMake execute_process on Windows with paths having spaces
# Toy example--execute_process() on Windows is challenging to handle paths with spaces
# Non-Winows sh -c just works.
set(setvars "set CC=gcc")
set(cmd "cc main.c")
set(cmd $ENV{COMSPEC} /c "${setvars} && ${cmd}")
string(REPLACE "C:/Program Files/" "C:/Progra~1/" cmd "$cmd}")
string(REPLACE "C:/Program Files (x86)/" "C:/Progra~2/" cmd "${cmd}")
@scivision
scivision / .gitignore
Last active January 27, 2025 14:35
Matlab buildtool MEX standalone example
.buildtool/