Skip to content

Instantly share code, notes, and snippets.

View MHJahanbakhsh's full-sized avatar
💭
I may be slow to respond.

MohammadHossein Jahanbakhsh MHJahanbakhsh

💭
I may be slow to respond.
  • iran
View GitHub Profile

Overview

This document outlines the approaches and considerations for integrating RFC 9457 (error response handling) into our application. The aim is to handle network error responses appropriately while enhancing user experience. Specifically, this design covers the handling of Retry-After headers for specific status codes (429 and 503) and 301 redirect responses with URLs.

Additionally, RFC 9457 also aims to convey more descriptive error messages to both users and developers, ensuring clarity and improved troubleshooting capabilities.


@MHJahanbakhsh
MHJahanbakhsh / myscript.sh
Created September 22, 2023 14:00 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@MHJahanbakhsh
MHJahanbakhsh / ssh.md
Created May 8, 2023 18:19 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh [email protected]

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

Why we cannot use React hooks in conditional statements? How React hooks work internally?

becuase in order for react to work properly, on each render, each hook should be called with the same order that it was called before.That’s what allows React to correctly preserve the state of Hooks between multiple calls.
for each hook in a react component there is an Object called "memory cell". When we call a Hook like useState(), it reads the current cell (or initializes it during the first render), and then moves the pointer to the next one. This is how multiple useState() calls each get independent local state.
under the hood hooks are implemented like a LinkedList where each one represents a node having reference to the next one.

//good approach
useState(1)
useState(2)
useState(3)
useState(4)
@MHJahanbakhsh
MHJahanbakhsh / js_linked_list.js
Created October 6, 2022 15:41 — forked from bradtraversy/js_linked_list.js
JS Linked List Class
// Construct Single Node
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}
// Create/Get/Remove Nodes From Linked List
class LinkedList {
@MHJahanbakhsh
MHJahanbakhsh / css-media-queries-cheat-sheet.css
Created September 18, 2022 08:44 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@MHJahanbakhsh
MHJahanbakhsh / koa-server.md
Last active November 21, 2022 21:44 — forked from kevinwucodes/koa-server.md
understanding koajs middleware architecture stack order

Notes

Portfolio: https://mhj-portfolio-nextjs.herokuapp.com/

Koa middleware cascade in a more traditional way as you may be used to with similar tools - this was previously difficult to make user friendly with node's use of callbacks. However with async functions we can achieve "true" middleware. Contrasting Connect's implementation which simply passes control through series of functions until one returns, Koa invoke "downstream", then control flows back "upstream".

The following example responds with "Hello World", however first the request flows through the x-response-time and logging middleware to mark when the request started, then continue to yield control through the response middleware. When a middleware invokes next() the function suspends and passes control to the next middleware defined. After there are no more middleware to execute downstream, the stack will unwind and each middleware is resumed to perform its upstream behaviour.

@MHJahanbakhsh
MHJahanbakhsh / sample.md
Last active August 31, 2022 06:54 — forked from bradtraversy/sample.md
Markdown Cheat Sheet

how to have a newline in markdown: before hit enter key,press two spaces

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6