Skip to content

Instantly share code, notes, and snippets.

@mbinna
mbinna / effective_modern_cmake.md
Last active May 2, 2025 03:17
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@ryandvmartin
ryandvmartin / c_interop.f90
Last active September 28, 2021 03:05
Fortran Character Arrays and Python Ctypes .... the pain is real.
! testing in the ipython notebook with the fortran code in one cell:
! %%file test.f90
! and with the build call in the following cell:
! `!gfortran -shared test.f90 -o test.dll`
! note: some useful stuff found here: https://stackoverflow.com/a/13880611/5545005
module c_interop
use iso_c_binding
implicit none
integer, parameter :: STRLEN = 64
contains
@mcattarinussi
mcattarinussi / gpg-ssh-setup.md
Last active May 4, 2025 17:51
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@baiwfg2
baiwfg2 / CMakeLists.txt
Created September 29, 2018 12:42
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@dayne
dayne / 0-WSL-SSH-README.md
Last active June 30, 2024 05:22
WLS-Helpers

Install linux subsystem Ubuntu 18.04

See Microsoft's WSL install guide for windows 10 for details.

Work-in-progress - command line only install:

  • Open Powershell as Administrator and run:
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • Open Windows App Store
    • Search for "Ubuntu" and install Ubuntu 18.04

(work in progress - command line install steps):

# Instructions on how to build the owl OCaml scientific library (https://github.com/owlbarn/owl)
# Debian, Option 3: Pin the Dev-Repo, with distro's native OpenBLAS/LAPACKE packages
docker run --rm -it debian bash -eux -c 'apt-get update
# basic tools needed for opam to work:
apt-get install -y curl patch unzip make gcc bzip2 git
# we cannot automate running the install.sh from opam because it is interactive, instead we just download the opam binary:
curl -sL https://github.com/ocaml/opam/releases/download/2.0.1/opam-2.0.1-x86_64-linux --output /usr/local/bin/opam
chmod +x /usr/local/bin/opam
# load test image
using Makie
using AbstractPlotting: limits
# The data
"""
Very simple resampling of an index range
"""
function resample(range)
<#
.SYNOPSIS
Reset-WindowsUpdate.ps1 - Resets the Windows Update components
.DESCRIPTION
This script will reset all of the Windows Updates components to DEFAULT SETTINGS.
.OUTPUTS
Results are printed to the console. Future releases will support outputting to a log file.
@andyneff
andyneff / cygwin xserver.md
Last active January 17, 2023 21:15
Modified Cygwin startxwin script that syncs X11 with WSL

Using cygwin X in WSL1 and MingW (and others)

Cygwin comes with an X Server that can be useful with tools other than Cygwin itself. With a few modifications, we can add cygwin's X Server support to other shell implementations including cygwin, mingw64 (such as git for windows), msys2, WSL1, WSL2, and others.

With a few minor modifications, we can save the DISPLAY variable to files accessible by any shell. Once the DISPLAY value is accessible, an rc file can load it and it will automatically be used.

Optionally, we can even add a "one click" link to the start menu to start the xserver

TL;DR

Guix on WSL2

(updated versions of this document, plus more, live here)

This will show you how to get Guix running on WSL2.
We're going to go as "minimal" as possible, without starting off one of the readily available WSL2 distros.
Parts of this guide should help with understanding how to set up any custom distro on WSL, not just Guix.

Disclaimer: I'm a Guix nOOb! (hence going through the trouble of installing it on WSL2)