Skip to content

Instantly share code, notes, and snippets.

@hardyscc
hardyscc / postgres-db-init.sql
Created November 11, 2024 09:31
Postgres Database Initialization
--Create user xxx_dba
create user xxx_dba with encrypted password 'Dba12345';
--Create app user
create user xxx_user with encrypted password 'User12345';
--Create xxx database (db owner = xxx_dba)
create database xxx with owner xxx_dba;
--Change db to xxx without change user
@hardyscc
hardyscc / HostnameFromIp.md
Last active August 12, 2024 14:50
HostnameFromIp.java
echo "import java.net.InetAddress; \
public class HostnameFromIp { \
    public static void main(String[] args) throws Exception { \
        var startTime = System.currentTimeMillis(); \
        System.out.println(InetAddress.getByName(args[0]).getHostName() + \
                \" - \" + (System.currentTimeMillis() - startTime) + \"ms\"); \
    } \
}" > HostnameFromIp.java
@hardyscc
hardyscc / get-java-opts-proxy
Last active July 24, 2024 09:06
get-java-opts-proxy
#!/bin/sh
# Usage: export JAVA_TOOL_OPTIONS=`get-java-opts-proxy`
local_http_proxy=${HTTP_PROXY:-$http_proxy}
if [ -n "$local_http_proxy" ] ; then
if [ $? -eq 0 ]; then # If variable has username and password, its parse method different
http_proxy_host=$(echo $local_http_proxy | sed 's/http:\/\/.*@\(.*\):.*/\1/')
http_proxy_port=$(echo $local_http_proxy | sed 's/http:\/\/.*@.*:\(.*\)/\1/' | tr -d "/")
@hardyscc
hardyscc / podman-on-wins.md
Last active June 18, 2024 07:09
Podman on Windows

Podman on Windows

Prerequisite

  1. Windows Subsystem for Linux

    • First ensure Windows Subsystem for Linux has been installed under System > Optional features > More Windows features.
  2. OpenSSH

@hardyscc
hardyscc / win11-setup.md
Last active June 12, 2024 03:01
Windows 11 setup

Windows 11 Setup

Recommended Packages

winget install chrisant996.Clink

winget install Git.Git
winget install GitHub.cli
@hardyscc
hardyscc / spring-boot-stored-proc.md
Created May 21, 2024 04:43
Stored Procedure on Spring Boot

Stored Procedure on Spring Boot

Executing stored procedures in Spring Boot using the @Procedure annotation provides a convenient way to interact with database procedures. By annotating a method with @Procedure and specifying the procedure name, you can easily call stored procedures, pass parameters, and handle result sets, simplifying the integration of stored procedures in your Spring Boot application.

Demostrations

Convert JPA Specification to Stored Procedure

Selected Function to Convert

@hardyscc
hardyscc / docker-on-windows.md
Last active November 2, 2023 04:20
Docker on Windows

Docker on Windows

Ubuntu on WSL

First make sure uninstall all of the old Ubuntu installation under App & Features.

Install Windows Subsystem for Linux under App & Features > Optional features > More Windows features, then

wsl --update
@hardyscc
hardyscc / docker-on-mac.md
Created September 18, 2023 03:57
Docker on Mac

Docker on mac

Colima

brew install colima

Add insecure registry

@hardyscc
hardyscc / CipherHelper.java
Created September 15, 2023 06:24
RSA & AES encryption
package com.example.cipher;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyStore;

Self-hosted Sonarqube

Start Docker Instance

docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:9-community

Generate Token