Skip to content

Instantly share code, notes, and snippets.

View folkertdev's full-sized avatar

Folkert de Vries folkertdev

View GitHub Profile
@folkertdev
folkertdev / Cargo.toml
Created September 9, 2021 20:45
Wasmer bug
[package]
name = "wasmer-bug"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
wasmer = "2.0.0"
wasmer-wasi = "2.0.0"
@folkertdev
folkertdev / bad_morphic
Created February 6, 2022 20:00
Roc+Morphic join point problem
program {
mod "UserApp" {
type "jY\xe2\xcd\xd2\xfd/t" = type_10 where {
type type_0 = "UserApp"::"jY\xe2\xcd\xd2\xfd/t";
type type_1 = "UserApp"::"jY\xe2\xcd\xd2\xfd/t";
type type_2 = (type_0, type_1);
type type_3 = ();
type type_4 = (type_3);
type type_5 = heap_cell;
type type_6 = (type_5);
@folkertdev
folkertdev / ioctl_ethtool.rs
Created July 20, 2022 13:18
Get timestamp capabilities of a network interface using ioctl in rust
#[repr(C)]
#[derive(Default)]
struct ethtool_ts_info {
cmd: u32,
so_timestamping: u32,
phc_index: u32,
tx_types: u32,
tx_reserved: [u32; 3],
rx_filters: u32,
rx_reserved: [u32; 3],
@folkertdev
folkertdev / init.vim
Last active August 10, 2023 18:38
public init.vim
let mapleader=","
" unset the mouse
set mouse=
au BufRead,BufNewFile *.elm set filetype=elm
" copy to system clipboard
" see http://askubuntu.com/questions/347519/unable-to-copy-from-vim-to-system-clipboard
set clipboard=unnamedplus
@folkertdev
folkertdev / main.rs
Created May 19, 2023 22:16
A rust example that writes a message with ancillary data (a control message) and then reads it from the error queue
use std::io::{Error, ErrorKind};
use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
use std::os::unix::io::AsRawFd;
use tokio::io::unix::AsyncFd;
use tokio::io::Interest;
pub(crate) fn cerr(t: libc::c_int) -> std::io::Result<libc::c_int> {
match t {
@folkertdev
folkertdev / mio_error_event.rs
Created June 7, 2023 19:42
mio responding to a message arriving on the error queue (EPOLLPRI)
use std::net::SocketAddr;
use std::os::unix::io::AsRawFd;
use std::thread;
use mio::net::UdpSocket;
use mio::{Events, Interest, Poll, Token};
const SOCKET_TOKEN: Token = Token(0);
fn main() {
@folkertdev
folkertdev / main.roc
Created July 19, 2023 12:05
brainroc
app "brainroc"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br",
}
imports [
pf.File,
pf.Path,
pf.Stdout,
pf.Task,
]
@folkertdev
folkertdev / main.roc
Created July 19, 2023 16:43
brainfuck interpreter using tail calls
app "brainroc"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.3.2/tE4xS_zLdmmxmHwHih9kHWQ7fsXtJr7W7h3425-eZFk.tar.br",
}
imports [
pf.File,
pf.Path,
pf.Stdout,
pf.Task,
]
@folkertdev
folkertdev / crc32.c
Created February 19, 2024 14:43
a vectorized crc32 implementation (from the zlib-ng repository)
// compile with
//
// $ clang -shared -o libcrc32.so -Wall -Werror -fpic -march=native -O3 crc32.c
//
// This command only works on x86_64 systems that support the pclmulqdq instruction.
#include <immintrin.h>
#include <wmmintrin.h>
#include <smmintrin.h> // _mm_extract_epi32
#include <inttypes.h>
#include <stdio.h>
@folkertdev
folkertdev / README.md
Created March 9, 2024 17:06
Creating a zip file with a unix extra field

run and validate with

rm -f extrafield.zip && python add_unix_extra_field.py && zipinfo -v extrafield.zip

this should show

Archive:  extrafield.zip