Skip to content

Instantly share code, notes, and snippets.

@FloydZ
FloydZ / shell.nix
Created April 20, 2024 19:30
Nix Shell for riscv vector extension cross compile
with import <nixpkgs> {};
let
riscv = (import <nixpkgs> {
crossSystem = { system = "riscv64-linux"; };
});
in
stdenv.mkDerivation {
name = "dukek";
src = ./.;
buildInputs = [
@FloydZ
FloydZ / pre-commit
Created February 15, 2024 12:06
git pre-commit hook with llvm and forced build
#!/usr/bin/env bash
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
@FloydZ
FloydZ / shuffle.c
Last active February 13, 2023 21:46
Examples of AVX2 Permutations that shuffle down all limbs selected by a input mask
#ifndef ASSERT
#define ASSERT(x) assert(x)
#endif
/// returns a permutation that shuffles down a mask on 32bit limbs
/// e.g INPUT: 0b10000001
/// <- 256 ->
/// OUTPUT: [ 0 ,..., 7, 0]
/// MSB <-32->
/// <- 8 limbs ->
@FloydZ
FloydZ / cuda_register_count.py
Created December 19, 2021 16:20
Simple script to extract the register count, shared, constant and global memroy consumption of a CUDA file.
#!/usr/bin/python3
import re
from subprocess import Popen, PIPE, STDOUT
import argparse
test_data = """ptxas info : 218048 bytes gmem, 88 bytes cmem[3]
ptxas info : Compiling entry function '_Z12test_fp_zeroIjLj2EEvPT_j' for 'sm_61'
ptxas info : Function properties for _Z12test_fp_zeroIjLj2EEvPT_j
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 5 registers, 332 bytes cmem[0]
@FloydZ
FloydZ / asm.cu
Created December 19, 2021 16:18
Useful C++ abstraction of some PTX instruction. Example of implementing Fp arithmetic on CUDA attached.
#include <iostream>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <helper_cuda.h>
#include <device_launch_parameters.h>
#include <curand.h>
#include <curand_kernel.h>
# The following line will extract every possible `perf` event
perf list | grep -i "^ [[:blank:]][[:alnum:]]" | sed -e 's/^[ \t]*//' | sed 's/ .*//'
@FloydZ
FloydZ / list.md
Created June 16, 2021 21:35 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@FloydZ
FloydZ / filter.md
Created November 3, 2020 20:31
My approach for +null submail adress

//my approach für +null@domain.de

rule:[DeleteNull]

if envelope :detail :matches "to" "null" { discard; stop; }

rule:[Main adress (without subadress)]

if not envelope :detail :matches "to" "?*"

#!/usr/bin/expect -f
proc log {msg} {
puts $::fh "[timestamp -format {%Y-%m-%d %H:%M:%S}]: $msg"
}
set ssh_host [lindex $argv 0]
set ::fh [open "sshlog.$ssh_host" a]
log "{session starts}"
@FloydZ
FloydZ / import_myexpenses_to_gnucash.sh
Created June 13, 2020 14:54
a simple script to create a .csv, which is importable to gnucash from a 'myexpanses' backup.zip file
unzip -n $1
rm -r Pictures
mv BACKUP tmp.db
sqlite3 -header -csv tmp.db "SELECT datetime(date, 'unixepoch', 'localtime'), amount*1.0/100, comment, label, name FROM transactions INNER JOIN accounts on accounts._id = transactions.account_id INNER JOIN payee ON payee._id = transactions.payee_id;" > out.csv