Skip to content

Instantly share code, notes, and snippets.


Jacek Wieczorek Jacajack

View GitHub Profile
Jacajack / radix_sort.cpp
Last active Sep 23, 2020
gotta go fast
View radix_sort.cpp
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cinttypes>
#include <random>
#include <functional>
#include <chrono>
#include <limits>
void radix_sort(int *data, size_t size)
Jacajack / midi.c
Created Sep 2, 2020
Simple and lightweight polyphonic MIDI interpreter
View midi.c
#include "midi.h"
#include <stddef.h>
#include <inttypes.h>
#include <string.h>
void midi_init(midi_status *midi)
midi->dlim = 0;
midi->dcnt = 0;
midi->status = 0;
Jacajack /
Last active Jun 27, 2020
Adventures with Nvidia in search of tear-free experience

GTX 1060 (3GB) + 440.82

ForceFullCompositionPipeline in nvidia-settings was sufficient to eliminate all tearing and didn't cause any manjor performance drop. Occasional stutter in desktop effects might have been present, but I'm not quite sure about that. Games usually worked better with KDE compositor disabled, but were tearing-free.

RTX 2070 SUPER + 440.82

ForceFullCompositionPipeline causes ridiculous stuttering - even the mouse cursor is not moving smoothly. Disabling it removes this issue, but results in screen-tearing in most applications.

Tearing in desktop applications can be solved by enabling TripleBuffer and disabling AllowIndirectGLXProtocol in /etc/X11/mhwd.d/nvidia.conf, adding export KWIN_TRIPLE_BUFFER=1 to /etc/profile.d/ and setting tearing prevention in compositor settings to "Re-use screen content". It's not perfect, though, because it only has effect while the compositor is running, meaning that games will likely exhibit tearing.

Jacajack / polyblep.dsp
Last active Jan 26, 2020
PolyBLEP oscillators vs Faust standard library oscillators
View polyblep.dsp
// PolyBLEP residual function - used for smoothing steps in the audio signal.
// #### Usage
// ```
// polyblep(Q, phase) : _
// ```
Jacajack / fast_log.h
Created Jan 12, 2020
Fast IEEE754 float logarithm approximation in C
View fast_log.h
Fast logarithm approximation (around 1.5) with Taylor series.
sage: ln(x).taylor(x, 1.5, 5).horner(x)
(((x*(0.02633744855967078*x - 0.24691358024691357) + 0.9876543209876543)*x - 2.2222222222222223)*x + 3.333333333333333)*x - 1.8778682252251688
static inline float fast_logf_taylor( float x )
return fmaf( fmaf( fmaf( fmaf( fmaf(0.02633744855967078f, x, -0.24691358024691357f), x, 0.9876543209876543f), x, -2.2222222222222223f), x, 3.333333333333333f), x, -1.8778682252251688f);
Jacajack / ppg_evu10.c
Created Dec 9, 2019
PPG waveform table generated from EVU 1.0 EPROM dump
View ppg_evu10.c
uint8_t ppg_wavetable[] = {
131, // -------- wave 000 (00h), sample 00
162, // sample 01
188, // sample 02
205, // sample 03
211, // sample 04
208, // sample 05
196, // sample 06
181, // sample 07
164, // sample 08
Jacajack / nsect.c
Last active Sep 23, 2019
N-section method benchmarking
View nsect.c
Compile with: clang -O3 -o nsect nsect.c -Wall -DCOUNT=5000000 -DNSECT=? -funroll-loops
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sys/time.h>
Jacajack / makefile-arm
Created Jul 31, 2019
Old liblightmodbus makefile for STM32F103
View makefile-arm
# liblightmodbus - a lightweight, multiplatform Modbus library
# Copyright (C) 2017 Jacek Wieczorek <>
# This file is part of liblightmodbus.
# Liblightmodbus is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
Jacajack / iir.c
Last active Jul 14, 2019
IIR filter
View iir.c
struct iir_filter
float *w; // w coefficients
float *a; // a coefficients
float *b; // b coefficients
int n; // filter size
float iir_push( struct iir_filter *f, float x )
Jacajack / packages-arch.csv
Last active Sep 27, 2019
My favorite programs (arch version) (not tested yet)
View packages-arch.csv
#Group Package name Description
sudo running programs as root
ssh remote shell
sshfs for mapping filesystems over network
pv program for measuring data flow through pipes
git version control system
moreutils more utilities
rsync for making backups and copying files
tree file tree view
rename powerful renaming utility