Skip to content

Instantly share code, notes, and snippets.

View amulyakashyap09's full-sized avatar
🎯
Focusing

Amulya Kashyap amulyakashyap09

🎯
Focusing
  • Greater Noida
View GitHub Profile
@amulyakashyap09
amulyakashyap09 / mongo_elastic_stream.js
Created August 20, 2022 15:15
MongoDb To Elastic-Search Sync using Nodejs Stream.
const {
MongoClient, ObjectId
} = require("mongodb");
const {
Client
} = require('@elastic/elasticsearch');
const Transform = require("stream").Transform;
const defaultElasticSettings = {
@amulyakashyap09
amulyakashyap09 / elastic_search_query.md
Last active March 14, 2024 10:57
How to query in elastic-search

Terminologies

We will be using following information throughout this article:

  • index_name : customers
  • index_type : personal
  • customer will have name,age,gender,email,phone,address,city,state as fields in schema for now

INFO Queries

@amulyakashyap09
amulyakashyap09 / download.js
Created April 8, 2019 06:20
Pipe download stream directly to s3 upload using nodejs streams
const http = require('http'),
stream = require('stream'),
AWS = require('aws-sdk'),
http = require('http');
const uploadStream = ({ Bucket, Key }) => {
const s3 = new AWS.S3();
const pass = new stream.PassThrough();
return {
writeStream: pass,
@amulyakashyap09
amulyakashyap09 / thoughtWorksAssignment.js
Created September 1, 2018 13:50
Thought works assignment without using any 3rd party npm modules.
const http = require('http');
const fs = require('fs');
const path = require('path');
const https = require("https");
const querystring = require('querystring');
const td = new Date("2018-09-01")
const config = {
"userId" : "HhjEtD0rD",
"endpoints" : {
@amulyakashyap09
amulyakashyap09 / ultimate-ut-cheat-sheet.md
Created August 15, 2018 14:28 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@amulyakashyap09
amulyakashyap09 / marut_vs_devil.js
Created August 11, 2018 17:52
marut_vs_devil problem
function main(input) {
//Enter your code here
inputs=input.split("\n");
var t=parseInt(inputs[0]);
var i=1;
var j;
while(t--)
{
@amulyakashyap09
amulyakashyap09 / micro_block_game.js
Created August 11, 2018 17:27
micro_block_game
function main(input) {
var inputs=input.split(" ");
function comp(a,b){
console.log("a, b : ", a, b)
var ab=a.concat(b);
var ba=b.concat(a);
console.log("ab, ba : ", ab, ba)
@amulyakashyap09
amulyakashyap09 / linkedList.go
Created August 11, 2018 12:17
Linked List operations in golang
package main
import (
"fmt"
"errors"
)
type Node struct {
value int32
next *Node
@amulyakashyap09
amulyakashyap09 / Maximization_Knapsack_Greedy_Approach.go
Created July 10, 2018 08:02
maximization knapsack solution using Go (Greedy Approach)
package main
import (
"fmt"
"errors"
)
func getMax(arr []int) int {
var max int = 0
@amulyakashyap09
amulyakashyap09 / has_cycle_linked_list.py
Created April 30, 2018 11:04
Check whether linked lists has cycle or not!
def has_cycle(head):
if head is None:
return False
begin = end = head
while (begin or end or end.next):
if end.next is None:
return False