Skip to content

Instantly share code, notes, and snippets.

@kopp
kopp / CMakeLists.txt
Created November 12, 2024 13:17
cmake: Selecting a generator within CMakeLists.txt (SO https://stackoverflow.com/q/11269833)
cmake_minimum_required(VERSION 3.31.0)
project(build_with_ninja CXX)
set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE)
message("generator is set to ${CMAKE_GENERATOR}")
@kopp
kopp / github_push_pull_https.md
Created July 23, 2024 22:23
git push and pull with https

How to git push and git pull via https://

  1. Create repository on github.com
  2. Add the remote (do not use set-url, rather delete and then add) including your username: git remote add origin https://<username>@github.com/<name>/<repo>.git
  3. Create an access token with scope Contents Read and Write (and if you want to work with workflows also Workflows Read and Write) via https://github.com/settings/tokens?type=beta
  4. Use git config push.autoSetupRemote true
  5. git push, then enter the PAT
@kopp
kopp / arduino_with_vscode.md
Created December 30, 2022 20:19
Arduino with VSCode

Install extension https://github.com/microsoft/vscode-arduino

Create a .vscode/settings.json file, that makes sure, that the C/C++ extension is enabled. (By default, I use the clangd extension for intellisense.)

{
    "C_Cpp.intelliSenseEngine":"default",
 "C_Cpp.autocomplete": "default",
@kopp
kopp / .xbindkeysrc
Created January 31, 2022 21:51
toggle-keyboard-layout-on-any-desktop
toggle_keyboard_layout.sh
Mod4+I
@kopp
kopp / points_interpolation_spines.py
Created January 17, 2022 20:32
Interpolate between two points with splines
import numpy as np
from scipy.interpolate import interp1d, splprep, splev, CubicHermiteSpline
import matplotlib.pyplot as plt
pts = np.array(
[
[-846724, 0],
[-423362, 10029],
[0, 13942],
[289000, 14733],
@kopp
kopp / verbose_coroutines.cpp
Created October 31, 2021 22:24
C++20 Coroutines with cout for the intermediate steps
// (c) 2021 kopp, MIT licensed
// see https://en.cppreference.com/w/cpp/language/coroutines
// works with g++ 11.1 with -std=c++20
#include <coroutine>
#include <iostream>
#include <string>
@kopp
kopp / unique_ptr_custom_allocator.cpp
Created July 18, 2021 21:28
Demo of how to use a unique_ptr with a custom allocator.
/**
* Demo of how to use a unique_ptr with a custom allocator.
*
* Unlicensed 2021 kopp
*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
@kopp
kopp / build_aim42_epub.md
Created April 12, 2021 16:07
build epub for aim42
git clone https://github.com/aim42/aim42.git
cd aim42
docker run -it -v $(pwd):/documents/ asciidoctor/docker-asciidoctor
asciidoctor --doctype book -a imagesdir=../resources/images -a icons=font -a toc=left -a sectlink=true -a sectanchors=true -a numbered=true, -a source-highlighter=coderay -a coderay-css=class -a stylesheet=aim42.css -a stylesdir=../resources/css/ -a version=0.8.0 -a data-uri=true --out-file a.html --source-dir src/main/asciidoc/ src/main/asciidoc/index.adoc

Note: data-uri will include the image content in the HTML; see here.

Directly create the epub via

@kopp
kopp / vscode_python_interactive_plotting.md
Created February 16, 2021 21:34
Interactive matplotlib plotting in VSCode's Inteactive Window
pip install ipympl

in Ipython/VSCode Interactive Window use

%matplotlib widget

@kopp
kopp / dash_map_plot_with_interaction.py
Created February 11, 2021 22:11
Dash App with plotted map and some user interaction
# %%
# Application that displays data on a map and allows to modify the data in a
# callback triggered by a button.
#
# Note: This application must not be executed using multiple workers, but only
# single-threaded (i.e. run with `python <name>`).
# See https://dash.plotly.com/sharing-data-between-callbacks for the reason.
import dash