Skip to content

Instantly share code, notes, and snippets.

@MaartenBaert
MaartenBaert / glinject.py
Created Jan 27, 2018
GLInject to Python (numpy)
View glinject.py
import ctypes
import glob
import mmap
import operator
import os.path
import time
import numpy
import matplotlib.pyplot as plt
@MaartenBaert
MaartenBaert / gist:e9c94f8c57cdb2913fe21102b9a6293d
Created Oct 9, 2017
QProgressDialog with separate worker thread. Note that there's a possible reentrancy problem since setValue calls QApplication::processEvents.
View gist:e9c94f8c57cdb2913fe21102b9a6293d
QProgressDialog dialog("Parameter sweep ...", "Cancel", 0, (int) sweep_values.size(), this);
dialog.setWindowTitle(MainWindow::WINDOW_CAPTION);
dialog.setWindowModality(Qt::WindowModal);
dialog.setMinimumDuration(0);
dialog.setValue(0);
std::atomic<bool> worker_canceled(false), worker_stopped(false);
std::exception_ptr worker_exception;
std::thread worker_thread([&]() {
try {
for(size_t i = 0; i < sweep_values.size(); ++i) {
@MaartenBaert
MaartenBaert / PKGBUILD
Created Oct 8, 2017
PKGBUILD for mingw-w64-harfbuzz 1.5.1
View PKGBUILD
# Maintainer: Schala <schalaalexiazeal "at" gmail {dot} com>
# Contributor: calegria <calegria+al "at" gmail {dot} com>
pkgbase=mingw-w64-harfbuzz
pkgname=(mingw-w64-harfbuzz mingw-w64-harfbuzz-icu)
pkgver=1.5.1
pkgrel=1
pkgdesc="OpenType text shaping engine (mingw-w64)"
arch=(any)
url="http://www.freedesktop.org/wiki/Software/HarfBuzz"
View segment_intersects_rectangle_demo.py
from pylab import *
def segment_intersects_rectangle(x1, y1, x2, y2, cx, cy, w, h):
return (fabs(x1 + x2 - 2.0 * cx) < fabs(x1 - x2) + w and
fabs(y1 + y2 - 2.0 * cy) < fabs(y1 - y2) + h and
2.0 * fabs((x1 - cx) * (y1 - y2) - (y1 - cy) * (x1 - x2)) < w * fabs(y1 - y2) + h * fabs(x1 - x2))
def test_intersect(plot_line, plot_rect):
for line in plot_line:
(x1, x2) = line.get_xdata()
@MaartenBaert
MaartenBaert / .asoundrc-jack
Last active Feb 22, 2016
ALSA configuration for recording with JACK.
View .asoundrc-jack
# Some of this may look redundant, but this was carefully written to
# work around various bugs in alsa-plugins, so don't mess with it :).
# override default
pcm.!default {
type plug
slave {
pcm "rjack"
}
}
@MaartenBaert
MaartenBaert / gast.sh
Last active Feb 22, 2016
A script that automates the process of configuring JACK, PulseAudio and ALSA for recording with SSR. It's used to record game audio, microphone audio and Skype/TeamSpeak audio simultaneously. This script only works when combined with the right config files. Also, this is completely unsupported, don't expect it to 'just work'.
View gast.sh
#!/bin/bash
# IMPORTANT: READ THIS BEFORE RUNNING THIS SCRIPT!
# This script only works when the system is configured correctly. Do these things first:
#
# Step 1:
# - If you have an ~/.asoundrc file, rename it to ~/.asoundrc-default. If you don't have one, create an empty file named ~/.asoundrc-default.
# - Create ~/.asoundrc-jack with the contents found here: https://gist.github.com/MaartenBaert/3630a1863969ba344704
# The script will create a symlink from .asoundrc to .asoundrc-jack when started, and from .asoundrc to .asoundrc-default when stopped.
#
You can’t perform that action at this time.