Handle CORS errors in gorilla websockets

TLD(W)R; // Allow everyone var upgrader = websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, } // Allow a specific domain var upgrader = websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { origin := r.Header.Get("Origin") return origin == "https://your.domain.com" }, } ...

December 11, 2024 · 4 min

Building a light weight clone of One million checkboxes

I first found out about the One million checkboxes website from a video on Prime’s youtube channel. I’ll admit that’s how I find about a lot of tech news these days. Ever since I found out about it I wanted to build it. I have recently started working on Go and wanted to build it directly in go instead of starting with python and then moving to go. While building this I learned two important things ...

December 4, 2024 · 10 min

Getting Started with Parcel.js and TypeScript

I have been looking for a simple way to use typescript in my html projects for some time now. There is Webpack, but it needs a lot of configuration for even the simplest of things. There is always the option to use React or Angular, but that is too much for something quick. Then there is Parcel.js Parcel.js is a fast, zero-config web application bundler that makes setting up a development environment a breeze. It comes with built-in support for TypeScript, which can be integrated into HTML with minimal hassle. Whether you’re building a simple project or something more complex, Parcel makes it easy to get up and running. In this article, we’ll explore how to use Parcel.js to set up a project with TypeScript, structure your project for scalability, and prepare it for deployment. ...

December 3, 2024 · 8 min

Adding React to an HTML Website using Parcel

I recently had to use react-window in a project. I did not want to use a full fledged framework for such a small task. I was looking for a way to add a few React components to an HTML page. My search ended at Parcel In this guide, we’ll walk through how to set up a simple React app using Parcel, a fast and zero-config bundler. Let’s jump in! ...

December 2, 2024 · 3 min
Chris Ensey, Unsplash

Understanding Endianness with Go

Byte order is crucial when working with low-level data, and messing it up can lead to bugs that are difficult to track down. It doesn’t matter whether you’re working on a network protocol, reading binary data, or doing something fancy with hardware; understanding how data is represented in memory (and how it travels) is essential. But before we dive into the byte order mess, let’s get familiar with some key concepts. You’re gonna need these as you start looking at endianness (yes, it’s a real word). ...

November 28, 2024 · 6 min
Rob, Unsplash

[WIP] 1BRC: 1 Billion row challenge in Go!

The one billion row challenge has taken the world by a storm. Today we are going to see what is the reason behind this storm… Ok. Enough with the theatrics. I recently came across the 1 billion row challenge through a video on Primeagen. And instantly I wanted to try it out myself. I really liked the iterative approach taken by the author of the original article. I have recently started working on Go and I thought this would be a good way to get my hands dirty. ...

September 25, 2024 · 3 min
Mike Winkler, Unsplash

Understanding Ports, Sockets, WebSockets, and File Descriptors

If you’ve ever peeked under the hood of a web server, you’ve probably heard terms like ports, sockets, WebSockets, and file descriptors. They sound like a cocktail of tech jargon that could confuse even the best of us. But don’t worry—by the end of this article, you’ll understand what these things are and how they fit together like puzzle pieces in the world of networking and operating systems. What’s a Port, Anyway? Think of your computer as an apartment building. Inside, you’ve got a bunch of people (programs) living in their respective rooms. A port is like the apartment number on each door. It helps incoming traffic (data) know which program to knock on. ...

September 24, 2024 · 4 min

A Quick Intro To The Raft Consensus Algorithm

A cruicual aspect of distributed systems is to have a clear consensus on who is the current leader. Consensus algorithms help us in determining a leader and provide us with the constitution for what happens when the leader inevitably goes down. Enter Raft, the algorithm that promises to make consensus more understandable. While its popular peer Paxos has an air of mystique, Raft is the algorithm that rolls up its sleeves and says, “Let’s make this easy to follow.” ...

September 13, 2024 · 6 min

String formatting in Go!

fmt.Printf is like the Swiss Army knife of Go when it comes to string formatting. Whether you’re debugging, logging, or trying to impress your peers with some beautifully formatted output, fmt.Printf has your back. So, let’s dive into some of the most commonly used formatting verbs and flags in Go’s fmt package. The Basic Placeholders Here’s the bread and butter of fmt.Printf—the simple formatting verbs: %v: Prints the value in a default format. It’s like the wild card of formatting. ...

September 12, 2024 · 3 min

Go's Lesser-Known Control Mechanisms - defer, panic, and recover

Go is a wonderfully simple language—until it isn’t. Sure, you’ve got your basic if, for, switch, and even goto (although, let’s be honest, no one likes to admit using it). But when you dig deeper, Go offers some extra gems that make it stand out: defer, panic, and recover. These three can seem like the “mystery meat” of Go, but once you understand how they work, they’re not only powerful but also fun to use (with a few “gotchas” along the way). Let’s dive in. ...

September 9, 2024 · 4 min