Skip to content

Instantly share code, notes, and snippets.

const std = @import("std");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const a = gpa.allocator();

    const hoge_str = try a.dupe(u8, "hogehoge");
    defer a.free(hoge_str);
@uulm-janbaudisch
uulm-janbaudisch / package-msys.bash
Created December 18, 2023 11:55
A packaging script for creating distributable archives of software built in MSYS2.
#!/bin/bash
# Check if running from within MSYS2.
if [ -z "$MSYSTEM" ];
then
>&2 echo "This is intended to be run from within an MSYS2 environment."
exit 1
fi
# Check arguments for correct length.

Enable & Using vGPU Passthrough

This gist is almost entirely not unlike Derek Seaman's awesome blog:

Proxmox VE 8: Windows 11 vGPU (VT-d) Passthrough with Intel Alder Lake

As such please refer to that for pictures, here i will capture the command lines I used as i sequence the commands a little differently so it makes more logic to me.

This gists assumes you are not running ZFS and are not passing any other PCIE devices (as both of these can require addtional steps - see Derek's blog for more info)

This gist assumes you are not running proxmox in UEFI Secure boot - if you are please refer entirely to dereks blog.

@zidenis
zidenis / 5_steps_for_creating_templates_and_vms_on_proxmox_using_linux_distros_cloud_images.md
Last active April 2, 2025 18:25
Creating Templates and Virtual Machines on Proxmox using cloud images from various Linux distributions.

5 Steps for Creating Templates and Virtual Machines on Proxmox using Linux Distro's Cloud Images

This tutorial guides you through the process of creating Templates and Virtual Machines on Proxmox using cloud-based images from various Linux distributions. We provide clear instructions for Alma Linux 9, Amazon Linux 2, CentOS 9, Fedora 38, Oracle Linux 9, RHEL 9, Rocky Linux 9, and Ubuntu 23.04 Lynx Lobster.

Note: The instructions have been tested on Proxmox 8.0.4.

Let's begin by choosing the cloud-based image. If you already have your preferred Linux distribution, skip to the 1st step.

To assist in making informed choices when selecting a Linux distribution for your virtual machines, we've compiled a table showcasing key characteristics of each cloud image. This table provides a snapshot of important attributes, including kernel version, Python version, number of processes initialized after boot, number of packages installed, free memory after boot, VM disk size, root partition disk size, used size on t

@benitogf
benitogf / mirror.sh
Last active February 5, 2025 21:45
ZFS mirror ubuntu boot drive
#!/bin/sh
# Assumptions and requirements
# - All drives will be formatted. These instructions are not suitable for dual-boot
# - No hardware or software RAID is to be used, these would keep ZFS from detecting disk errors and correcting them. In UEFI settings, set controller mode to AHCI, not RAID
# - These instructions are specific to UEFI systems and GPT. If you have an older BIOS/MBR system, please use https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html
# change the these disks variables to your disks paths (check with lsblk)
DISK1="/dev/nvme0n1"
DISK2="/dev/nvme1n1"

All digest-* packages built with the same GPG key:

$ gpg --list-keys
pub   rsa4096 2022-06-30 [SC]
      A5EA7083CF9513E99A476505B081E2685FE35E6E
uid           [ultimate] MNX Cloud Package Signing (Linux) <[email protected]>
sub   rsa4096 2022-06-30 [E]
#!/usr/bin/env bash
Z=$(curl -s https://ziglang.org/download/index.json | jq -r '.master."x86_64-linux".tarball')
OUT_DIR=$(echo "$Z" | awk -F "/" '{ print $NF }' | sed 's/.tar.xz//')
if [ -d "$OUT_DIR" ]; then
echo "Latest Zig already present: $OUT_DIR"
else
curl -s "$Z" | tar xJf -
fi
@svaniksharma
svaniksharma / matrix.zig
Created May 7, 2023 05:42
Optimizing Matrix Multiplication in Zig
const std = @import("std");
const mem = std.mem;
const meta = std.meta;
const math = std.math;
const Vector = meta.Vector;
const expect = std.testing.expect;
fn generateSquareMatrix(N: usize, allocator: mem.Allocator, gen_rand: bool) ![][]f64 {
var matrix: [][]f64 = undefined;
matrix = try allocator.alloc([]f64, N);
@tetsu-koba
tetsu-koba / c2zig
Last active July 2, 2024 07:37
shell script for zig translate-c
#!/bin/bash -eu
if [ $# -ne 1 ]; then
echo "Usage: $0 <cfilename> ending '.c' or '.h'"
exit 1
fi
if [[ $1 == *.c ]]; then
OUTPUT=$(basename $1 .c)_translated.zig
elif [[ $1 == *.h ]]; then
OUTPUT=$(basename $1 .h)_h_translated.zig
else
@bgeneto
bgeneto / fortran-vs-python-integration-loop.md
Last active February 17, 2025 13:19
Python vs Fortran performance on trapezoidal numerical integration

Python numerical integration performance

Out of the box performance of python numerical integration is poor. Here we present three python versions of the trapezoidal rule.

Python code (naive version)

import math
import time