Parallel vs Asynchronous: Understanding the Difference in C# (Using Bread Making)
When working with C#, developers often face two important concepts:
- Asynchronous programming (async/await) – Best for waiting on external tasks (e.g., network requests, file operations).
- Parallel programming (Parallel.ForEach) – Best for executing multiple tasks simultaneously (e.g., CPU-heavy computations).
To explain this, let’s use the example of baking bread.
Asynchronous Programming (async/await) – A Single Baker Handling Tasks Efficiently
Imagine you are baking bread alone. The process involves several steps:
- Mix the ingredients → You wait for the dough to come together.
- Proof the dough → You wait for it to rise.
- Shape the dough → You actively work on it.
- Bake the bread → You wait for it to cook.
Each step has periods of waiting. Instead of just standing around, you do other work—like washing dishes or preparing another meal—while waiting.
How Not To Send Transactional Emails
Disclaimer: this is the anti-aws guide to sending emails
The problem
You have a system and you need to send emails to your customers which happen upon certain events, for example a new user signs up and you send him a welcome email. At the same time you are using aws and to ensure the least problems you decided to use as much as much possible of what Jeff is selling. Based on that you decided to use SES (simple email service) to send your emails (far from simple if you ask me, but that’s how they market it).
Bazel: Love it or Leave it? My Short Experience
For the past two years, I’ve been using Bazel, an open-source build tool similar to Make, Maven, and Gradle. As their documentation states: “Bazel is an open-source build and test tool similar to Make, Maven, and Gradle. It uses a human-readable, high-level build language. Bazel supports projects in multiple languages and builds outputs for multiple platforms. Bazel supports large code-bases across multiple repositories, and large numbers of users.”
My experience has primarily been within a monorepo setup, managing code written in both Java and Golang. While I wouldn’t call myself a Bazel guru, I’ve become comfortable with the core functionalities:
Implementing 2FA Login With Email On AWS Cognito Using Typescript
Security has become a huge deal in today’s computing world, and one part of security is authentication, in other words proving that you are the person you say you are. For computer systems a username and passoword is enough to authenticate a user, however that has proven to be insufficient for today. That led to 2FA solutions (2 Factor Authentication) which add one more layer of security in the process of identifying a user and basically giving access to certain resource like your bank account, or your email.
How to Write Good Unit Tests
It is probable that you have encountered numerous tests, or perhaps none at all (though this scenario is hopefully uncommon). If you belong to the former group, you may have experienced the laborious process of comprehending and constructing tests, which is painful for the eyes and patience. Despite the challenges, investing effort into test creation yields considerable benefits in the long term.
Consider a scenario where you aim to enhance your codebase. Upon conducting benchmarks, you identify sluggish and opaque segments within your code. What course of action do you take? Typically, you pinpoint these pain points and proceed to refactor with the expectation of improvement. Subsequently, after a period of refinement, say, several days or weeks, you manage to enhance performance substantially, perhaps achieving a 50% boost in efficiency—an outcome worthy of commendation in practical applications. However, what follows next? You contemplate merging your feature branch into the main codebase, yet uncertainty looms: Are you certain that all functionalities operate flawlessly? Are there comprehensive tests in place to validate that the end result remains consistent? Is there assurance that unintended consequences are not introduced to other areas of the codebase or experienced by users?
Using JWT for authentication in Gin
Authentication is a crucial part of any web application. It allows us to verify the identity of users and ensure that only authorized users can access sensitive information. In this post, we will learn how to use JSON Web Tokens (JWT) for authentication in the Gin framework for Go. The Gin framework is a popular web framework for Go that makes it easy to build fast and scalable web applications. It provides a simple and elegant API that makes it easy to handle HTTP requests and responses. In this post, we will see how to use Gin and JWT to implement a simple authentication mechanism.
Quick Mock Server
Are you in a need of a quick mock server? One simple solution for Linux/Mac/BSD users
is to employ an existing tool, nc
. It exists in most distros and it’s very easy to use.
#!/bin/bash
if [ "$#" -ne "1" ]; then
echo "usage: ./mock_server.sh <port>"
exit 1
fi
trap "{ exit 0; }" SIGINT SIGTERM SIGKILL
PORT="$1"
function make_response() {
read -r response
echo -e "HTTP/1.1 200 OK\r\n\r\n${response}"
}
while true ; do
dd if=/dev/zero count=10000
make_response | nc -l "$PORT"
done
Save this in a file called mock_server.sh
and run it like this: ./mock_server.sh 8000
,
or on any port you like. After running this script you can call the server using curl
specifying any path you like.
Favourite VSCode Extensions
I’ve been using VSCode for about 3 years now, it’s not the best editor out there, but I like it. I try to keep it minimal with only a few extensions for executing certain things quickly and easily.
Here’s a list of the extensions I use:
C# - I’ve been writing C# over 5 years now, the first years I used Visual Studio, then vscode came out and I switched. On dotnet core it works quite good until it starts failing.
Learning a Musical Instrument
About 2 years ago I decided to learn a musical instrument. I have always been interested in string based instruments so I decided to learn how to play guitar. First, I tried out a friend’s guitar and then I realized that I really liked it, so I bought a cheap acoustic guitar.
My knowledge about playinng musical instruments was very limited, I knew very basic things from school most of which have faded over time.
Editors Choice
I’ve used a few editors over time, Emacs, Atom, Sublime, Vim, VSCode, IntelliJ, Visual Studio and Xcode. From those I’ve used professionally Xcode, Emacs, Visual Studio, vim, vscode and Intellij. I have tried to use atom and sublime, but they never really stack.
Here is a small review of what I like and what I don’t for each one of them. FYI my favourite 2 are vim and vscode.
Atom didn’t really click for me, I’ve met people that liked it, but I never managed to like it. Every time I used it felt slow and clunky. It was very famous in the circles of JavaScript developers, but too me it was still bad.