This file contains hidden or 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
import json | |
import socket | |
def parse_http_request(request): | |
headers, _, body = request.partition("\r\n\r\n") | |
request_line = headers.splitlines()[0] | |
method, path, _ = request_line.split() | |
return method, path, headers, body | |
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
This file contains hidden or 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
version: '3' | |
services: | |
zookeeper: | |
# image: confluentinc/cp-zookeeper:latest | |
image: bitnami/zookeeper:3.9 | |
container_name: zookeeper | |
ports: | |
- "2181:2181" | |
environment: | |
ALLOW_ANONYMOUS_LOGIN: 1 |
This file contains hidden or 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
# gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app --max-requests 100 --max-requests-jitter 10 --threads 5 | |
# .......................................................................................... | |
import asyncio | |
import os | |
import logging | |
# from asyncio.log import logger | |
from time import sleep |
This file contains hidden or 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
permission issues: | |
> ls -l /var/run/docker.sock | |
> sudo chmod 666 /var/run/docker.sock | |
Create a Docker Image: (assuming you already have Dockerfile in ur folder) | |
> docker build -t <my-image-name> . | |
RUN ......................................... | |
Run a built created image |
This file contains hidden or 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
what is the time duration of SSE for keep-alive connection ? | |
The time duration of an SSE (Server-Sent Events) keep-alive connection can vary depending on several factors, including: | |
Server configuration: The server can specify a keep-alive timeout using the Keep-Alive header or other configuration settings. | |
Client configuration: The client can also specify a keep-alive timeout using the Keep-Alive header or other configuration settings. | |
Network conditions: Network conditions, such as latency and packet loss, can affect the keep-alive timeout. | |
Typically, the keep-alive timeout for SSE connections ranges from a few seconds to several minutes. Here are some common values: | |
Default timeout: 30 seconds to 1 minute | |
Typical timeout: 1-5 minutes | |
Maximum timeout: 30 minutes to 1 hour |
This file contains hidden or 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
from enum import Enum | |
class Xyz(Enum): | |
"""Xyz._member_map_.values()""" | |
A = 100 | |
B = 200 | |
# Key: Pair of Enums | |
map = Xyz._member_map_ |
This file contains hidden or 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
Vite is a fast and efficient WebD build tool to build and serve web apps | |
1. instant server start and fast code reloading make development a breeze. | |
2. PROD builds are optimized for performance, resulting in smaller bundle sizes and faster load times. | |
3. not work seamlessly with older browsers. | |
4. Hot Module Replacement (HMR) is a feature that allows developers to update and reload individual modules (e.g., JavaScript files) without requiring a full page reload. | |
This enables a faster and more efficient development experience. | |
Install Node (Linux) |
This file contains hidden or 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 com.example.DemoApp.service; | |
import com.example.DemoApp.Dtos.BirdDTO; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.JsonMappingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.modelmapper.ModelMapper; | |
import org.springframework.web.util.UriComponentsBuilder; | |
import java.util.*; |
This file contains hidden or 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
import time | |
from functools import wraps | |
def timed_cache(expiration): | |
cache = {} | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args): | |
now = time.time() |
This file contains hidden or 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
from db_connector import SQLHelper | |
import pandas as pd | |
chunk_size = 20 # Number of rows in chunks | |
chunks = [] | |
file_name = 'customers-100.csv' | |
for chunk in pd.read_csv(file_name, chunksize=chunk_size, delimiter=","): | |
df: pd.DataFrame = chunk |
NewerOlder