Skip to content

Instantly share code, notes, and snippets.

View sagar290's full-sized avatar
🏠
Working from home

Sagar sagar290

🏠
Working from home
View GitHub Profile
@sagar290
sagar290 / api-gateway-docker-compose.yml
Created February 23, 2024 21:22
api-gateway-docker-compose.yml
version: '3.8'
services:
app:
image: nginx
volumes:
- "./docker/nginx/sites/:/etc/nginx/conf.d"
ports:
- "80:80"
networks:
@sagar290
sagar290 / api-gateway.local.conf
Created February 23, 2024 18:07
api-gateway.local
upstream authUpstream {
server auth:9090 max_fails=0 fail_timeout=10s;
keepalive 512;
}
upstream service1Upstream {
server services1:9091 max_fails=0 fail_timeout=10s;
keepalive 512;
}
# for select duplicate
SELECT * FROM `lb` t1, `users` t2 WHERE t1.user_id = t2.id AND t2.dff_stm = 1 ;
# for delete duplicate
DELETE t1 FROM `lb` t1, `users` t2 WHERE t1.user_id > t2.id AND t2.dff_stm = 1
@sagar290
sagar290 / docker-compose.yml
Created November 24, 2023 13:41
mysql, schema_design, db_postgres
version: '3.1'
services:
db_mysql:
image: mysql
command:
- --default-authentication-plugin=caching_sha2_password
restart: always
environment:
import redis
source = redis.Redis(host='localhost', port=63790, db=1)
#destination = redis.Redis(host='localhost', port=63790, db=5)
keys = source.keys('auth-service:*')
print("key,vallue,ttl")
for key in keys:
#destination.set(key, source.get(key), source.ttl(key))
@sagar290
sagar290 / console.sql
Last active September 17, 2023 16:30
Resetting Auto-Incrementing IDs in PostgreSQL
DO
$$
DECLARE
rec RECORD;
lastId INT;
BEGIN
FOR rec IN (SELECT table_name
FROM information_schema.tables
WHERE table_schema = (SELECT current_schema())
AND table_type = 'BASE TABLE')
function power(base, exponent) {
let result = 1;
for (let i = 0; i < Math.floor(exponent); i++) {
result *= base;
}
if (exponent % 1 !== 0) {
result *= base ** (exponent % 1);
}
return result;
}
function sqrt(number) {
if (number < 0) {
throw new Error("Square root of a negative number is undefined");
}
let guess = number / 2;
const precision = 0.0001; // Adjust the precision as needed
while (Math.abs(guess * guess - number) > precision) {
guess = (guess + number / guess) / 2;
invoice_id id product_id price paid_ammount
INV000001 1 40 450 450
INV000002 2 50 5000 5000
INV000003 3 200 400 400
id product_id price paid_ammount
1 40 450 450
2 50 5000 5000
3 200 400 400