Skip to content

Instantly share code, notes, and snippets.

View jKh98's full-sized avatar

Jihad Al Khurfan jKh98

View GitHub Profile

Gitflow

Gitflow workflow is a branching model for git developed by Vincent Driessen in 2010 and became the most popular branching workflow out there. This workflow aims to manage large projects by defining a strict branching model to facilitate the project development and release .
Gitflow is based on two main branches master and develop and other supporting branches. It defines specific roles to different branches and specifies how and when these branches should interact.

Git-flow Extension (Optional)

Gitflow by itself is a work pattern which does not nee any extra tools besides regular Git commands. However, there are some tools that help facilitate the use of Gitflow and enforce naming and branching conventions - one of which is the Gitflow Extension

  • On OSX systems, execute brew install git-flow
@jKh98
jKh98 / array_static_methods_example.js
Last active February 7, 2022 17:48
Static methods
// New array
Array.of("🍏", "🍌", "πŸ’"); // ["🍏", "🍌", "πŸ’"]
Array(3).fill("⭐️"); // ["⭐️", "⭐️", "⭐️"]
// From array-like object
Array.from("hello"); // ["h", "e", "l", "l", "o"]
// From iterable
Array.from([1, 2, 3], (x) => x * 2); // [2, 4, 6]
@jKh98
jKh98 / redux_toolkit_axios_async_error_handing.ts
Last active December 12, 2021 19:27
Redux-toolkit return original response error value when using asyncThunks
const myApiRequest = createAsyncThunk(
"sliceName/myApiRequestStatus",
async ( _, { rejectWithValue }: any) => {
try {
// make api call
const response = await axios.get(myUrl);
// It is important to return response data
// since response alone is not serializable
return response.data;
@jKh98
jKh98 / react_inactivity_detect.tsx
Last active December 12, 2021 19:28
React detect inactivity
import React from "react";
import { useIdleTimer } from "react-idle-timer";
//...
const timeoutMinutes = 3;
export function App() {
const handleOnIdle = () => {
// If user is authenticated and inactive, log them out
@jKh98
jKh98 / rn_inactivity_detect.tsx
Last active December 12, 2021 19:28
React-Native detect inactivity
import React, { useEffect, useRef } from 'react';
import { View } from 'react-native';
import { setSessionLocked } from 'path/to/sessionHandler';
//...
const timeoutSeconds = 10;
export function App() {
@jKh98
jKh98 / interceptors.ts
Created March 6, 2021 09:06
Here are two axios interceptors that can be used in any JS frontend application (React, React-Native ,etc..) to authorize requests and handle unauthorized responses.
// Include this file in your app entry (App.ts, index.ts ...)
// These interceptors will trigger with the default axios export and not with custom axios instances,
// as custom instances need their own interceptors
import axios from 'axios';
// Local file imports
...
import { COMMON_HEADERS } from 'path/to/headers/config'
import { PRIVATE_KEY } from 'path/to/env'
import { generateSignature } from 'path/to/signature'