Skip to content

Instantly share code, notes, and snippets.

@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
@kopp
kopp / aurci_restructuring.md
Created July 11, 2020 19:18
Notes about restructuring aurci to aurci2
@kopp
kopp / calliope_mini_robot_two_ac_motors.py
Created June 21, 2020 21:22
A python class that allows to control a two-wheel robot with two AC motors on the Calliope Mini.
from calliope_mini import pin28, pin29, pin30
from utime import ticks_us, ticks_add
# Note: as the file is large and has long comments, use pyminifier before uploading to Calliope mini.
# Note: Some abstration is missing here and code is duplicated.
# This happens with a reason:
# MicroPython has only a very limited stack size and thus number of nested
# function calls is low.
# Because of that, code is repeated in different functions