Skip to content

Instantly share code, notes, and snippets.

@gonsolo
gonsolo / chipyard_arch_nitefury2.txt
Last active April 15, 2024 19:35
Chipyard on Arch with Nitefury II
As of April 2024:
1. Vivado: Do not run installLibs.sh, manually add libs from script, libtinfo.so.5 can be symlinked
2. XDMA:
- For kernel 6.8.x: Use updated driver from https://github.com/gonsolo/dma_ip_drivers.git branch gonsolo.
- "config bar not found": Start kernel with "pci=nomsi", insmod with "poll_mode=1 interrupt_mode=2".
- After that you should have some devices: /dev/xdma*.
@gonsolo
gonsolo / nvidia_530_on_linux_6.3.3.patch
Created May 24, 2023 16:52
Run nvidia driver 530.30.02 on Linux 6.3.3
diff -u -r nvidia-530.30.02/nvidia/nv-mmap.c /home/gonsolo/nvidia-530.30.02/nvidia/nv-mmap.c
--- nvidia-530.30.02/nvidia/nv-mmap.c 2023-02-22 05:37:36.000000000 +0100
+++ /home/gonsolo/nvidia-530.30.02/nvidia/nv-mmap.c 2023-05-24 18:49:07.797789349 +0200
@@ -458,7 +458,7 @@
}
// Needed for the linux kernel for mapping compound pages
- vma->vm_flags |= VM_MIXEDMAP;
+ vm_flags_set(vma, VM_MIXEDMAP);
@gonsolo
gonsolo / git_author_stats.sh
Last active March 17, 2023 08:18
Discover insertions and deletions of an author for a specified time with git
# Print lines added by author
git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep insertions | awk '{sum += $4} END {print sum}'
# Print lines deleted by author
git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep deletions | rev | awk '{print $2}' | rev | awk '{sum += $1} END {print sum}'
# Net amount
echo $(( $(git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep insertions | awk '{sum += $4} END {print sum}') - $(git log --stat --since 2023-01-01 --author="Charlie Chaplin" | grep deletions | rev | awk '{print $2}' | rev | awk '{sum += $1} END {print sum}') ))
@gonsolo
gonsolo / mp3_to_opus.bash
Last active May 3, 2022 09:54
Convert mp3 to opus with GNU parallel respecting whitespace
find . -name \*.mp3 | parallel -q ffmpeg -i {} -c:a libopus -b:a 20k {.}.opus
@gonsolo
gonsolo / mixin.cc
Created April 12, 2021 15:58
Mixin in c++
#include <iostream>
using namespace std;
class A {
public:
void a() { cout << "a" << endl; }
};
template<typename T> struct Mixin: T {
@gonsolo
gonsolo / crtp.cc
Created April 12, 2021 15:56
CRTP aka static polymorphism
#include <iostream>
// CRTP aka static polymorphism
using namespace std;
template<typename T> class Base {
public:
void bla() {
auto derived = static_cast<T&>(*this);
@gonsolo
gonsolo / rename.sh
Last active June 28, 2020 07:31
Recursive mass rename in all files in a directory
find -name \*.swift -exec perl -pi -e "s/bla/laber/g" {} \;
@gonsolo
gonsolo / How to write a Ptex quad
Last active December 15, 2019 14:55
How to write a Ptex quad face
Basically a hello world for using the Ptex API for writing quad face.
The second example writes random colors to triangle meshes.
@gonsolo
gonsolo / Worst01.swift
Created May 29, 2019 15:56
The worst of the worst, part I
func a() {
print("a")
}
func b() {
print("b")
}
func c() {
print("c")
@gonsolo
gonsolo / HelloWindow.swift
Last active April 21, 2022 18:13
Swift 4 macOS Window Hello World
// Hello World Window macOS Swift 4: Creates an empty window
import AppKit
let nsapp = NSApplication.shared
let rect = NSMakeRect(0, 0, 200, 200)
if #available(macOS 10.10, *) {
let window = NSWindow(contentRect: rect,
styleMask: .fullSizeContentView,
backing: NSWindow.BackingStoreType.buffered,