• How to generate an error stack trace in Go 🥞

    A common problem that many people (including me) have faced when programming in Go, is to pin point the source of an error. Other programming languages provide you with a stack trace to tell you where the error came from, but Go does not have this behavior by default.

    In this article, we will discuss how to use the fmt, and the github.com/pkg/errors libraries to give us better error reporting.


    Read more...

  • Session based authentication in Go 📂

    When a user signs in to your application, their authorization has to be persisted across all other routes. In simpler words, this means that you have to know who is calling your HTTP server.

    One way to do this is to store the users “session”. A session is started once a user logs in, and expires some time after that. Each logged in user has some reference to the session, which they send with their requests. We then use this reference to look up the user that it belongs to and return information specific to them.

    banner


    Read more...

  • Password authentication and storage in Go (Golang) 🔑

    Any application that involves password storage and authentication has to make sure that its passwords are safely stored. You cannot simply store the username and password of your users the way you store other types of data. In fact, it should be impossible for you to actually know the password of any of your users.

    This post will go through how to securely store your users password by building a very simple web application in Go, and using a Postgres database to store your users credentials.


    Read more...

  • Data races in Go(Golang) and how to fix them 🏃‍♀️

    Go is known for how easy it is to build concurrent programs in it. But, with all this concurrency, comes the possibility of the dreaded data race – one of the hardest bugs to debug if you’re ever unfortunate enough to encounter it in your code.

    In this post, we will go through a sample program that causes a data race, and detect the race condition with the race detector tool. We will then look at some of the methods to get around and solve the race condition, while still keeping the core logic of our code intact.


    Read more...

  • Linear regression with Python 📈

    Linear regression is the process of fitting a linear equation to a set of sample data, in order to predict the output.

    In order to do this, we assume that the input X, and the output Y have a linear relationship.

    X and Y may or may not have a linear relationship. We just want to find the closest linear relationship between them, in order to explain the data that we observe.

    We can get a better understanding of linear regression from the following chart:

    sample plot

    The line is the linear relationship that we predicted based on the points which we observed.

    If you want to get a brief recap of the theory behind linear regression, you can see my notes here

    In order to perform linear regression with python, we will need to:

    1. Generate the sample data, and divide it into training and testing data.
    2. Create a linear regression model
    3. Fit our model using the training data
    4. Test our model using the testing data

    Read more...

  • Understanding Tensorflow - your first program

    Tensorflow is a machine learning library released by Google, which is now one of the most popular machine learning libraries currently in use. While the name “Tensorflow” might seem intimidating, it’s actually a really neat library that can be used for many things outside of machine learning as well.

    In fact, there will be no further mention of machine learning in this post, since we are only going to learn about the basics of the Tensorflow library. Once, you understand how the library works, it’s application in AI and machine learning will come naturally.


    Read more...

  • How to install and run Kafka on your machine 🌪

    Apache Kafka is a distributed streaming platform. It can be used for anything ranging from a distributed message broker to a platform for processing data streams.

    Anyone approaching Kafka for the first time may find it intimidating, with the vast amount of documentation present. This post is written to help you get your hands dirty and run a distributed Kafka cluster on your system with the least effort.


    Read more...

  • Parsing JSON in Golang ⏩

    There’s always a bit of friction when it comes to making JSON work with statically types programming language. One one hand, JSON data can be anything from a simple number, to a complex array of embedded objects. Working with a language like Go means you have to make the variable structure of JSON fit into structured variables.

    Fortunately, Go tries to make this process as easy for us as possible, and gives us many options to work with when we want to parse our JSON data.


    Read more...

subscribe via RSS