Writing a HTTP Server in Zig

🖊️ 🔖 code zig 💬 0

I continue my Zig adventure by following up an echo server with a HTTP server.

I’ve been doing web development the majority of my career. Yet I never really thought too much about HTTP servers, much less what it would take to implement one. So it made perfect sense for me when I started to learn Zig to build one. The problem space is a nice mix of socket programming and string handling.

A Simple Echo Server in Zig

🖊️ 🔖 code zig 💬 0

Recently I’ve been trying to hone my low-level programming skills. Zig is cool and it’s less painful than Rust.

Eventually I’d like to implement a HTTP server. We’ll see if I get there. As a baby step, here is a simple echo server written in Zig:

Should MIT Really be the Default License?

🖊️ 🔖 code 💬 0

When and why did MIT become the default license for open source projects?

I was watching some Fireship videos yesterday and one popped up called The Dark Side of Open Source // What really happened to Faker.js? I am familiar with the story of Aaron Swartz, but I had not heard about faker.js. The author of this extremely popular library got so fed up with companies taking and giving nothing in return that he blanked out the repo and broke it for everyone.

I couldn’t help but notice faker.js was under the MIT license.

What Learning Rust Feels Like

🖊️ 🔖 code memes 💬 0

Learning Rust

I think I’m going to try Zig

A Web Component for Highlighting Remote Code with Prism

🖊️ 🔖 code 💬 0

I was playing around with Web Components and thought it would be neat to be able to display code snippets, but instead of static text load the content from a remote source. For example, displaying the source code for a file hosted on Github inline in a blog post. Thus prism-remote was born.

I’ve been using Kagi for a month and I haven’t missed Google for a minute. Crazy to me how it can absolutely demolish one of the world’s most powerful company’s flagship products.

Wednesday Feb. 28, 2024 7:35 p.m.

The Power of Django, HTMX and django-components

🖊️ 🔖 code django python 💬 0

In this post, I’m going to explore using Django, HTMX, django-components and a slick project layout to build the best todo app you’ve ever seen that doesn’t require React.

A minimal todo app for Waybar

🖊️ 🔖 linux 💬 0

What is the simplest TODO app imaginable? In my opinion, it’s just a text file in your home directory named todo.txt. One line per item, edited with Vim. No need for additional software, websites, or electron apps.

Using standard unix tools, this setup is easy to extend. In my case, I wanted a persistent, nagging reminder of my constant procrastination. I also use waybar. Naturally then the end goal is a custom module.

Image

Obviously, it displays the number of TODOs you have remaining. Additionally, hovering over the module will print display them in a tooltip. When you click a new Neovim instance will spawn opening the file.

Simple and effective. Here’s the code. I placed this is ~/.config/waybar/scripts/todo.sh:

#!/bin/bash
COUNT=$(wc -l < ~/todo.txt)
TODOS=$(cat ~/todo.txt | head -c -1 - | sed -z 's/\n/\\n/g')
printf '{"text": "%s", "tooltip": "%s"}\n' "$COUNT" "$TODOS"

And then add a custom module to ~/.config/waybar/config:

 "custom/todo": {
        "exec": "~/.config/waybar/scripts/todo.sh",
        "return-type": "json",
        "format": "{} todos",
        "on-click": "wezterm -e nvim ~/todo.txt",
        "interval": 5,
    }

Replace wezterm with your preferred terminal emulator and you should be good to go!

Speeding Up API Endpoints using Python AsyncIO

🖊️ 🔖 code python 💬 0

As a developer, you want the APIs you write to be as fast as possible. So what if I told you that with this one simple trick, you might be able to increase the speed of your API by 2x, 3x, or maybe even 4x? You’d probably tell me to get lost with the clickbait, but hear me out. In this article you will learn how to utilize Python asyncio, the httpx library, and the Flask micro framework to optimize certain parts of your API.

A Humble Makefile

🖊️ 🔖 code 💬 0

I’ve been adding GNU Makefiles to all my projects recently and it’s not because I’ve suddenly become a C programmer.