Introduction In this article, I would like to try implementing a code that generates a one-time password, which is often used in many two-factor authentication functions, called Time-based One-time Password (TOTP), using Go.
What is Two-Factor Authentication? Before writing the TOTP generation code, let’s briefly review what two-factor authentication is.
There are mainly three types of factors for authentication: knowledge, possession, and biometrics.
Knowledge: Something only the user knows or remembers, such as a login password.
WIP
Chapter 2 Building Blocks of TCP TCP is what provides the abstraction of a reliable network running over an unreliable channel.
TCP abstracts important parts of network such as retransmission of lost data, congestion control, data integrity, and in-order delivery
Chapter 3 Building Blocks of UDP Ref. https://hpbn.co/
What’s this article about These are my notes on a book called Designing Data-Intensive Applications.
SSTables and LSM Trees(P.76) SSTables (Sorted String Tables) are files that contain a set of arbitrary and sorted key-value pairs.
https://www.igvita.com/2012/02/06/sstable-and-log-structured-storage-leveldb/
SSTables and Log-Structured Merge Trees are still used in some database.
As a rule of thumb, LSM Trees are faster for writes but slower for reads than B-Tree indexes.
B-Trees The B-Tree is the most widely used indexing structure.
What is Dijkstra’s Algorithm Dijkstra’s Algorithm is the algorithm to find the shortest path between any two vertices in a graph.
Dijkstra’s Algorithm will find the shortest path from a given starting vertex to every other vertices in a graph.
Steps Prepare a table to have the shortest distance from a starting vertex and previous vertex.
Initialize two list of visited and unvisited nodes
Let the distance of a start vertex from the start vertex 0.
Decision Tree Summarize decision trees to decide which gcp services you should use in a certain circumstance.
Compute option GCP offers a multiple compute services.
Here is a list of those services and how customizable/managed they are.
Decision Tree
Services
Firebase When you’re a mobile or html developer and want the least amount of server-side code possible, you should choose Firebase.
Firebase provides Database, Storage, Functions/Services, and Hosting with a little code.
What is a Graph? A graph G is an ordered pair of a set V of vertices and a set of E of edges. G can be defines as follows $$G=\left(V,E\right)$$ ordered pair $$(a, b) \neq \left(b,a\right) \text{where} \ a \neq b$$ Graph terminology There are two type of graph, the one is directed graph and the other is undirected graph. Directed graphs contain ordered pairs of vertices while undirected
NoSQL database NoSQL databases are non tabular databases.
Features
Flexible schema Horizontal scaling Fast queries due to the data model Ease of use for developers Types The main types are document, key-value, wide-column, and graph.
Document databases Document databases store data in documents similar to JSON objects.
Particular elements can be indexed for faster querying.
They have the flexibility to rework their document structures as needed.
Use cases include e-commerce platforms, trading platforms, and mobile app development.
BFS Template A template in a python-ish pseudo-code for bfs from collections import deque def bfs(root, target): step = 0 # Enqueue root node in queue q = deque([root]) # Set to store visited nodes visited = set(q) while q: size = len(q) # Iterated the nodes which are already in the queue for _ in range(size): # Pop the first node in the queue curr = q.popleft if curr
Queue FIFO
package queue import "sync" type node struct { data interface{} next *node } type Queue struct { head *node tail *node count int lock *sync.Mutex } func NewQueue() *Queue { return &Queue{lock: &sync.Mutex{}} } func (q *Queue) Len() int { q.lock.Lock() defer q.lock.Unlock() return q.count } func (q *Queue) Push(data interface{}) { q.lock.Lock() defer q.lock.Unlock() ele := &node{data: data} if q.head == nil { q.head = ele q.tail = ele } else { q.
Heap Heap is a special Tree-based data structure in which tree is a complete binary tree. Heaps are basically are binary trees with more properties and specifications and there are mainly two types of heaps.
Rules
A heap must be a complete binary tree. All of the levels of the tree must be completely filled except maybe the last one. The last level has all keys as left as possible Types of heap Min Heap