Skip to content

Instantly share code, notes, and snippets.

View ammarfaizi2's full-sized avatar
๐Ÿ€
Baby Opossum Posse

Ammar Faizi ammarfaizi2

๐Ÿ€
Baby Opossum Posse
View GitHub Profile
1) Soft advance to reduce the number of memmove() calls.
2) Fully buffered stdio, reduce the number of write() syscalls.
diff --git a/http_logger_old.c b/http_logger.c
index 7d75a0ee5a2f..6ab4affb1ee2 100644
--- a/http_logger_old.c
+++ b/http_logger.c
@@ -1687,6 +1687,7 @@ struct buf {
uint64_t cap;
diff --git a/http_logger_old.c b/http_logger.c
index 7d75a0ee5a2f..a60c4b98c9f7 100644
--- a/http_logger_old.c
+++ b/http_logger.c
@@ -1687,6 +1687,7 @@ struct buf {
uint64_t cap;
uint64_t len;
char *buf;
+ char *orig_buf;
};
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2025 Ammar Faizi <[email protected]>
*
* http_logger.c - HTTP logger via LD_PRELOAD.
*
* gcc -Wall -Wextra -fpic -fPIC -Os http_logger.c -o /tmp/http_logger.so;
* export LD_PRELOAD=/tmp/http_logger.so;
* export GWNET_HTTP_LOG_FILE=/tmp/http.log;
* bash -c 'for i in {1..1000000}; do printf "POST /aaa HTTP/1.1\r\nHost: test.local\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nabcde\r\n0\r\n\r\n"; done | nc 127.0.0.1 8080';
// SPDX-License-Identifier: GPL-2.0-only
/*
* gwnet_http1.c - HTTP/1.0 and HTTP/1.1 parser.
*
* Copyright (C) 2025 Ammar Faizi <[email protected]>
*/
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
// SPDX-License-Identifier: GPL-2.0-only
/*
* Author: Ammar Faizi <[email protected]>
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef PM_USE_TCP
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
static FILE *log_file = NULL;
static void init_log(void)
{
const char *log_path;
.section .rodata
msg_enter_pwd:
.string "Enter password: "
msg_pwd_wrong:
.string "Sorry, wrong password!"
msg_pwd_ok:
.string "\nPassword OK!"
msg_fmt_flag:
.string "Congratulations, you solved it!\nThe flag is: %s\n"
Recently, I saw an announcement that the mobile network in Bali will
be shut down during Nyepi.
What will happen to the servers in a data center in Bali?
Will they also go offline?
ChatGPT's response:
from matplotlib.ticker import ScalarFormatter
import xml.etree.ElementTree as ET
import matplotlib.pyplot as plt
import pandas as pd
from email.utils import format_datetime
from datetime import datetime, timezone, timedelta
import matplotlib.dates as mdates
import matplotlib.font_manager as fm
import requests
<?php
const MAIL_LOG_PATH = __DIR__."/users/ubuntu/gwmail/storage/gwmail-master/var/log/mail.log";
const BAN_LIST_PATH = __DIR__."/storage/mail_ip_ban_list.txt";
const IPSET_PATH = "/usr/sbin/ipset";
const FAIL_THRESHOLD = 200;
const CHECK_INTERVAL_SECS = 120;
const CIDR_PRECISION = 24;
function grab_ban_list_map(string $path): array