Skip to content

Instantly share code, notes, and snippets.

View DanishSiddiq's full-sized avatar
🎯
Focusing

DanishSiddiq

🎯
Focusing
View GitHub Profile
@DanishSiddiq
DanishSiddiq / SingleDimensionStats.csv
Last active May 30, 2018 08:11
Single Dimension Stats
Machine Mac Book Pro Hp Virtual Machine
Processor 2.2GHz Intel i7 Intel(R)Core(TM)[email protected] Intel(R)Xeon(R)CPU [email protected]
CPU Count 8 8 2
Operating System macOS Sierra Windows 10 Pro Ubuntu 16.04 LTS(xenial)
Node 10.0.1 9.6.1 8.11.2
t t t t
Classical For 16.278 134.288 34.912
For Length defined 15.44 151.212 27.813
Reverse For 15.278 132.534 28.005
Reverse While 14.757 116.211 20.628
@DanishSiddiq
DanishSiddiq / TwoDimensionalArray.csv
Last active May 30, 2018 08:10
Two Dimensional Loops Stats
Machine Mac Book Pro Hp Virtual Machine
Processor 2.2GHz Intel i7 Intel(R)Core(TM)[email protected] Intel(R)Xeon(R)CPU [email protected]
CPU Count 8 8 2
Operating System macOS Sierra Windows 10 Pro Ubuntu 16.04 LTS(xenial)
Node 10.0.1 9.6.1 8.11.2
t t t t
Classical For 113.897 293.612 184.597
For Length defined 109.186 227.223 161.769
Reverse For 106.299 497.724 179.925
Reverse While 110.679 208.435 171.540
@DanishSiddiq
DanishSiddiq / app.js
Created September 23, 2018 10:44
app.js
import http from 'http';
import morgan from 'morgan';
import express from 'express';
import bodyParser from 'body-parser';
import cluster from 'cluster';
import { setRouter } from './route';
const app = express();
let workers = [];
@DanishSiddiq
DanishSiddiq / workerCode.js
Created September 23, 2018 10:47
worker code for a long operation
export default class AsyncListController {
createList = async(req, res) => {
await this.populateHugeList();
res.json({ ProcessId: 'Worker Process Id' + process.pid });
};
/* populate list with million elements
*/
populateHugeList = async() => {
@DanishSiddiq
DanishSiddiq / index.js
Created September 23, 2018 15:14
Main Threading Code
// module included to create worker threads
const { Worker } = require('worker_threads');
// main attributes
let lst; // list will be populated from 0 to n
let index = -1; // index will be used to traverse list
let myWorker; // worker reference
let interval;
mainBody();
@DanishSiddiq
DanishSiddiq / workerThread.js
Created September 23, 2018 15:16
Worker thread code
// parentPort for registering to events from main thread
// workerData for receiving data clone
const { parentPort, workerData } = require('worker_threads');
let interval;
let index = -1;
registerForEventListening();
function registerForEventListening () {
@DanishSiddiq
DanishSiddiq / ecosystem.config.js
Last active September 29, 2018 19:19
Configuration file for setting up PM2
module.exports = {
apps : [
{
name : 'Custering',
script : 'Clustering/src/app.babel-register.js',
exec_mode : 'cluster_mode',
instances : 'max'
},
{
name : 'Clustering_Replcia',
@DanishSiddiq
DanishSiddiq / student.route.js
Last active May 11, 2020 20:50
Defining CRUD operations using GraphQL and Express route
const { Router } = require('express');
const express_graphql = require('express-graphql');
const { buildSchema } = require('graphql');
const studentController = require('./student.ctrl');
// GraphQL schema
const schema = buildSchema(`
scalar Date
, input SearchInput {
@DanishSiddiq
DanishSiddiq / student.graphql.query.json
Last active May 10, 2020 12:32
GraphQL Student Client Queries
query getStudent($studentId: String, $firstName: String) {
byId: findOne(input: {_id: $studentId}) {
...studentFields
}
byName: findOne(input: {firstName: $firstName}) {
...studentFields
}
}
mutation createStudent($firstName: String!, $lastName: String!, $registrationNumber: Int!, $email: String!) {
@DanishSiddiq
DanishSiddiq / student.graphql.variables.json
Last active May 10, 2020 18:40
GraphQL Student Query Variables
{
"studentId": "5e727fa7b9f23a1c643e671f",
"firstName": "Danish",
"lastName": "Siddiq",
"registrationNumber": 543678,
"email": "[email protected]"
}