Skip to content

Instantly share code, notes, and snippets.

@Jongy
Jongy / print_raw_term.c
Created December 14, 2019 21:40
Print input characters in raw terminal mode. Useful when developing shells/readline etc.
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <termios.h>
#include <string.h>
int main(void)
{
struct termios tty_attr;
@Jongy
Jongy / null.py
Last active December 14, 2019 22:24
/dev/null tricks using my Linux kernel MicroPython
file_operations = partial_struct("file_operations")
null_fops = file_operations(null_fops)
from kernel_ffi import callback
def my_read_null(file, buf, count, ppos):
pos = p64(ppos)
b = "who said /dev/null must be empty?\n"[pos:]
l = min(len(b), count)
memcpy(buf, b, l)
p64(ppos, pos + l)
int my_global_int = 5;
int mul_by_global(int y)
{
return y * my_global_int;
}