Skip to content

Instantly share code, notes, and snippets.

View jniemann66's full-sized avatar

Judd Niemann jniemann66

  • Melbourne
View GitHub Profile
@jniemann66
jniemann66 / build-all.sh
Last active January 14, 2026 13:19
Building a simple C++ cmake project with gcc AND clang
#!/bin/bash
# script to produce in-source builds for both gcc AND clang
# (run this from project src dir)
# Define build directories based on compiler choice
GCC_BUILD_DIR="build/gcc"
CLANG_BUILD_DIR="build/clang"
# Function to build with GCC
@jniemann66
jniemann66 / copydlls.txt
Created January 7, 2026 23:17
cmake: windows copy-dlls post build
#cmake >= 3.21
if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}>
$<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND_EXPAND_LISTS
)
endif()
@jniemann66
jniemann66 / copydlls.sh
Created January 6, 2026 13:40
copying goddamn mingw_64 runtime dlls into your goddamn build directory
# usage (run it in git bash):
# cd <your-project's-build-dir>
# copydlls.sh .
# path to your goddamn compiler's dlls
# (they are usually in the bin directory of where compiler is installed)
dllpath=/c/Qt/Tools/mingw1310_64/bin
# copy the damn dlls already
cp ${dllpath}/libatomic-1.dll $1
@jniemann66
jniemann66 / format_string.h
Last active January 7, 2026 00:02
format a std::string with printf-style formatting
// utility function to do printf-style formatting on a std::string
#include <string>
template<typename ... Args>
static std::string format_string(const char* format, Args... args)
{
if (format) {
// get size from test run
const size_t sz = std::snprintf(nullptr, 0, format, args ...);
@jniemann66
jniemann66 / vaginasaur.txt
Created October 24, 2020 07:03
QMake Syntax for variables
VAR = foobar => Assign value to variable when qmake is run
$$VAR => QMake variable's value at the time qmake is run
$${VAR} => QMake variable's value at the time qmake is run (identical but enclosed to separate from surrounding text)
$(VAR) => Contents of an Environment variable at the time Makefile (not qmake) is run
$$(VAR) =>Contents of an Environment variable at the time qmake (not Makefile) is run
@jniemann66
jniemann66 / hilbert-freq-doubler.cpp
Created July 26, 2020 10:51
freq doubler - multiples +45 deg with -45 deg phase shift
class FrequencyDoubler
{
public:
FrequencyDoubler() {
coeffs = ReSampler::makeHilbert(1001);
length = coeffs.size();
history.resize(length);
centerTap = length / 2;
currentIndex = length - 1;
}
@jniemann66
jniemann66 / output.txt
Created April 29, 2020 04:31
empty QString key in QMap<QString, T>
"quince"
"apple"
"bananna"
"cherry"
""
Mr Mrs
Ms
Miss
Dr
Herr
Monsieur
Hr
Frau
-
A V M
#ifndef UGLYPLOT_H
#define UGLYPLOT_H
#include <iostream>
#include <cmath>
class UglyPlot
{
public:
static void plot(const double* p, int length)