This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var graphqlHTTP = require('express-graphql'); | |
var { buildSchema } = require('graphql'); | |
// Construct a schema, using GraphQL schema language | |
var schema = buildSchema(` | |
type Query { | |
rollDice(numDice: Int!, numSides: Int): [Int] | |
} | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package.json | |
{ | |
"name": "flame-graph-exercise", | |
"version": "1.0.0", | |
"private": true, | |
"scripts": { | |
"start": "node --perf-basic-prof-only-functions app.js" | |
}, | |
"author": "Shubham Verma",\ | |
"dependencies": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app.js | |
const express = require('express'); | |
const console = require('console'); | |
const levenshtein = require('fast-levenshtein'); | |
var arr=[]; | |
const HOW_OBVIOUS_THE_FLAME_GRAPH_SHOULD_BE_ON_SCALE_1_TO_100 = 10; | |
const someFakeModule = (function someFakeModule () { | |
return { | |
calculateStringDistance (a, b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//makeIndex.js | |
const _ = require('highland'); | |
const fs = require('fs'); | |
const csv = require('csv-parser'); | |
const elasticsearch = require('elasticsearch'); | |
const indexName = 'demo_elastic_index'; | |
const start = async () => { | |
const client = new elasticsearch.Client({ | |
host: 'localhost:9200', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//searchData.js | |
const elasticsearch = require('elasticsearch'); | |
const indexName = 'demo_elastic_index'; | |
const query = 'Lewisham'; | |
const searchData = async () => { | |
const client = new elasticsearch.Client({ | |
host: 'localhost:9200', | |
// log: 'trace', | |
}); | |
await client.ping({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//deleteIndex.js | |
const elasticsearch = require('elasticsearch'); | |
const indexName='demo_elastic_index'; | |
const deleteIndex = async () => { | |
const client = new elasticsearch.Client({ | |
host: 'localhost:9200', | |
// log: 'trace', | |
}); | |
await client.ping({ | |
requestTimeout: 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"query": { //1 | |
"bool": { //2 | |
"must": [ | |
{ "match":{"address":"Street"}} //3 | |
], | |
"filter": [ //4 | |
{ "term":{"gender":"f"}}, //5 | |
{ "range": { "age": { "gte": 25 }}} //6 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package.json: | |
{ | |
"name": "blockchain", | |
"version": "1.0.0", | |
"description": "", | |
"main": "main.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Shubham Verma", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main.js | |
const crypto = require('crypto'); | |
class Block { | |
constructor(index, data, prevHash) { | |
this.index = index; | |
this.timestamp = Math.floor(Date.now() / 1000); | |
this.data = data; | |
this.prevHash = prevHash; | |
this.hash=this.getHash(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sample.json | |
[{ | |
"firstName":"Shubham", | |
"lastName":"Verma", | |
"email":"example@gmail.com", | |
"Mob:":1234567890, | |
"country":"India" | |
}, | |
{ | |
"firstName":"Shubham", |
OlderNewer