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
@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)
// .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
},
}
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
@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++
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 / 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 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){
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';
@MohammedALREAI
MohammedALREAI / calcalater.ts
Created May 30, 2021 13:56
simple calcalater in ts
type Operation="+"|"-"|"*"|"/"
function calcalater(a:Array<number>=[1,2,3],b:Array<number>=[5,2,3],operation:Operation='-'){
let len=a.length>=b.length?a.length:b.length
let res:Array<number>=[]
for(let i=0;i<len;i++){
let first
let secand
if(operation==='+' ||operation==="-"){
@MohammedALREAI
MohammedALREAI / simple.ts
Created June 1, 2021 16:09
JavaScript assignment 2‏
// call by value when you are used any the prmitive type like
// number ,string ,boolean ,undefined ,null like
// are always assigned/passed by
// value-copy: null, undefined, string, number, boolean, and ES6’s symbol.
// - First: Pass by value example
// some hint
// The original variable is not modified on changes in other variables.
let x=10;