• 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...

  • Adding a database to a Go web application 🗄

    This post will go through how to add a postgres database into your Go application.

    It is not enough to just add a driver and query the database in your code if you want to make your application production ready. There are a few things that you have to take care of:

    1. How would you write tests for your application?
    2. How will you ensure that everyone else who wants to run the application (including other servers and VMs) are using the same database structure as the one you developed?
    3. How do you most effectively make use of your computing resources?

    Read more...

  • Build a web application in Go (golang) 🕸

    Go is getting more and more popular as the go-to language to build web applications.

    This is in no small part due to its speed and application performance, as well as its portability. There are many resources on the internet to teach you how to build end to end web applications in Go, but for the most part they are either scattered in the form of isolated blog posts, or get into too much detail in the form of books.

    With this tutorial, I hope to find the middle ground and provide a single resource which describes how to make a full stack web application in Go, along with sufficient test cases.

    The only prerequisite for this tutorial is a beginner level understanding of the Go programming language.


    Read more...

  • Simulating realistic random motion : The different degrees of randomness 🎲

    Random sequences are a bunch of random numbers arranged one after the other.

    Something like this : 4, 6, 10, -6, -2, 1

    Seems straightforward right? But, what if we wanted to bring some order to these sequences, while still retaining their randomness?


    Read more...

subscribe via RSS