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 / deployment.yml
Last active October 29, 2024 10:04
Worker file for digital ocean
name: Build and Push Docker Image
on:
push:
branches:
- master # Specify the branches that should trigger the workflow
jobs:
build-and-push:
runs-on: ubuntu-latest
@sagar290
sagar290 / BaseDto.php
Last active July 27, 2024 13:46
DTO Transformer for php
<?php
namespace App\DTO;
use App\Interfaces\ActionServiceDTOInterface;
use Illuminate\Support\Str;
class BaseDto
{
public function __construct(?array $data = null)
@sagar290
sagar290 / wordpress-complete-config.yaml
Last active June 24, 2024 19:15
Deploy WordPress easily in Kubernetes with this wordpress-complete-config.yaml. It includes configurations for WordPress, MySQL. kubectl apply -f wordpress-complete-config.yaml.
# Add secret
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
data:
MYSQL_ROOT_PASSWORD: bXlwYXNzd29yZAo=
@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:
@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;