A bit of background before we start the article. When I develop a Python web service I use the Connexion library created by Zalando. It’s a great library which is built on top of Flask. It uses an OpenAPI Specification (OAS) file to handle input validation and routing for you. Therefore reducing the boilerplate code you need to write.
The main advantage of this is that we have a design-first approach to developing our API. We fully define the OAS then develop the code/web service. This also keeps the OAS up to date, helping to mitigate the issue of the…
Recently I’ve been working on a new personal project called Banter Bus, a browser-based multiplayer game. I’ve been working on a REST API to add new questions to the game. The API is built in Golang and uses MongoDB as the database. Since Golang is a strongly typed language, we will need to specify the structure of the data we expect from the database. This can get tricky if the data varies, such as one field changing.
One issue I encountered was each game type has to have its questions. These questions will be asked to the users playing the…
In this article, we will go over what the yield
keyword is used for. We will also cover how you can use a yield
with a pytest fixture to allow us to clean up data after our tests.
Before we can look at the yield
keyword we will need to cover iterables and generators in Python. An "iterable" is any Python object that can return its members one at a time, in a for-loop.
In Python we have functions called magic methods, there are methods like __enter__
and __exit__
defined within objects. These are called "magic" methods because they are…
A lot of people, I included, are using Gatsby to build their own blogs. One of the things I wanted to add to my blog was a table of contents (ToC) 📝. A ToC will show you all the headings of an article and when you click on a heading it’ll take you directly to that heading. It’s a nice little feature to have on your blog, which makes it easier for users to navigate and find the information they are looking for.
https://www.youtube.com/watch?v=YrUeiD4YO5E
So before we get started you can find the source code here. …
In this article, we will briefly go over what DNS (domain name system) is and explain how it is used in conjunction with Docker 🐳.
You can think of DNS like a phonebook, except instead of people’s name and phone numbers, it stores domains names and IP addresses (this can be either IPv4 or IPv6). Where a domain name is used to identify resources i.e. google.com
is a domain name. This is how DNS works:
google.com: 8.8.8.8
cloudflare.com: 1.1.1.1
You can manually send a DNS request (and get a response) using the dig
command. …
In this article, we will go over how you use proxychains
to proxy our traffic through a socks proxy.
Recently like everyone else, I’ve been working from home a lot more often. This means to access resources at work I need to use a VPN. However, to access some resources, such as production servers from my local machine, I need to use a SOCKS5 proxy. Without using a SOCKS proxy, I would need to do something shown in the diagram below.
In this article, we will go over how you can manage your markdown blog posts from another git repository (repo). Separate to the git repository for your Gatsby site. This is the same process that I use to manage this repo.
So what this entails is the source code for my Gatsby site is in a repo called portfolio-site
on Gitlab. Then I have another repo for all of the blog posts (in markdown) called articles
. …
In this article, we will look at how we can add an “edit post” button, to your Gatsby blog. When this button is clicked it will take the user to your markdown file, on github/gitlab that was used to generate the blog post they are currently viewing.
Before we add the edit button to a Gatsby blog, let’s set up a simple Gatsby site using the Gatsby blog starter
. You can skip this step and add the button to an existing site.
npm -g install gatsby-cli
gatsby new my-blog-starter https://github.com/gatsbyjs/gatsby-starter-blog
If you don’t use the start above, you will…
In this article, we will go over how we can use the gitlab-auto-mr
CLI script I wrote to help automate your Gitlab workflow. This is a very simple script you can use with Gitlab which will auto-create merge requests (MRs) every time you create a new branch on a project in Gitlab.
Feel free to skip this section if you are already familar with feature branch, skip to the
Gitlab Auto MR
section
Before I introduce what the script does and how we use it, let’s go over why you might need to use it. Say you’re working on a…
Let’s take a look at how we can add offline local search 🔍 to a Gatsby blog. There are two main types of search we can use an offline search like elasticlunr
and external API search engines like ElasticSearch
. These are typically more scalable but also more expensive.
You can find more info here.
In this article, I will show you how to add offline search to your Gatsby blog using elasticlunr
. This means your website needs to be indexed locally and will increase the bundle size as this index needs to be loaded by the client but with the…
Software Engineer | Pythonista | Typescripter | Docker Advocate | https://haseebmajid.dev