Skip to content

Instantly share code, notes, and snippets.

Avatar

Mohamed Ahmed Abd-elmagid aim97

  • Benha University
View GitHub Profile
@aim97
aim97 / DrawGraph.py
Created Sep 29, 2021
Draw a graph of connected vertices
View DrawGraph.py
import numpy as np
import matplotlib.pyplot as plt
alpha = (np.sqrt(2)/2)
square_points = ((0, 0),(1, 0),(1, 1),(0, 1))
shape_points = ((1, 0),(alpha, alpha),(0, 1),(-alpha, alpha),(-1, 0),(-alpha, -alpha),(0, -1),(alpha, -alpha))
# generate {count} vertices of a graph on a circle with radius {radius}
# at equal distances from one another
def generateGraph(count:int, radius:float):
@aim97
aim97 / Authentication_notes.md
Last active Aug 7, 2021
Some authentication notes for REST APIs and node
View Authentication_notes.md

Authentication

it's synonymous to Proof of Identity.
Authorization: it defines what a person (authenticated or not) is entitled to do.

Authentication methods

HTTP Authentication Schemes (Basic & Bearer)

Basic

Send the email and password with the request in auth header encoded in base64.

@aim97
aim97 / Observer-design-pattern.md
Last active Jul 16, 2021
A collections of design patterns, small description of each along with when to use it
View Observer-design-pattern.md

Observer Design Pattern

We need it when we want multiple objects to be informed of the changes to the state of another object.
it usually appears in displays, or something like UI that needs to update when that data it displays changes.

Basic Idea

Problem: You want a set of objects Observers to be notified about the changes occuring in a specific object Observables.

solution

@aim97
aim97 / pypipe.py
Created Jan 27, 2021
Pipe in Python
View pypipe.py
# This functions simulates Ramda.pipe in javascript
# its input is a list of functions
# and its return value is a function loopOverFuns
# loopOverFuns accepts one positional argument X
# it iteratively applies the functions provided in pipe to X
# and returns the result
def pipe(functions):
def loopOverFuns(X):
for f in functions:
X = f(X)