Skip to content

Instantly share code, notes, and snippets.

View MohammedALREAI's full-sized avatar
😉
I may be slow to respond.

Mohammed Al-Reai MohammedALREAI

😉
I may be slow to respond.
View GitHub Profile
import { jsPDF as JsPDF } from "jspdf";
import 'jspdf-autotable';
import * as XLSX from 'xlsx';
const handleDownloadpdf = useCallback(() => {
const selectedRows = [];
dataFiltered.forEach((row) => {
if (selected.includes(row.id)) {
selectedRows.push(row);
}
});
@MohammedALREAI
MohammedALREAI / paginator.ts
Created January 19, 2023 16:48
paginator with Gentaick
import { Expose } from "class-transformer";
import { SelectQueryBuilder } from "typeorm";
export interface PaginateOptions {
limit: number;
currentPage: number;
total?: boolean;
}
export class PaginationResult<T> {
@MohammedALREAI
MohammedALREAI / file-deculter-swigger.ts
Created January 5, 2023 09:42
ApiFiles swigger multer
import { ApiBody } from '@nestjs/swagger';
interface IApiFileSwigger {
files: Array < { name: string, description: string, required: boolean }>;
}
export const ApiFiles = ({files}: IApiFileSwigger): MethodDecorator => (
target:any, propertyKey : string | symbol,
export enum HttpStatus {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
EARLYHINTS = 103,
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
@MohammedALREAI
MohammedALREAI / looger.ts
Created May 26, 2022 09:12
CustomLooger
import fs from 'fs';
import config from 'config';
import path from 'path';
import winston, {
createLogger,
LoggerOptions,
transports,
format
} from 'winston';
import winstonDaily from 'winston-daily-rotate-file';
class NodeClass{
value:number = 0;
left:NodeClass|null = null;
right:NodeClass|null = null;
constructor()
{
this.value = 0;
this.left = null;
this.right = null;
@MohammedALREAI
MohammedALREAI / sortedSquares.ts
Created April 17, 2022 08:22
leetcode 977. Squares of a Sorted Array
function sortedSquares(nums: number[]): number[] {
let result = Array(nums.length).fill(0)
let p1 = 0
let p2 = nums.length - 1
let position = p2
while (p1 <= p2) {
let smaller=nums[p1]
let laege=nums[p2]
if( Math.abs(smaller)>Math.abs(laege)){
@MohammedALREAI
MohammedALREAI / formik.tsx
Created December 2, 2021 07:09
formik example
import React from 'react'
import { useSelector } from 'react-redux'
import { Link } from 'react-router-dom'
// material-ui
import { makeStyles } from '@material-ui/core/styles'
import {
Box,
Button,
Checkbox,
@MohammedALREAI
MohammedALREAI / permutation.js
Created November 24, 2021 12:34
HackerRnak permutation soluation
var result = []
function permutation(arr, currentSize) {
if (currentSize == 1) {
result.push(arr.join(""));
return;
}
for (let i = 0; i < currentSize; i++){
permutation(arr, currentSize - 1);
@MohammedALREAI
MohammedALREAI / firebaseAuth.tsx
Created October 7, 2021 11:52
firebaseAuth with Context
/* eslint-disable @typescript-eslint/no-empty-function */
import React, { createContext, useEffect, useReducer } from 'react'
// third-party
import firebase from 'firebase/app'
import 'firebase/auth'
// action - state management
import { FIREBASE_STATE_CHANGED } from '../store/actions'