Skip to content

Instantly share code, notes, and snippets.

View multun's full-sized avatar

Victor Collod multun

View GitHub Profile
@multun
multun / libhook.sh
Last active April 8, 2020 18:24
bash space safe cleanup hooks
__cleanup_hook_i=0
__cleanup_hook () {
for ((i=__cleanup_hook_i - 1; i >= 0; i--)); do
eval "\"\${__cleanup_hook_action_${i}[@]}\""
done
}
trap __cleanup_hook EXIT
@multun
multun / config_parser.py
Last active September 28, 2024 22:35
Parse arguments augmented with a YAML config file
import sys
import yaml
import argparse
class ConfigParser():
def __init__(self, *pargs, **kwpargs):
self.options = []
self.pargs = pargs
self.kwpargs = kwpargs
@multun
multun / wow.c
Last active December 12, 2017 14:37
An array iterator in C
#include <stddef.h>
#include <stdio.h>
#define ARR_SIZE(...) (sizeof(__VA_ARGS__) / sizeof((__VA_ARGS__)[0]))
#define FOREACH_ARR(Type, IName, ...) \
for (struct \
{ \
size_t i; \