Skip to content

Instantly share code, notes, and snippets.

View jniemann66's full-sized avatar

Judd Niemann jniemann66

  • Melbourne
View GitHub Profile
@jniemann66
jniemann66 / pr.md
Created March 27, 2017 23:09 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jniemann66
jniemann66 / blueFIR.py
Created April 25, 2017 13:03
FIR Blueing Filter
# FIR filter coefficients for FIR to turn white noise into blue (3dB / octave increase)
# pretty good approximation (can probably safely truncate latter coeffs for shorter FIR)
b = np.array([
0.65574456 , -0.38378737 , -0.053818095 , -0.024852204 ,
-0.019328524 , -0.016130449 , -0.013568251 , -0.011437699 ,
-0.0096596723 , -0.0081750885 , -0.0069352004 , -0.0058993955 ,
-0.0050338087 , -0.0043101989 , -0.0037050145 , -0.0031986151 ,
-0.0027746217 , -0.0024193749 , -0.0021214835 , -0.0018714476 ,
-0.0016613448 , -0.0014845678 , -0.0013356065 , -0.0012098652 ,
@jniemann66
jniemann66 / ubuntu-node-link.sh
Created April 26, 2017 02:37
Ubuntu 16.04 Node Symlink
@jniemann66
jniemann66 / FIRSpectrumSimple.py
Last active April 26, 2017 10:46
Plot Frequency Response of FIR
# -*- coding: utf-8 -*-
# Sampling frequency
fs = 44100
# FFT size
N = 32768
# use Log freq response ? (False: Linear)
logFreq = False
# normalize peak to 0dB ?
peakAtZero = False
@jniemann66
jniemann66 / raiitimer.h
Created May 21, 2017 02:32
Really simple RAII millisecond timer
#ifndef _RAIITIMER_H
#define _RAIITIMER_H 1
#include <iostream>
#include <chrono>
class RaiiTimer {
public:
RaiiTimer() {
beginTimer = std::chrono::high_resolution_clock::now();
@jniemann66
jniemann66 / resolve-path.sh
Last active May 25, 2017 01:39
Script to resolve the include search paths from minGW to something sensible
#!/usr/bin/env bash
# usage: resolve-path.sh "<some-stupid-path>"
# changes this: "e:\mingw\bin\../lib/gcc/mingw32/5.3.0/../../../../include"
# ... into this: /e/mingw/include
# first sed script replaces <letter><colon> with <forward-slash><letter>
# second sed script replaces back-slashes with forward-slashes
realpath $1 | sed -e 's/\([a-zA-Z]\):/\/\1/g' -e 's/\\/\//g'
@jniemann66
jniemann66 / Qt-Android-dev-linux.md
Last active May 29, 2017 13:00
Qt Android Dev on Linux

Android Studio

dependencies:

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

download (put it in the /opt directory)

@jniemann66
jniemann66 / bash-find-examples.sh
Last active June 4, 2017 04:28
random snippets of solutions to weird things I needed to do using 'find'
# remove all image files with dimensions in filename (eg ./Williamstown-012v-300x150.jpg)
# (needed when cleaning media collection from wordpress, because it auto-generates multiple image sizes for every uploaded image)
find . -regex .+[0-9]x[0-9].+ -delete
# run spectrogram tool in parallel on batch of sound files. Concurrency set by numThreads
spectrogram_tool="spectrogram"
numThreads=4
find ./outputs -type f ! -name '*.png' ! -name '*.txt' ! -name '*.sd2' ! -name '*.raw' -print0 | xargs -i --null -n 1 -P $numThreads $spectrogram_tool --dyn-range=190 {} 1200 960 {}.png

typeid, typeof, decltype etc ...

typeid is an operator in C++ which returns a std::type_info object representing dynamic information about an object at runtime

Requires the <typeinfo> header to be included.

class type_info {
public:
 virtual ~type_info();
@jniemann66
jniemann66 / insert.cpp
Created June 19, 2017 09:54
Qt Insert row into SQL table
#include <QMap>
#include <QList>
#include <QStringList>
#include <QDebug>
// just one way of doing it ...
void MainWindow::on_pushButton_clicked()
{
QMap<QString,QString> data = {