Skip to content

Instantly share code, notes, and snippets.

View Jacajack's full-sized avatar
🦄

Jacek Wieczorek Jacajack

🦄
View GitHub Profile
@Jacajack
Jacajack / blackwidow_v4_command_dial.py
Last active June 22, 2023 23:12
A simple script for Razer BlackWidow V4 command dial support with OpenRazer and evdev
#!/usr/bin/env python3
import asyncio
import evdev
import evdev.ecodes as ecodes
import openrazer.client
import colorsys
import time
import math
import random
@Jacajack
Jacajack / blackwidow-dial.py
Created June 21, 2023 17:50
Python evdev script for handling BlackWidow V4's command dial (when mapped to horizontal scroll)
#!/usr/bin/env python3
import asyncio
import evdev
import evdev.ecodes as ecodes
import openrazer.client
import colorsys
devman = openrazer.client.DeviceManager()
print(devman.devices)
@Jacajack
Jacajack / jmw_masks.py
Last active April 25, 2023 16:40
Image mask generator for uni project
#!/usr/bin/python3
import sys
import os
import pathlib
import json
import cv2
import numpy as np
CATEGORY_COLORS = {
1: (255, 0, 0), # NonMaskingBackground
@Jacajack
Jacajack / random.html
Created May 19, 2021 20:21
Random trip destinations
<!DOCTYPE html>
<html style="height: 100%;">
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=&libraries=geometry&sensor=false&ext=.js"></script>
<script>
var circle;
var infowindow = new google.maps.InfoWindow({});
function initialize() {
@Jacajack
Jacajack / radix_sort.cpp
Last active September 23, 2020 22:54
gotta go fast
#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
Jacajack / midi.c
Created September 2, 2020 21:41
Simple and lightweight polyphonic MIDI interpreter
#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
Jacajack / nvidia-config.md
Last active June 27, 2020 00:32
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/kwin.sh 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
Jacajack / polyblep.dsp
Last active January 1, 2023 12:39
PolyBLEP oscillators vs Faust standard library oscillators
import("stdfaust.lib");
//----------`(os.)polyblep`----------
// PolyBLEP residual function - used for smoothing steps in the audio signal.
//
// #### Usage
//
// ```
// polyblep(Q, phase) : _
// ```
@Jacajack
Jacajack / fast_log.h
Created January 12, 2020 21:22
Fast IEEE754 float logarithm approximation in C
/**
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
Jacajack / ppg_evu10.c
Created December 9, 2019 18:18
PPG waveform table generated from EVU 1.0 EPROM dump
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