Skip to content

Instantly share code, notes, and snippets.

View nephest's full-sized avatar
💭
I may be slow to respond.

nephest

💭
I may be slow to respond.
View GitHub Profile
@nephest
nephest / ReactorRateLimiter.java
Created December 15, 2021 13:36
A simple rate limiter for Project Reactor
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;
import reactor.core.publisher.MonoSink;
import reactor.util.retry.Retry;
import reactor.util.retry.RetryBackoffSpec;
import reactor.util.retry.RetrySpec;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
@nephest
nephest / kvm-gpu-passthrough-on-debian-buster.md
Last active March 20, 2024 15:09
Setting up KVM with GPU passthrough in Debian Buster

Here's how to set up a Windows 10 virtual machine in KVM with PCI passthrough. The VM will have access to an NVIDIA graphics card while the host machine (running Debian Buster) uses Intel integrated graphics. This is mostly for my own reference so I don't forget how I did it.

Hardware

  • Intel i5 (an old one) with integrated graphics: this will be used as the graphics card for the host machine running Debian Buster
  • NVIDIA Geforce 1070: this will be used as the graphics card for the Windows 10 VM

Step 1: Enable IOMMU

In order to do hardware passthrough with KVM at all, you need to enable the Intel Vt-d virtualization extensions. Edit /etc/default/grub and edit the GRUB_CMDLINE_LINUX_DEFAULT line so that it reads like:

--active query list
SELECT datname, pid, state, query, age(clock_timestamp(), query_start) AS age
FROM pg_stat_activity
WHERE state <> 'idle'
AND query NOT LIKE '% FROM pg_stat_activity %'
ORDER BY age;
--shutdown
SELECT pg_cancel_backend(<pid of the process>);
@nephest
nephest / DoubleXYChart.java
Created April 1, 2021 13:40
Generic double XYChart with secondary Y axis for JavaFX
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.chart.Chart;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;