Tutorials

This page contains all the tutorials I have made about various topics and interests.

How to Recursively Convert Django Model to Dict

In this article we will look at how to create your own recursive serializer in Django without using the Django Rest Framework Sometimes when working with Django, we may have some data that we want to serialize (convert to JSON) but we do not have the option of using the serializers that come with Django Rest Framework. The data can also take the same form for many cases and writing a new serializer for all of those cases can be tedious and repetitive.
Read more >

How to Create Custom Permission Class in Django

Permissions can be a hustle to deal with when developing an api. Suppose we have a number of api views and endpoints where the access permissions are very similar to one another with only slight variations.. We could create different permission classes with the slight changes that fit the specific endpoint’s needs. That works, but that involves a lot of repetition and duplicated code that can be hard to update later down the line.
Read more >

Algorithms

SEARCH ALGORITHMS# Linear Search# Linear search goes over all elements and checks if it is the target element. Since the search has to go through all elements in the worst case where there the values is not there, it has a complexity of $O(n)$. // golang package search func Linear(items []int, target int) bool { for _, n := range items { if n == target { return true } } return false } Binary Search# Binary search is used to find items in an ordered list by iteratively halving the input.
Read more >

Data Structures

A data structure is a way of representing data in a program, and storing it in memory. There are many structures with their pros and cons, and uses cases. In these notes, we are going to go through some of them and look at how they function and when to use them. Static Array# Arrays are a contiguous (non-breaking) space in memory with an index for each byte of memory.
Read more >

Big-O Complexity Notation

Big O complexity notation is used to give a general idea of the performance of an algorithm in terms of resources such as time or memory as the input grows larger. It is not a measure of true performance and is only a guide. The differences between the various algorithms are only seen on really large inputs. The notation uses the syntax $O(v)$ where $v$ is an expression of complexity. d
Read more >