Skip to content

Instantly share code, notes, and snippets.

@PaulMarisOUMary
PaulMarisOUMary / Makefile
Created November 20, 2023 16:40
Makefile: use arguments in the command line + help command
TARGETS := $(shell grep -E '^[a-zA-Z0-9 -]+:' $(MAKEFILE_LIST) | sort | awk -F ':.*' '{print $$1}')
ARGS = $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
.DEFAULT_GOAL := help
help: # Show this help
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
%: # Allow to pass arguments to 'make' commands without errors and show help if the command is not found
@if [ -z "$(filter $(firstword $(MAKECMDGOALS)),$(TARGETS))" ]; then \
@PaulMarisOUMary
PaulMarisOUMary / star.c
Created October 12, 2023 20:24
ASCII star of n using only write sys call (my_putchar)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void my_putchar(char c)
{
write(1, &c, 1);
}
static void top(unsigned int size) {