Skip to content

Instantly share code, notes, and snippets.

View saethlin's full-sized avatar
🦀

Ben Kimock saethlin

🦀
View GitHub Profile
@saethlin
saethlin / packet_mmap_clock.rs
Created June 13, 2021 21:07
Does the PACKET_MMAP clock go backwards?
let mut cap = packet_capture::Capture::new("enp68s0").unwrap();
let mut previous_time = (0, 0);
loop {
let packet = cap.next();
let time = (packet.tp_sec, packet.tp_nsec);
if time < previous_time {
println!("{:?}: {:?} {:?}", chrono::Local::now(), time, previous_time);
} else {
previous_time = time;
}
@saethlin
saethlin / jsoncmp.rs
Created September 22, 2020 20:56
Order-resistant JSON diffing cargo script
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [package]
//! edition = "2018"
//!
//! [dependencies]
//! serde = "1.0"
//! serde_json = "1.0"
//! ```
@saethlin
saethlin / read_hdf5_parallel.c
Last active April 26, 2020 20:58
Bypassing the library to read HDF5 datasets in parallel
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/time.h>
#include <hdf5.h>
// The read syscall is allowed to return without reading all the requested bytes
// In my experience it'll only read ~2^31 bytes at a time so we NEED the retry logic
void retrying_read(char* dest, size_t count, FILE* stream) {
@saethlin
saethlin / colt-median_41026727_663.log
Created September 15, 2019 16:20
MPI errors for Samoxive
[c24b-s28.ufhpc:24695] PMIX ERROR: PMIX TEMPORARILY UNAVAILABLE in file ptl_tcp.c at line 685
[c24b-s28.ufhpc:24695] PMIX ERROR: UNREACHABLE in file ptl_usock.c at line 177
[c24b-s28.ufhpc:24695] OPAL ERROR: Unreachable in file ext2x_client.c at line 109
--------------------------------------------------------------------------
The application appears to have been direct launched using "srun",
but OMPI was not built with SLURM's PMI support and therefore cannot
execute. There are several options for building PMI support under
SLURM, depending upon the SLURM version you are using:
version 16.05 or later: you can use SLURM's PMIx support. This
import numpy as np
import numba
import time
def add_numpy(a, b):
return np.sum(a**2 + b**2)
@numba.njit(parallel=True, fastmath=True)
import pycuda.autoinit
import pycuda.driver as drv
import numpy as np
import h5py
from imageio import imwrite
import matplotlib.pyplot as plt
import matplotlib
from pycuda.compiler import SourceModule
@saethlin
saethlin / launch.sh
Created January 17, 2019 04:47
Basically overleaf
#!/usr/bin/env bash
trap "kill 0" SIGINT
HOST=$(cut -d':' -f1 <<<$1)
TEX_PATH=$(cut -d':' -f2 <<<$1)
DIR=`dirname $TEX_PATH`
FILE=`basename $TEX_PATH`
(lambda __g, __print: [[(lambda __after: (lambda __after: [__after() for __g['tax'] in [(((((((((userIncome - 418001) * 0.396) + ((418400 - 416701) * 0.35)) + ((416700 - 191650) * 0.33)) + ((191650 - 91901) * 0.28)) + ((91900 - 37951) * 0.25)) + ((37950 - 9326) * 0.15)) + (9325 * 0.1)))]][0] if (userIncome >= 418001) else (lambda __after: [__after() for __g['tax'] in [((((((((userIncome - 416701) * 0.35) + ((416700 - 191650) * 0.33)) + ((191650 - 91901) * 0.28)) + ((91900 - 37951) * 0.25)) + ((37950 - 9326) * 0.15)) + (9325 * 0.1)))]][0] if (userIncome >= 416701) else (lambda __after: [__after() for __g['tax'] in [(((((((userIncome - 191650) * 0.33) + ((191650 - 91901) * 0.28)) + ((91900 - 37951) * 0.25)) + ((37950 - 9326) * 0.15)) + (9325 * 0.1)))]][0] if (userIncome >= 191651) else (lambda __after: [__after() for __g['tax'] in [((((((userIncome - 91901) * 0.28) + ((91900 - 37951) * 0.25)) + ((37950 - 9326) * 0.15)) + (9325 * 0.1)))]][0] if (userIncome >= 91901) else (lambda __after: [__after() for __g['tax'
@saethlin
saethlin / aws-bot.txt
Created December 16, 2018 07:03
frozen backtrace
* thread #1, name = 'lolxd-bot', stop reason = signal SIGSTOP
* frame #0: 0x0000000000886a46 lolxd-bot`__syscall at syscall.s:13
frame #1: 0x000000000087f1eb lolxd-bot`recvfrom(fd=<unavailable>, buf=<unavailable>, len=<unavailable>, flags=<unavailable>, addr=<unavailable>, alen=<unavailable>) at recvfrom.c:7
frame #2: 0x00000000008611bd lolxd-bot`_$LT$std..net..tcp..TcpStream$u20$as$u20$std..io..Read$GT$::read::hc758e0e252f17143 [inlined] std::sys::unix::net::Socket::recv_with_flags::h5897433169e91fcb at net.rs:235
frame #3: 0x00000000008611aa lolxd-bot`_$LT$std..net..tcp..TcpStream$u20$as$u20$std..io..Read$GT$::read::hc758e0e252f17143 [inlined] std::sys::unix::net::Socket::read::h61cd1a08b158ef7b at net.rs:244
frame #4: 0x00000000008611aa lolxd-bot`_$LT$std..net..tcp..TcpStream$u20$as$u20$std..io..Read$GT$::read::hc758e0e252f17143 [inlined] std::sys_common::net::TcpStream::read::hdae7457dd4e75e61 at net.rs:227
frame #5: 0x00000000008611aa lolxd-bot`_$LT$std..net..tcp..TcpStream$u20$as$u
(lldb) attach 20328
Process 20328 stopped
* thread #1: tid = 4750, 0x76c21132, name = 'reqwest-interna', stop reason = signal SIGCONT
frame #0: 0x76c21132
-> 0x76c21132: strbtmi r4, [r0], -r7, lsl #12
0x76c21136: .long 0xfdbbf008 ; unknown opcode
0x76c2113a: .long 0xf85d4638 ; unknown opcode
0x76c2113e: vstmialt r0, {d14, d15}
thread #2: tid = 4751, 0x76cb0454, name = 'hyper-dns0', stop reason = signal SIGCONT
frame #0: 0x76cb0454