Skip to content

Instantly share code, notes, and snippets.

@zethon
zethon / gist:e5381174f9de9db73559534ead587c34
Last active March 13, 2025 14:58
Getting VSCode's CMakeTools on Win10 to Launch a WSL2 Process as Root

When you set "miDebuggerPath": "/usr/bin/sudo" and "miDebuggerArgs": "/usr/bin/gdb", CMake Tools (or the Microsoft C++ debug adapter) then appends extra GDB flags like --interpreter=mi – but those end up being passed to sudo rather than gdb. Sudo complains about unrecognized options (anything starting with a dash), and so it fails.

You need a way for sudo itself to ignore those GDB options, so that they pass through to gdb. There are two main workarounds:


1) Use a Small “Wrapper” Script

One of the simplest solutions is to create a one-line shell script that runs gdb under sudo, and then reference that script as your debugger path. This way, the extra flags appended by VS Code or CMake Tools go to gdb correctly.

@zethon
zethon / test.cp
Last active April 20, 2024 14:40
#include <iostream>
#include <string>
// Requirements:
// * get and set employees first name and last name
// * get and set employees manager
// * get and set employees salary
// * function that returns full name
// * function that prints all known/set info about employee
// * function that gives a raise to an employee, not above 25%
@zethon
zethon / sample.qml
Last active November 23, 2023 01:34
QML Popup Transition
import QtQuick.Window 2.2
// import QtQuick.Controls 2.12
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.3
ApplicationWindow {

NPM error with installing dependencies:

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz failed, reason: unable to get local issuer certificate

Fixed with:

@zethon
zethon / gist:6b7470b4f3a1df9618fc5151a4fbbcf2
Created January 9, 2022 13:16
Redirect CMake output to file
cmake ... >> output_file.txt 2>&1
@zethon
zethon / snippet.yml
Created June 26, 2021 23:52
Github Actions Ubuntu Install GCC-11
- name: Install GCC11
shell: bash
run: |
sudo apt update
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
@zethon
zethon / iterator.cpp
Created June 22, 2021 13:26
Writing a Custom Iterator for a Container with Ephemeral Objects
#include <iostream>
#include <string>
#include <vector>
#include <memory>
class Database
{
std::vector<int> _data;
public:
@zethon
zethon / file.cpp
Created December 19, 2020 02:47
C++ Cumulative Moving Average Class
template<typename NumberT>
class CumulativeMovingAverage
{
NumberT _total = 0;
std::size_t _count = 0;
public:
float value() const
{
// TODO: pretty sure only one cast is need, but not 100% sure
@zethon
zethon / swedish-words.txt
Last active October 1, 2020 11:57
Swedish Words
igen - again
arr - is
jag har ett träd på mitt hus - I have a tree on my house