Skip to content

Instantly share code, notes, and snippets.

@AlexTalker
AlexTalker / hdubench.cc
Created October 20, 2025 11:03
HDD Geometry benchmarking
/*
Discovering Hard Disk Physical Geometry through Microbenchmarking
http://blog.stuffedcow.net/2019/09/hard-disk-geometry-microbenchmarking/
Henry Wong, 2019/09/06
2022/10/12: Fixed overflow in find_next_track_boundary. Add more sanity checks to RPM measurement.
*/
#include <stdio.h>
#include <sys/types.h>
@AlexTalker
AlexTalker / kcflags.sh
Created October 13, 2025 17:18
Unholy ~trinity~ quadruplicity of false-positives for ./configure
export KCFLAGS="${KCFLAGS} -Wno-unused-value -Wno-unused-variable -Wno-uninitialized -Wno-frame-larger-than"
@AlexTalker
AlexTalker / auth.c
Created June 28, 2022 16:22
Simple example of how `getent ---service <service>` retrieves the information for specific service only.
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
#include <nss.h>
#include <stdio.h>
/* Possibly a memory leak according to documentation */
#define SETUP_DB(db, service) if (service != NULL) { __nss_configure_lookup(db, service); }
void print_passwd(struct passwd *entry) {
@AlexTalker
AlexTalker / mpath-debug.sh
Created April 8, 2022 16:58
Collect information about present multipath devices in sufficient for `awk` format
#!/usr/bin/env bash
# vim: set number tabstop=4 shiftwidth=4 smarttab expandtab:
_transform_slaves() {
xargs -n1 -I{} realpath "/sys/block/{}/../../" | sort -u | tr '\n' ','
}
iterate_dms() {
local dmname dmuuid dmslaves dmslavescnt
@AlexTalker
AlexTalker / pcie-throughput.sh
Created January 12, 2022 13:15
Show performance information about NVMe PCie drives or any PCIe sysfs device, based on https://community.mellanox.com/s/article/understanding-pcie-configuration-for-maximum-performance
#!/usr/bin/env bash
# BEGIN: PCIe-related things
_read_attr() {
local dir="$1" name="$2"
local path=$(printf "%s/%s" "$dir" "$name")
cat "$path"
}
#!/usr/bin/env bash
function cat_passwd_column() {
awk -F: '{ print $2; }'
}
function cat_passwd_salt() {
awk -F'$' '{ print $3; }'
}
#!/usr/bin/env bash
_calc() { awk "BEGIN{print $*}"; }
_call_lspci() {
local pcie="$1"
lspci -s "$pcie" -vvv
}
@AlexTalker
AlexTalker / helloworld.pyx
Created March 5, 2020 09:49
Direct I/O in Python with Cython
from libc.stdlib cimport malloc, free
from libc.stdio cimport *
from posix.unistd cimport *
from posix.stdlib cimport *
from posix.fcntl cimport *
def test_cython(path):
cdef int ret
cdef int stdout_save, dev_null
cdef int O_DIRECT = 040000
# Maintainer: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor:
pkgname=marker-git
pkgver=2018.03.09.r86.g2d701156
pkgrel=1
pkgdesc='Markdown editor for linux made with Gtk+-3.0'
arch=('x86_64')
url='https://github.com/fabiocolacio/Marker'
license=('GPL3')
@AlexTalker
AlexTalker / mock_open.pl
Created April 7, 2017 18:02 — forked from ernix/mock_open.pl
Mock(override) built-in `open` function in perl.
#
# http://perldoc.perl.org/CORE.html#OVERRIDING-CORE-FUNCTIONS
# > To override a built-in globally (that is, in all namespaces), you need to
# > import your function into the CORE::GLOBAL pseudo-namespace at compile
# > time:
# >
# > BEGIN {
# > *CORE::GLOBAL::hex = sub {
# > # ... your code here
# > };