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 FuseScrollbars from '@fuse/core/FuseScrollbars';
import Avatar from '@material-ui/core/Avatar';
import Icon from '@material-ui/core/Icon';
import Paper from '@material-ui/core/Paper';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import clsx from 'clsx';
import moment from 'moment/moment';
import React, { useEffect, useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
function numberSigningSums(num:number =5555531):any{
let arr=[...String(num)].map(x=>Number(x))
if(arr.length<2){
return arr[0]
}
let sum=0
for(let i=0;i<arr.length;i+=2){
@MohammedALREAI
MohammedALREAI / insert.ts
Created April 19, 2021 20:50
57. Insert Interval
function insert(intervals: number[][], newInterval: number[]): number[][] {
let i = 0;
while (i < intervals.length) {
const [a, b] = intervals[i];
const [c, d] = newInterval;
if (
(a >= c && a <= d) ||
(b >= c && b <= d) ||
(c >= a && c <= b) ||
function arrayReplace(inputArray: number[], elemToReplace: number, substitutionElem: number): number[] {
let arr:number[]=[]
let count=inputArray.filter(x=>x===elemToReplace).length
if(count<1){
return inputArray
}
for(let i=0;i<inputArray.length ;i++){
@MohammedALREAI
MohammedALREAI / sortedSquares.ts
Created April 5, 2021 23:44
977. Squares of a Sorted Array
function sortedSquares(nums: number[]=[-4,-5,0,1,2]): number[] {
let left =0
let right=nums.length-1;
let arr= new Array(nums.length).fill(0)
for(let i=0;i<nums.length;i++){
if(Math.abs (nums[left])>Math.abs (nums[right])){
arr[i]=nums[left]*nums[left] ;
left++
import { mergeTypes, mergeResolvers } from "merge-graphql-schemas";
import * as path from "path";
import * as fs from "fs";
import { makeExecutableSchema } from "graphql-tools";
import * as glob from "glob";
export const useSchema = () => {
const pathToModules = path.join(__dirname);
const graphqlTypes = glob
// .eslint.js=>
module.exports = {
parser: '@typescript-eslint/parser',
overrides: [
{
files: ['*.ts', '*.tsx'], // Your TypeScript files extension
parserOptions: {
project: ['./tsconfig.json'], // Specify it only for TypeScript files
},
}
@MohammedALREAI
MohammedALREAI / Swigeer.ts
Created April 1, 2021 10:18
swiger setup and make in the controller
import { INestApplication } from '@nestjs/common';
import { DocumentBuilder, OpenAPIObject, SwaggerModule } from '@nestjs/swagger';
import { SWAGGER_CONFIG } from './swagger.config';
export function createDocument(app: INestApplication): OpenAPIObject {
const builder = new DocumentBuilder()
.setTitle(SWAGGER_CONFIG.title)
.setDescription(SWAGGER_CONFIG.description)
function isOdd(l=3,r=9){
let arr=[]
for(;l<=r;l++){
if(l%2===0){
continue;
}
arr.push(l)
}
return arr.map(item=>item)
@MohammedALREAI
MohammedALREAI / areFollowingPatterns.ts
Created March 16, 2021 21:57
areFollowingPatterns in the codesignal
function areFollowingPatterns(strings: string[], patterns: string[]): boolean {
for (let i: number = 0; i < strings.length; i++) {
if (patterns.indexOf(patterns[i]) !== strings.indexOf(strings[i])) return false;
}
return true;
}
or
function areFollowingPatterns(strings: string[], patterns: string[]): boolean {