Skip to content

Instantly share code, notes, and snippets.

@nir9
nir9 / editor.c
Last active April 21, 2024 01:08
Minimalist Text Editor Written in C for Linux - Just for fun, not for production use :) -- Notice: This editor will truncate files that are bigger than 1024 bytes --
#include <stdio.h>
#include <string.h>
void edit_line(char* buffer, int current_line) {
for (int i = 0; i < current_line; i++) {
buffer = strchr(buffer, '\n') + 1;
}
char* line_end = strchr(buffer, '\n');
char saved[1024] = { 0 };
@nir9
nir9 / server.c
Created November 25, 2023 16:50
Minimalist C Web Server - not for production use, only for fun :)
#include <sys/socket.h>
#include <string.h>
#include <fcntl.h>
#include <sys/sendfile.h>
#include <unistd.h>
#include <netinet/in.h>
void main() {
int s = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr = {
@nir9
nir9 / beep.cpp
Last active December 4, 2023 03:43
Beep with a ioctl
#include <stdio.h>
#include <cstdint>
#include <Windows.h>
struct Beep
{
uint32_t freq;
uint32_t duration;
};
@nir9
nir9 / NoteServer.py
Last active January 8, 2024 05:51
Notes server in python
import socket
import datetime
"""
Instead of header+stuff
just make a function that adds that
"""
def list_to_html(l):
html = ""