Skip to content

Instantly share code, notes, and snippets.

@LegalizeAdulthood
LegalizeAdulthood / CMakePresets.json
Last active March 13, 2024 07:47
clang CMake Presets
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "sibling-build-preset",
@LegalizeAdulthood
LegalizeAdulthood / latest-cmake.sh
Last active February 21, 2024 15:49
Install latest CMake on ubuntu
# run this script with sudo
# From <https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line>
apt remove --purge --auto-remove cmake
apt update
apt install -y software-properties-common lsb-release && \
apt clean all
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
apt update
apt install kitware-archive-keyring
@LegalizeAdulthood
LegalizeAdulthood / PortingFromMFCToWxWidgets.md
Last active November 12, 2023 02:34
Porting from MFC to wxWidgets
@LegalizeAdulthood
LegalizeAdulthood / SpaceshipOperator.txt
Last active January 4, 2022 03:04
A counterintuitive breaking change related to new comparisons C++17 vs. C++20
comp.lang.c++ #1074341 (1)
From: Andrey Tarasevich <andreytarasevich@hotmail.com>
[1] A counterintuitive breaking change related to new comparisons
Date: Mon Jan 03 10:48:42 MST 2022
Lines: 42
A colleague discovered that switching from `-stc=c++17` to `-std=c++20`
in their project resulted in a different behavior from some associative
containers. A bit of research allowed to narrow down the culprit to what
can be demonstrated by the following minimalist example
@LegalizeAdulthood
LegalizeAdulthood / HowToSonarQube.md
Created May 8, 2019 21:55
SonarQube Configuration for C++ Projects

SonarQube Configuration for C++ Projects

  1. Download SonarQube from SonarQube.org.
  2. Unpack the distribution.
  3. Download the C++ community plugin.
  4. Install the plugin using these instructions.
  5. Run bin\windows-x86-64\StartSonar.bat to start the server.
  6. Wait for the server to output the message SonarQube is up.
  7. Browse to http://localhost:9000 and login with admin/admin.
  8. Create a project by following the built-in tutorial.
  9. Configure the scanner for C++
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active February 7, 2018 22:41
Give Your Old Code Some New Love

Case Study

  • Our case study is the open source fractal generator Iterated Dynamics, a fork of FRACTINT.
  • This is a 30 year old code base that started as a 16-bit MS-DOS program written in C and 16-bit x86 assembly.
  • The code base has contributions from many, many authors over the years.
  • Source formatting and identifier conventions are varied due to the large number of authors.
  • Source code organization has been tortured by the constraints of early MS-DOS programs operating in a limited amount of physical memory and the use of overlays.
  • Conditional compilation was sprinkled throughout to enable various debugging facilities or experiments in alternative implementations.
  • As C does not have inline functions, there are some places that heavily use preprocessor macros.
  • Some of the functions are [exceedingly long*](https://github.com/LegalizeAdulthood
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active December 14, 2017 18:54
Embedded Development with Kvasir

Refresher of Embedded Development

  • Characteristics of an embedded environment
    • Bare metal interaction with hardware
    • No operating system
    • No virtual memory
    • No C/C++ runtime
  • No RTTI
@LegalizeAdulthood
LegalizeAdulthood / json.cpp
Created November 15, 2017 22:49
Compile-time JSON example
constexpr auto jsv = R"({
"feature-x-enabled": true,
"value-of-y": 1729,
"z-options": {
"a": null,
"b": "220 and 284",
"c": [ 6, 28, 496 ]
}
})"_json;
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active November 15, 2017 22:50
Compile-Time Programming Explained

Outline

TEST( Foo, foo )
{
int failures = 0;
for (int i = 0; i < 50; ++i) {
EXPECT_TRUE( i % 2 == 0 ) << ([&failures]() { ++failures; return ""; })();
}
if (failures > 0) {
std::cout << "There were " << failures << " failures.\n";
}
}