RSSAmplifier

Blog

Fredrb's Blog

Recent content on Fredrb's Blog

blog.fredrb.comRSS feed ↗22 posts

Latest posts

Lipstick on a Pig

This post was written at 2am by a sleep-deprived human 
 
 Lipstick on a pig 
 As humans, we have evolved to be very good at orienting ourselves in nature. A landscape, with mountains, rivers, and valleys is natural and we have a good memory for geographical references. And the same thing also happens with code - or so says Robert C. Martin. Therefore, our natural instinct is to…

Fun with Futex: building my own mutex in C for funtex

Fun with Futex 
 Implementing an optimized lock in Linux requires some Operating System help. You can only get so far by doing everything in user-land. We are going to take a look how one can implement a simple spin lock in C (just like the spin lock in Go I implemented a while back) and then a slightly more elaborate lock using operating system’s primitives. The idea behind a mutex…

Solving the same problem multiple times

Solving the same problem 
 I have gotten into the habit of solving the same problem multiple times. Whenever I start working on a new feature or fixing a bug, I revert my code until I write a solution that I’m happy with. 
 The first code is always a draft. My mental model is similar to writing a text. The first pass will rarely get published. Each section gets many rewrites.…

On bash one-liners: unmaintained go.mod dependencies

Bash one liners 
 I have a graveyard of one-time-use bash one-liners that become either aliases or get wrapped by shell functions in my .zshrc file. I often justify the effort of polishing them and adding to my dotfiles with the excuse that they will be used again in the future. Even if they are never used again, they serve as a library of examples. For every new command, there is always an…

On sound programming: Playing a single note with SDL2

Playing a single note with SDL2 
 I have successfully avoided sound programming for all my programming life. Even when I tried making games, sound was always an afterthought. However, recently I got a new pair of headphones, and wondered: “what makes sound good?”, or “how much of the quality can be improved by hardware?”, and even “what is the structure of a sound…

A case for Go code generation: testify

A case for Go code generation: testify 
 Discussion(s): lobste.rs 
 
 If you’ve been using Go for a while, you’re probably familiar with the testing library stretchr/testify . It makes it easy to write tests and provides several assertion functions, such as Equal , Contains , Greater , and many more . 
 Assertion functions behaves differently depending on the scope. For example,…

Concurrency in Go: simple lock implementation

Simple lock implementation 
 This is a simple sync.Locker implementation in Go for learning purposes. This is not a lock to be used seriously. 
 
 I’ve been reading about concurrent programming, and I’m going to walk through some examples I found in the book The Art of Multiprocess Programming on lock implementations that helped me understand the inner workings of locks.…

Concurrency in Go: shared memory

Concurrency in Go: shared memory 
 I’ve been playing around with some examples to better understand how Go’s memory model behaves on concurrent programs. I’m going to try and explain what I’ve learned regarding operation ordering on multi-core CPUs. 
 The example I’m going to show is an extension of the Message Passing example written by Russ Cox in his…

Character encoding and UTF-8

Character encoding and UTF-8 
 Here are some quick facts I learned about character encoding, ASCII and UTF-8: 
 
 You need to know the encoding of any text, otherwise it’s impossible to decipher the message (although it’s common for applications to assume the encoding). 
 ASCII standard character set uses 7 bits only ( 0x00:0x7F range). This allows for 128 character only. 
 The…

Investigating man-db internals

Investigating man-db internals 
 From time-to-time I get nerd-snipped into understanding the internals of some system, library or any technology I use. This time, man was the target. I’ve discovered that man-db uses a DB (maybe that’s why there is DB in the name?) to index command names to some metadata, allowing quicker lookups on whatis and apropos commands. 
 Technically,…

Writing a Hash Table in Go

Writing a Hash Table in Go 
 Inspired by the recent post from Ben Hoyt , a recent refresher of Computer Science fundamentals and my journey on learning the Go programming language, I’ve implemented a hash table in Go. 
 Hash Table is a great data structure, they are to Balanced Trees what linear time sorting is to comparison sorts. By not relying on the comparison model, they allow…

Tiny Python Docker Images

Tiny Python Docker Images 
 I was looking for a way to create a very small docker image for a Python project. The python project I created is a Telegram bot quizzes me in German. The python-telegram-bot pip package requires gcc to fully build- so using alpine image did not do the trick for me. I searched online, found a few example bot none that would actually do what I needed with a…

Rediscovering Roguelike Games

Rediscovering Roguelike Games 
 I’m not a hobbyist Game Designers. Perhaps I was on that path ten years ago when my friend and I had an idea for the next World of Warcraft and we would put it to practice. We hadn’t, and we didn’t. The passion for building something of my own is still there though. Maybe different, less grandiose and more reasonable. What keeps pulling me back to Game…

Microservices and Object Oriented Programming

Microservices and Object Oriented Programming 
 Sam Newman defines in his book Building Microservices (2015) that there are two key traits that make a good service in a Microservice Design: (1) Loose Coupling and (2) High Cohesion . These two traits have been previously raised in the context of Object-Oriented Design by authors such as Robert C. Martin, Martin Fowler and Sandi Metz. But what…

Optimizing ZSH on WSL

I have recently switched my machine at work from Linux to Window (for many reasons that are beyond this post). And to keep using some of the tools I’m familiar with, I turned to WSL (Windows Subsystem for Linux). It is reasonably good for the most part ¹ . One thing that was not so good, was the initialization time of zsh , which was taking roughly 20s when opening on WSL. I have used zprof…

Subscription Model, Metrics, Monitoring and Software-as-a-Service

Today I’m going to ramble about Metrics, Monitoring, SaaS (Software-as-a-Service) and the Subscription Business Model. Topics I’ve been reading and discussing about for the last few weeks. The topic that calls for special attention is the Subscription Business Model. This model has been affecting our industry drastically, specially if we look around from a consumer perspective the idea…

Automating this Blog

I haven’t really written much for this blog. But one thing that really gets to me every time I write a post is the way I publish it. When I first created this site, it wasn’t for the blogging itself, it was more the experience of hosting my own website. I was going to put the first blog post on GitHub pages but I ended up creating my own website infrastructure.

Node Versioning - A lightweight version manager for Node

Skip to the final result: GitHub Repository 
 JavaScript and the NodeJS ecosystem have never been my favorite technologies in a stack, but I have managed fine in the last four years of professional and personal projects. With the growing need to manage application releases and parallel projects using Node, the lack of version manager such as Ruby’s rvm was indisputable. I was alone back…

Ruby Monkey-Patch and Design Decisions

Ruby is a wonderful language. Despite the type wars between static and dynamic (typing/checking) or that some say it might be dying (which I don’t agree with), I just find Ruby a great language to learn. Its readable and has features that hooked me from the start. I never used it on a big project or anything professionally. But I learned enough of it to send some pull requests to Ruby…

Understanding /proc

Understanding /proc 
 Last week I created a small ps clone in ruby.
This was done purely out of curiosity, just wondering how does ps works and how it knows all about current running processes. You can find the project here . 
 Cool things I learned in the process: 
 
 procfs is a virtual filesystem that stores process data! 
 ps clone is merely file reading (really). 
…

(untitled)

Resume 
 I’m a Software Engineer and Computer Science Graduate excited to explore and develop new technologies.
I thrive on tackling complex problems and working on them with my peers. Believer on the practice of writing
better code rather than more code and occasional contributor to Open Source. 
 Programming Languages I’m comfortable with: Go, Python, Java, Rust, Bash and…

(untitled)

Personal Projects 
 
 Hash Table implementation : implemented a Hash Table in Go while revisiting
some CS concepts (Reviewed by Ben Hoyt ) 
 Game Boy Emulator : recently took a huge interest in Emulator Development. This project
is my second attempt at trying to create an emulator for the Game Boy familiy of consoles. This one is developed in Rust, and a huge part of…