Skip to content

Instantly share code, notes, and snippets.

View nik-sta's full-sized avatar
👻
programmer. see also wizard, magician.

Nikola Stanković nik-sta

👻
programmer. see also wizard, magician.
View GitHub Profile
@nik-sta
nik-sta / ExampleScheduledTask.kt
Last active June 6, 2024 12:21
Non-Blocking and Asynchronous Scheduled Task in Kotlin + Ktor Client @ Spring Boot Application
package dev.niksta.nonblockinghttpskotlinspringboot
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
@nik-sta
nik-sta / pg-session-related-queries.sql
Created January 8, 2024 21:25
PostgreSQL: SQL Session Management, Queries
@nik-sta
nik-sta / build.sh
Last active January 2, 2024 10:19
Docker buildx script for multi-architecture builds. (DockerHub and GitHub Container Registry Support)
#!/bin/bash
# Docker Buildx Multi-Architecture Script
#
# Automates the creation of multi-architecture Docker images.
# Utilizes OCI Image Format Specification for metadata setup.
# Supports DockerHub and GitHub Container Registry.
#
# Author: Nikola Stanković <nikola.stankovic@viascom.email>
# Version: 1.0.0
# Created on: 01.01.2024
@nik-sta
nik-sta / shell.txt
Last active September 18, 2023 22:59
Creating a Let's Encrypt certificate
❯ lsof -i :80
❯ certbot certonly --standalone -d niksta.viascom.?
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for niksta.viascom.?
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/niksta.viascom.?/fullchain.pem
Key is saved at: /etc/letsencrypt/live/niksta.viascom.?/privkey.pem
@nik-sta
nik-sta / shell.txt
Last active September 18, 2023 22:44
Creating a self-signed certificate
❯ openssl req -newkey rsa:2048 -nodes -keyout private-key.pem -x509 -days 398 -out public-cert.pem
Generating a 2048 bit RSA private key
...................+++++
.........................................................................................................+++++
writing new private key to 'private-key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
@nik-sta
nik-sta / application.yaml
Last active September 25, 2023 19:37
application.yaml ssl security
server:
port: 8080
ssl:
bundle: "server"
enabled-protocols: TLSv1.3
spring:
ssl:
bundle:
jks:
@nik-sta
nik-sta / application-prod.yaml
Last active May 10, 2023 12:50
Graceful Shutdown
server:
shutdown: "graceful"
spring:
lifecycle:
timeout-per-shutdown-phase: "45s" # Default is 30s
@nik-sta
nik-sta / docker-run-trivy
Created April 29, 2023 22:51
Docker run Trivy
docker run \
--rm \
-v trivy-cache:/root/.cache/ \
-v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy:latest \
image viascom/alpine:3.17.3
@nik-sta
nik-sta / .bashrc
Last active May 3, 2023 08:57
.bashrc for Alpine Docker image
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias lh='ls -lh'
source /etc/profile.d/bash_completion.sh
@nik-sta
nik-sta / packages.list
Last active April 30, 2023 14:51
packages.list for alpine base image
tzdata
bash
bash-completion
curl
openssl
ca-certificates
dumb-init
jq