Skip to content

Instantly share code, notes, and snippets.

View jniemann66's full-sized avatar

Judd Niemann jniemann66

  • Melbourne
View GitHub Profile
@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)
@jniemann66
jniemann66 / fftsize.cpp
Last active October 11, 2019 04:59
fft size selector
// pick a good fft size for fftw (of the form 2^a * 3^b * 5^c * 7^d * [1|11|13] )
int selectFFTSize(int n)
{
int s = 1;
for(int ef : {1, 11, 13}) {
for(int d = 1 ; d <= n; d *= 7) {
for(int c = 1; c <= n; c *= 5) {
for(int b = 1; b <= n; b *= 3) {
@jniemann66
jniemann66 / takeItAwayHerb.md
Last active October 8, 2019 01:55
C++: taking a const reference to a return value (OK) [non-const reference to return value = NOT OK]
@jniemann66
jniemann66 / alignAcrossLayouts.cpp
Last active August 27, 2019 01:15
Qt align tops of widgets in separate layouts
// in Widget A, residing in some other layout, but part of the same window as widget B
// someBox is a widget somewhere in widgetA
void WidgetA::resizeEvent(QResizeEvent *event)
{
widgetB->setBoxYPos(someBox->mapTo(this->window(), someBox->rect().topLeft()).y());
QWidget::resizeEvent(event);
}
// in widget B, which has a member QVBoxLayout* mainLayout
@jniemann66
jniemann66 / dragdropfilter.cpp
Last active August 12, 2019 00:35
Qt Generic Drag and Drop event filter
#include <QDragEnterEvent>
#include "dragdropfilter.h"
bool DragDropFilter::eventFilter(QObject* obj, QEvent* event)
{
auto w = qobject_cast<QWidget*>(obj);
if(w == nullptr) {
return true;
}