Skip to content

Instantly share code, notes, and snippets.

View niklas88's full-sized avatar

Niklas Schnelle niklas88

View GitHub Profile
@niklas88
niklas88 / Notes-QEMU.md
Last active May 31, 2025 21:02
QEMU + MacVTAP with Systemd Unit Files on Arch Linux

QEMU + MacVTAP with Systemd Unit Files

Below I list a launch script which creates the MacVATP tun file as root and then drops privileges to the qemu user. This user thus needs access to the image file passed as first parameter. This is /var/vms/chimera.img in the example systemd unit. Also this launch script makes QEMU create unix sockets for the monitor and console streams. This way socat can be used to access e.g. the guest console with the following command:

From 9facb3455c116337791946c2ecef1ed16cb78a2e Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Mon, 5 Jul 2021 11:43:16 +0200
Subject: [PATCH] CONFIG_HAS_IOPORT
Note (Niklas Schnelle):
This is as rebase on v5.16-rc5 of https://pastebin.com/yaFSmAuY
originally posted at by Arnd at the link below.
On s39 which leaves HAS_IOPORT unset it compiles with allyesconfig.
#!/usr/bin/env zsh
# Now with vulkan / venus magic and UEFI. Remove cdrom after install.
# qemu-img create -f qcow2 fedora.qcow2 40G
# cp /usr/share/edk2/x64/OVMF_VARS.4m.fd fedora_OVMF_VARS.4m.fd
# -cdrom Fedora-Kinoite-ostree-x86_64-42-1.1.iso \
qemu-system-x86_64 -machine q35 \
-drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.4m.fd \
-drive if=pflash,format=raw,file=fedora_OVMF_VARS.4m.fd \
-bios /usr/share/edk2/x64/OVMF_CODE.4m.fd \
-boot menu=on \
" Show tabs, End-of-Line and Trailing spaces
set listchars=tab:▸\ ,eol:¬,trail:~
" So the background is transparent for the above characters
highlight Normal ctermbg=none
highlight NonText ctermbg=none
" Whitespace at end of line in red
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
@niklas88
niklas88 / min-byte-rnn.py
Last active March 23, 2018 12:54 — forked from karpathy/min-char-rnn.py
Karpathy's original minimal char rnn + Python 3 + bytes directly instead of chars
#!/usr/bin/env python3
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
import sys
import time
# data I/O
#include <chrono>
#include <iostream>
#include <algorithm>
#include <array>
int main(int argc, char** argv) {
std::array<int, 13> arr = {12, 5, 7, 9, 2, 2, 33, 24, 1, 8, 0, 3, 77};
auto start = std::chrono::high_resolution_clock::now();
std::sort(arr.begin(), arr.end());
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
std::vector<std::string_view> split_no_strcpy(std::string_view orig, const char sep) {
std::vector<std::string_view> result;
if (orig.size() > 0) {
size_t from = 0;
size_t sepIndex = orig.find(sep);
#include <iostream>
#include <experimental/filesystem>
#include <fstream>
namespace fs = std::experimental::filesystem;
int main() {
fs::path path = u8"猫.txt";
std::cout << "path = " << path << std::endl;
PREFIX fb: <http://rdf.freebase.com/ns/>
SELECT DISTINCT ?cityname ?countryname ?popcount ?latitude ?longitude WHERE {
?citytype fb:type.object.name "City/Town/Village"@en .
?city fb:type.object.type ?citytype .
?city fb:type.object.name ?cityname .
?city fb:location.location.containedby ?country .
?city fb:location.statistical_region.population ?population .
?population fb:measurement_unit.dated_integer.number ?popcount .
#include <stdint.h>
#include <stdio.h>
#include <zmq.h>
#include <assert.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if(argc < 3) {
fprintf(stderr, "Usage %s: <xpublish_url> <xsubsriber_url>\n", argv[0]);
exit(1);