Skip to content

Instantly share code, notes, and snippets.

View Qubasa's full-sized avatar
🐞

Luis Hebendanz Qubasa

🐞
View GitHub Profile
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <stdint.h>
#include <string.h>
#ifndef _BIT_ARRAYS_
#define _BIT_ARRAYS_
" Author: Luis Hebendanz
" Description: FASM linter for asmsyntax fasm.
call ale#Set('fasm_fasm_executable', 'fasm')
call ale#Set('fasm_fasm_options', '')
function! ale_linters#fasm#fasm#GetCommand(buffer) abort
"Note that NASM requires a trailing slash for the -I option.
let l:separator = has('win32') ? '\' : '/'
let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator
iptables -t mangle -A OUTPUT -m owner --uid-owner music-heaven -j MARK --set-mark 42
iptables -t nat -A POSTROUTING -o vpn-secure -j MASQUERADE
echo 201 music.out >> /etc/iproute2/rt_tables
ip rule add fwmark 42 table music.out
ip route add default via 10.8.0.249 dev vpn-secure table music.out
@Qubasa
Qubasa / libvirt_nested_kvm.md
Last active September 13, 2020 16:01
Enable nested amd virtualization with virt-manager

Enable in NixOS:

boot.extraModprobeConfig = "options kvm_amd nested=1";

Check if correctly set with:

$ cat /sys/module/kvm_amd/parameters/nested
@Qubasa
Qubasa / CMakeLists.txt
Last active November 15, 2025 15:04
CMake with ubsan
cmake_minimum_required(VERSION 3.16)
# Set debug mode
set(CMAKE_BUILD_TYPE Debug)
if (MSVC)
message("Using MSVC")
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX)
else()
@Qubasa
Qubasa / fix_encrypted_zfs.md
Last active October 26, 2020 13:38
Fix encrypted zfs NixOS

Reboot the machine and boot from a NixOS usb Stick ISO. Import the zpool with:

$ zpool import -f rpool
$ zpool status
$ zfs list

If you want to resilver a new disk parition it the same way as the other disk! Afterwards execute:

@Qubasa
Qubasa / unlocking_backups.md
Last active January 4, 2021 21:31
Unlocking backups

To mount a restic backup:

$ restic mount -r thinkpad-repo backup-mnt

Fixing a restic backup

$ restic -r thinkpad-repo unlock # Do delete lockfile
$ restic -r thinkpad-repo rebuild-index
@Qubasa
Qubasa / linked-clone.sh
Created September 28, 2020 19:33 — forked from aojea/linked-clone.sh
Script to create a linked clone with libvirt
#!/bin/bash
set -xe
# This script takes as a parameter the name of the VM
# and creates a linked clone
# Ref: https://unix.stackexchange.com/a/33584
# The scripts assumes that it runs from the same folder
# where the vm image is located and it coincides with the
# image name
@Qubasa
Qubasa / README.md
Last active October 1, 2020 10:38
NixOS nsd setup

first servers static ip: 1.2.3.4 second servers static ip: 1.2.3.4

Normally you use two different server but I don't want to.

For Namecheap

First go to manage domain -> advanced dns -> Personal dnsserver -> Register nameserver -> Click on the plus sign and add ns1.example.com and ns2.example.com with ip 1.2.3.4 and 1.2.3.4

Then go to manage domain -> domain -> nameservers -> add ns1.example.com, ns2.example.com

@Qubasa
Qubasa / cpuid.c
Created October 8, 2020 23:09
Get x64 AMD family & model number
#include <stdio.h>
int main(){
unsigned int cpuid;
asm volatile("cpuid":"=a"(cpuid):"a"(0x1));
unsigned char base_fam = (cpuid & 0xf00) >> 8;
unsigned char ext_fam = (cpuid & 0xf00000) >> 20;
unsigned char family = base_fam + ext_fam;