Simple HTTP server from scratch in C
Features:
- Serves static files (HTML, images, etc.)
- Content-type detection
- Basic error handling (404, 403)
Only ~200 lines of code.
@realpastaya@kennethnym That's a runtime check, typescript only ensures a contract is met during compile time but there's no way to know the data passed is actually of a specific type especially for software that depend on external inputs.
Every time I write login, I do one small thing on line 122 that looks completely pointless.
If the email isn't in the database, I still run a bcrypt compare against a dummy hash before I return. Why would you hash a password for a user that doesn't exist?
Because of timing. If you return early the moment the user is missing, that path is fast. The path where the user does exist is slow, because bcrypt is slow on purpose. An attacker times your responses and now knows which emails are registered. That's user enumeration.
So I make both paths cost about the same. User exists or not, the response comes back in roughly the same time. Nothing leaks.
Small detail, big difference. Detailed video on this coming soon, stay tuned.
Often I feel like I’m out of sync with the rest of the world.
I don’t watch World Cup.
I haven’t participated in $SPCX IPO.
I haven’t tried Fable.
Anyway, is time to lock in and solve some LeetCode in C++
@TrisH0x2A Yeah, libs like libc(glibc) are already so highly optimized it doesn't make any sense to rewrite in another language so they just call C under the hood. For interpreted languages, most of them don't just call C, they are built fully with C.
Two things I’d spend the rest of next week adding into my project
Elasticsearch:
→ replacing ILIKE queries with proper full text search
→ fuzzy matching ("jolof" finds "Jollof Rice") → filter by price, dietary, allergens at search level
Mocking tests:
→ mock interfaces for DB, Redis, Paystack
→ test every service method in isolation
→ no real database needed to run tests
solved my first binary tree problem today after learning about trees by reading grokking algorithms and watching a youtube video, took me a few submissions to get it right
Chess has hundreds of millions of players.
OTB chess still doesn't have a great social app.
My co-founders and I are building it.
We're looking for a strong full-stack engineer
Send:
• LinkedIn/CV
• Chess level/experience
• Salary range
Contact details in 🧵