Skip to content

Instantly share code, notes, and snippets.

@flisboac
flisboac / _README.md
Last active October 1, 2023 00:10
Proxmox-VE 7.x: Enable PCI passthrough for I226-V Ethernet network devices, with non-passthrough exceptions for specific ports (tested with CWWK's CW-MBX-AD12 2.5Gbps 6-port mini-PC).

Some notes:

  • Disable Above 4G in BIOS, otherwise vfio-pci (on the host) will panic all the time when turning off the Opnsense VM, and the only way to get off the problem is to hard-reset the host entirely.
  • On Opnsense Guest, go to the Web GUI, option System -> Settings -> Tunables, click "Add", and add the virtio_console_load=YES config Make sure QEMU Guest Agent is disabled.
@flisboac
flisboac / tps6104x-calculate-components.py
Last active September 22, 2023 13:05
Calculates component values for a TPS6104x buck-boost regulator setup, given a target input value.
from bisect import bisect_left
import math
r_mult_values_smd = [
0.1, 1, 10, 100, 1000, 10000, 100000
]
r_base_values_smd =[
10, 11, 12, 13, 15, 16, 18, 20,
22, 24, 27, 30, 33, 36, 39, 43,
47, 51, 56, 62, 68, 75, 82, 91,
@flisboac
flisboac / jq-jsonobject-set.sh
Last active April 20, 2023 03:02
Various slow-ish portable Shell utilities for JSON values (all depending on `jq`)
#!/bin/sh
##
# Sets properties in a JSON object.
#
# Properties are given in the format `KEY[:TYPE]=VALUE`, as a var-arg argument to the function.
# `TYPE` is optional; if not provided, the value will be simply serialized to string, regardless
# of its format. But if a type is informed, some conversion and validation occurs prior to
# assignment. Type names are case insensitive. Accepted types:
#
@flisboac
flisboac / join-string.state-function.json
Last active January 3, 2023 13:59
simple state function to perform join with json serialization
{
"StartAt": "CreateCliParams",
"States": {
"CreateCliParams": {
"Type": "Pass",
"Next": "CreateCliParams_ifJoinParams",
"Parameters": {
"CliParameterSeparator.$": "$.CliParameterSeparator",
"CliCurrentParameterSeparator": "",
"CliParameters.$": "$.CliParameters[*][*]",
@flisboac
flisboac / certificate_utils.py
Last active September 3, 2022 05:57
Utility Python library and CLI capable of downloading a whole certificate chain; barely tested
# Requires at least Python 3.7, and typing_extensions
from __future__ import annotations
import collections.abc
import datetime
import functools
import os
import pathlib
import re
import shutil
@flisboac
flisboac / test_hipsycl.cpp
Last active August 25, 2022 07:08
An attempt on building a SYCL example program. Build and execute with `build.sh`.
@flisboac
flisboac / backoff.dart
Last active August 12, 2022 13:47
backoff.dart
//
"""
Contém utilitários para capturar e/ou indicar interrupções em processos.
"""
from __future__ import annotations
import signal
from typing import Any, Callable, Mapping, Sequence, Set
@flisboac
flisboac / static-convert-path.ts
Created September 22, 2021 21:45
static-convert-path.ts
type ToPathIndexArray<S extends string> =
S extends `${infer N}[${infer P}]` ? [N, P] : [S];
type ToPathArray<P extends string, _R extends string[] = []> =
P extends `${infer NS}.${infer N}`
? NS extends `${infer IN}[${infer I}]`
? [IN, I, ...ToPathArray<N>, ..._R]
: [...ToPathIndexArray<NS>, ...ToPathArray<N>, ..._R]
: P extends `${infer IN}[${infer I}]`
? [IN, I, ..._R]
@flisboac
flisboac / dod.cpp
Created July 17, 2021 01:46
Differences between OOP vs DOD approaches in software design (only examples here, actually)
// Working snippet at: https://glot.io/snippets/g0jhgoope4
// "DOD" stands for data-oriented design
#include <vector>
#include <cstddef>
#include <iostream>
#include <algorithm>
#include <queue>
#include <emmintrin.h>
#include <xmmintrin.h>