Skip to content

Instantly share code, notes, and snippets.

View AjayPoshak's full-sized avatar

Ajay Poshak AjayPoshak

View GitHub Profile
// This is an example of Dijkstra's algorithm. https://leetcode.com/problems/network-delay-time/
function createAdjList(edges, n) {
const adjList = new Map()
for(let i=0; i<n; i++) adjList.set(i, [])
for(let i=0; i<edges.length; i++) {
const [from, to, weight] = edges[i]
const neighbors = adjList.get(from)
neighbors.push({ node: to, weight })
adjList.set(from, neighbors)
}
@AjayPoshak
AjayPoshak / controller.ts
Created May 15, 2023 15:21
Streaming file from S3 NestJS
@Get(':hash')
@Header('Content-Type', 'image/png')
async getActiveImageByHash(
@Param('hash') hash: string,
@Res() response: Response,
): Promise<any> {
const res = await this.usersService.getActiveImageByHash(hash);
// Connect to s3
const client = new S3Client({
region: REGION,
@AjayPoshak
AjayPoshak / docker-compose.yml
Created July 6, 2024 12:01
Docker compose setup for Elasticsearch and Kibana
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.14.1
container_name: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- xpack.security.enabled=false
@AjayPoshak
AjayPoshak / docker-compose.yml
Last active June 7, 2025 17:55
logs server compose
# docker-compose.yml for log-server
services:
loki:
image: grafana/loki:2.8.0
ports:
- "3100:3100"
volumes:
- loki-data:/loki
restart: unless-stopped