Skip to content

Instantly share code, notes, and snippets.

View harryhanYuhao's full-sized avatar
🎯
Focusing

Harry Han harryhanYuhao

🎯
Focusing
View GitHub Profile
@harryhanYuhao
harryhanYuhao / gist:20bfa03e0272bc6ba433b5e1b9296574
Created October 30, 2023 13:41
i3status bar default config v2.14
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
@harryhanYuhao
harryhanYuhao / Makefile
Created August 2, 2023 12:25
clang makefile
CC=clang
CWARNINGS=-Wall -Wextra -Wpedantic -Wshadow -Wpointer-arith -Wcast-align \
COPTIMISING=-O0 -ggdb3 -fno-omit-frame-pointer -fno-common -fstrict-aliasing
CFLAGS=-std=c11 $(CWARNINGS) $(COPTIMISING)
INSTALL_DIR=$(HOME)/psu/bin
@harryhanYuhao
harryhanYuhao / Makefile
Last active November 19, 2023 21:20
gcc makefile
CC=gcc
CWARNINGS=-Wall -Wextra -Wpedantic -Wformat=2 -Wswitch-default -Wpointer-arith -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls -Wold-style-definition -Waggregate-return -Wformat=2 -Wfatal-errors
COPTIMISING=-O0 -ggdb3 -fno-omit-frame-pointer -ffloat-store -fno-common -fstrict-aliasing -g
CFLAGS=-std=c11 $(CWARNINGS) $(COPTIMISING) -lm
INSTALL_DIR=$(HOME)/psu/bin
@harryhanYuhao
harryhanYuhao / rawmode.c
Created May 26, 2023 08:20
Enable Terminal Raw Mode
// Simple snippets to enable raw mode
// stdin is read as long as any key are pressed
// A simple testing function is included
// Note in raw mode "\n" is not interpreted with "\r" carriage return
// All "\n" shall be replaced with "\r\n" for normal effect
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
@harryhanYuhao
harryhanYuhao / keycode.c
Last active August 2, 2023 09:19
Print key code (read from stdin)
// terminal raw mode is enabled: the keypress is registerred immediately after pressing
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
void enableRAWMode(void);