Coderbook

How to Inject New Docker Tag into Docker Compose File

If you follow best practices then you’re tagging each of your Docker images with a unique tag or version whenever it gets updated. These tags might be the git commit hash, a CI/CD Build number or any other value that is usually generated automatically during your build process.

You might be running your containers using Docker Compose and a docker-compose.yml file, or maybe you’re running things in AWS Elastic Beanstalk with a Dockerrun.aws.json file. No matter... Read more

Best Practices for Setting Up Celery with Django

Asynchronous Celery tasks can be a great solution to many problems that you might encounter when you’re building a Django application. It allows you to move the processing of long running tasks to the background, and continue serving the visitor their HTTP request without having to wait for the long running task to finish.

For example, a few months ago I was working on a project where we had a step by step wizard where we collected a lot of... Read more

How to use Celery for Scheduled Tasks and Cronjobs

A very common, reoccurring thing that developers want to create is a feature that occurs over and over again on a certain schedule. This could be things like emailing out notifications at certain intervals, clearing some data from the database, deleting log files on the system or maybe just prepare data by conducting some heavy task in the middle of the night so it can be consumed in the morning by the users.

Whatever it is, the common thing between... Read more

How to Send Celery Messages to Remote Worker

When you’re setting up a distributed system where there are multiple different applications and services that communicate with each other, you can choose to handle this communication in a few different ways.

One of the ways you can communicate between services while keeping them decoupled is by sending messages to Message Queues that other services pickup and execute. For example, imagine we have a web application that allow the user to upload videos. To optimize the delivery and performance of... Read more

How to Create a Hash Table From Scratch in Python

A Hash Table is one of the core data structures that you need to have a good understanding of as a Software Engineer. Unlike some other data structures that are rarely used in real life situations, Hash Tables are used all the time.

For example, by using a dictionary in Python like data['key'] = 1 you are actually using a hash table. The way Python handles it in the background is hashing that key that you used and... Read more

How to Store Django Static and Media Files on S3 in Production

Storing your static or media files on a remote storage in the cloud such as Amazon Web Services S3 or DigitalOcean Spaces is one of the first things that I recommend you to do when you setup a new Django project that is ready to go into production.

Storing your media files on a remote storage instead of together with your application on your web server give you a lot of great benefits such as:

How to add LDAP & Active Directory Authentication to Django

You know that you’re working for an Enterprise business when you’re asked to integrate their website’s authentication with their Active Directory server. If you have no idea what Active Directory is, don’t worry it probably just means that you’re living within the StartUp bubble of web development!

Active Directory is Microsoft’s enterprise solution for storing user data. Many enterprises use it as a centralized location of all their employees data where they can easily update passwords, information and permissions from... Read more

How to use The 12 Factor App Methodology in Practice

How do you build an application that is easy to deploy to the cloud, easy to scale, secure and a breeze to work with as a developer? It’s a question that should be in our heads for every new project we work on, since we should always aspire to produce high quality work that can take a business to the next level.

Wouldn’t it be amazing if there was a methodology out there with strict chapters or guidelines and you... Read more

How to Add Social Authentication to Django

No matter what type of website your building these days, if you require some kind of authentication there is probably some kind of service or social network out there that would be a good fit for you and your application and that you could leverage for authentication and registration.

Are you building a gaming website? Why not authenticate with Blizzard’s Battle.net. Are you building an application with a technology target group? Maybe you can allow authentication with their GitHub account?... Read more

How to replicate PostgreSQL Database as Master/Slave

Most websites out there perform fine by simply having a web server instance and a database server instance, but if you are one of the lucky few who manage to get real traction to your business and start attracting serious number of visitors, you’ll quite quickly run into your first bottleneck, your database.

Of course every application is different and might have different needs and because of this, there might be other things within your specific application that you need... Read more