Skip to content

Instantly share code, notes, and snippets.

@edef1c
edef1c / Makefile
Created Aug 17, 2021 — forked from glandium/Makefile
Linux kernel module for Zen workaround for rr
View Makefile
obj-m = zen_workaround.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
@edef1c
edef1c / 0001-Linux-consider-ZFS-ARC-to-be-cache.patch
Last active May 20, 2020
ZFS on Linux ARC support patch for htop (multi's revised version)
View 0001-Linux-consider-ZFS-ARC-to-be-cache.patch
From 78ade158ed480a6958fd6d477ee90f2bd2d1f668 Mon Sep 17 00:00:00 2001
From: multiplexd <multi@in-addr.xyz>
Date: Sat, 9 May 2020 20:31:35 +0100
Subject: [PATCH v2] Linux: consider ZFS ARC to be cache
This patch adds an arcSize member to the ProcessList struct, and then
adjusts the usedMem and cachedMem values when the memory usage meter is
initialised in Platform_setMemoryValues(), and not earlier.
---
ProcessList.c | 1 +
View gist:8f362930518bad3493b4cbbf7dda5c9b
building '/nix/store/s103zvdl4nrsi24vl0xvsjmdcphab79m-unit-nix-daemon.service.drv'...
building '/nix/store/4sni1imp36r5mj8vjgphngx2p14aqm1x-system-units.drv'...
building '/nix/store/zf3ypcls84l6pmf516krf888in81syhp-etc.drv'...
building '/nix/store/xxyk1rn73xss107wapp71nkrmdqc1kcg-nixos-system-platypus-20.03pre-git.drv'...
stopping the following units: nix-daemon.service, nix-daemon.socket
activating the configuration...
setting up /etc...
error: cannot connect to daemon at '/nix/var/nix/daemon-socket/socket': Connection refused
Activation script snippet 'nix' failed (1)
reloading user units for edef...
@edef1c
edef1c / env-necessary.pl
Last active Oct 20, 2019
perl script to check what environment variables a program actually needs to run
View env-necessary.pl
#! /usr/bin/env perl
use POSIX ":sys_wait_h";
my @untested = keys %ENV;
sub choose {
return splice @untested, rand @untested, 1;
}
sub works {
@edef1c
edef1c / ugdb-overlay.nix
Created Oct 18, 2019
ugdb packaged for Nix
View ugdb-overlay.nix
self: super:
with self;
with rustPlatform;
{
ugdb = buildRustPackage rec {
pname = "ugdb";
version = "0.1.4";
src = fetchFromGitHub {
owner = "ftilde";
@edef1c
edef1c / nixos-option
Last active Aug 17, 2019
NixOS deployment scripts
View nixos-option
nixos-rebuild
@edef1c
edef1c / sigevent.c
Last active Aug 13, 2019
proof-of-concept of siglongjmp/ppoll-based signal handling in an event loop
View sigevent.c
#define _GNU_SOURCE
#include <err.h>
#include <errno.h>
#include <poll.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
View nix-jump.kak
define-command nix-jump %{
execute-keys <esc><a-i><a-w>
edit %sh{
if [[ "$kak_selection" =~ ^\<(.*)\>$ ]]; then
path="$(nix-instantiate --find-file "${BASH_REMATCH[1]}")"
else
cd "$(dirname "$kak_buffile")"
path="$(realpath "$kak_selection")"
fi
if [ -d "$path" ]; then
@edef1c
edef1c / default.nix
Last active Mar 9, 2019
NixOS module for qemu-user binfmt_misc
View default.nix
{ pkgs, ... }:
let inherit (pkgs) stdenv qemu getopt; in
{
systemd.additionalUpstreamSystemUnits = [
"proc-sys-fs-binfmt_misc.automount"
"proc-sys-fs-binfmt_misc.mount"
];
environment.etc."binfmt.d/qemu-user.conf".source = stdenv.mkDerivation {
name = "qemu-binfmt";
inherit (qemu) src;
@edef1c
edef1c / playground.rs
Created Feb 17, 2019
for .. { .. } else { .. } macro for Rust
View playground.rs
macro_rules! for_expr {
( $lhs:pat in $iter:ident $body:block else $else:block ) => {
for_expr!($lhs in ($iter) $body else $else)
};
( $lhs:pat in ($iter:expr) $body:block else $else:block ) => {{
let mut iter = ::core::iter::IntoIterator::into_iter($iter);
if let Some(mut item) = iter.next() {
loop {
let $lhs = item;
let result = $body;