Skip to content

Instantly share code, notes, and snippets.

@hydrastro
hydrastro / c_nostd.txt
Created June 23, 2022 16:41 — forked from tcoppex/c_nostd.txt
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
@hydrastro
hydrastro / syscall.S
Last active January 25, 2022 12:43
syscall.S
/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
@hydrastro
hydrastro / shitplate.c
Created December 21, 2021 23:43 — forked from skullchap/shitplate.c
simple dull way of http template generation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BFSZ 1024
char* template = "test.html";
char* generated = "new_test.html";
char* listFile = "zanimals.txt";
define("HTTP_CONTINUE", 100);
define("HTTP_SWITCHING_PROTOCOLS", 101);
define("HTTP_PROCESSING", 102);
define("HTTP_EARLY_HINTS", 103);
define("HTTP_OK", 200);
define("HTTP_CREATED", 201);
define("HTTP_ACCEPTED", 202);
define("HTTP_NON_AUTHORITATIVE_INFORMATION", 203);
define("HTTP_NO_CONTENT", 204);
define("HTTP_RESET_CONTENT", 205);
@hydrastro
hydrastro / ascii_cat
Created December 2, 2021 17:06
ascii cat
/\_/\
(O. o)__/
(___)|
| | |_)
(_/\_)
@hydrastro
hydrastro / dead_switch.sh
Last active October 23, 2021 16:19
dead_switch.sh
#!/bin/bash
# Add this script to crontab:
# `sudo printf "33 3\t* * *\troot\t/etc/dead_switch.sh" >> /etc/crontab`
# Dead Switch configuration
your_email=""
server_username=""
warning_time=$((3600 * 24 * 14))
trigger_time=$((3600 * 24 * 28))
@hydrastro
hydrastro / fizzbuzz.c
Last active November 20, 2021 08:30
fizzbuzz.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *
itoa (
int value ,
char *
result ),
charlist [
10 ];
@hydrastro
hydrastro / locks.asm
Created September 26, 2021 18:01
MIPS locks
# Atomic Swap/Exchange (Test-and-set) (T&S)
lock1: addi $t0, $zero, 1
ll $t1, 0($s1)
sc $t0, 0($s1)
beq $t0, $zero, lock1
add $s2, $zero, $t1
# Atomic Increment (Fetch-and-Add) (FAA)
lock2: ll $t0, 0($s1)
addi $t1, $t0
@hydrastro
hydrastro / convert_time_ago.py
Last active July 23, 2021 16:00
Time ago/Convert time
import time
def convert_time(conv_time, ago=False):
"""Returns time ago/stuff lol"""
periods = ["second", "minute", "hour", "day", "week", "month", "year", "decade", "century", "millennium"]
lengths = [60, 60, 24, 7, 4.35, 12, 10, 10, 10]
if ago:
now = time.time()
difference = now - conv_time
else:
@hydrastro
hydrastro / send_mail.sh
Last active October 22, 2021 13:18
Bash SMTP(/S) authentication and mailsending script
#!/bin/bash
smtp_address=""
smtp_username=""
smtp_password=""
smtp_server=""
smtp_port=587
use_starttls=true
send_mail() {