did some more mining off camera

also posts can be hidden by prepending a _
This commit is contained in:
Snorre Ettrup Altschul 2025-02-07 00:45:54 +01:00
parent 302d405cc3
commit 63644ecc7f
8 changed files with 67 additions and 16 deletions

View file

@ -284,7 +284,36 @@ const tokens2html = (tokens, title) => {
for (let token of tokens) { for (let token of tokens) {
switch (token.type) { switch (token.type) {
case "toc": case "toc":
output += "TABLE LE CONTENTOS" let headers = tokens.filter(x => x.type == "header");
let listHTML = '';
let currentLevel = 0;
headers.forEach(header => {
let indent = ' '.repeat(header.level - 1); // Indentation based on header level
// Check if we need to create a new <ul> for this level
if (header.level > currentLevel) {
listHTML += '<ul>'; // New nested list
} else if (header.level < currentLevel) {
listHTML += '</ul>'.repeat(currentLevel - header.level); // Close previous <ul>s
}
// Add the list item
listHTML += `
${indent}<li><a href="#${header.content.replace(/\s+/g, '-')}">${header.content}</a></li>
`;
currentLevel = header.level; // Update the current level
});
// Close any remaining <ul> elements
if (currentLevel > 0) {
listHTML += '</ul>'.repeat(currentLevel-1);
}
output += "<div class=\"toc\"><h2>Table of Contents</h2>" + listHTML + "</div>";
break; break;
case "title": case "title":
output += `<h1>${title}</h1>` output += `<h1>${title}</h1>`

View file

@ -3,10 +3,10 @@ Functions Vectors Evaluate Isolate Solve Matrix Tensor Calculus Derivation Limit
# Openbirch # Openbirch
Cool fucking cas tool. Cool fucking cas tool.
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")
![image of openbirch](/posts/openbirch/openbirch.png "Cool image of the cool fucking cas tool") ![image of openbirch](/posts/My language is 700x slower than python/openbirch.png "Cool image of the cool fucking cas tool")

View file

@ -1,5 +1,7 @@
2 2
Minecraft Rust Async Networking Proxy CRIU Minecraft Rust Async Networking Proxy CRIU
\title
\toc
# Minecraft servers are HUNGRY # Minecraft servers are HUNGRY
They hunger for your ram and your cpu. This makes it either expensive or They hunger for your ram and your cpu. This makes it either expensive or
@ -46,7 +48,7 @@ an internal port based on the subdomain. I quickly found out that this did
some research I decided on creating my own reverse proxy that spoke the some research I decided on creating my own reverse proxy that spoke the
minecraft protocol instead of HTTP. minecraft protocol instead of HTTP.
# The Minecraft protocol ## The Minecraft protocol
Minecraft implements its own protocol consistent of packets. My first idea was to see if anybody had created a Minecraft implements its own protocol consistent of packets. My first idea was to see if anybody had created a
rust library for dealing with minecraft packets. rust library for dealing with minecraft packets.
@ -56,7 +58,7 @@ was useful for seeing how an implementation of parsing packets was done, but ult
*images of minecraft protocol* *images of minecraft protocol*
# Detecting the subdomain ## Detecting the subdomain
Luckily for me, the Minecraft procotol sends the full address it is trying to connect to during the handshake. This meant that I simply Luckily for me, the Minecraft procotol sends the full address it is trying to connect to during the handshake. This meant that I simply
had to parse the handshake and extract the subdomain from the address, see if it matches any configured server, and then redirect all had to parse the handshake and extract the subdomain from the address, see if it matches any configured server, and then redirect all
@ -76,7 +78,7 @@ but the sockets are connected on the kernel level.
After hours of debugging I found the solution. `stream.set_nodelay(true)` After hours of debugging I found the solution. `stream.set_nodelay(true)`
## ... **...**
**All this time the problem was as simple as saying ** `if (slow) { dont(); }`! **All this time the problem was as simple as saying ** `if (slow) { dont(); }`!

17
public/posts/_toc.md Normal file
View file

@ -0,0 +1,17 @@
0
Tick Tock Cock
\title
\toc
# Big Chapter
## Sub-chapter
## Sub-chapter 2
# Another big chapter
## Sub-Chapter again
### Third sub chapter :O

View file

@ -20,6 +20,12 @@
text-justify: auto; text-justify: auto;
} }
.toc {
background: var(--background-text);
border-radius: var(--radius);
padding: var(--padding);
}
pre.quote { pre.quote {
font: inherit; font: inherit;

View file

@ -1,5 +0,0 @@
0
Tick Tock Cock
# Table of Contents test
\toc

View file

@ -125,6 +125,8 @@ fn handle_connection(mut stream: TcpStream) {
if y.is_some() { if y.is_some() {
if y.unwrap().ends_with(".html") { if y.unwrap().ends_with(".html") {
false false
} else if y.unwrap().starts_with("_") {
false
} else { } else {
true true
} }