Skip to content

Instantly share code, notes, and snippets.

View Eng-Fouad's full-sized avatar

Fouad Almalki Eng-Fouad

View GitHub Profile
@Eng-Fouad
Eng-Fouad / ssl-certs.md
Last active January 17, 2024 17:22
Generate self-signed PKCS#12 SSL certificate and export its keys using Java keytool and openssl.

Steps to generate self-signed PKCS#12 SSL certificate and export its keys:

1- Create PKCS#12 keystore (.p12 or .pfx file)

keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass MY_PASSWORD -alias KEYSTORE_ENTRY -keyalg RSA -keysize 2048 -validity 99999 -dname "CN=My SSL Certificate, OU=My Team, O=My Company, L=My City, ST=My State, C=SA" -ext san=dns:mydomain.com,dns:localhost,ip:127.0.0.1
  • myKeystore.p12 = keystore filename. It can with .pfx extension as well.
  • MY_PASSWORD = password used for the keystore and the private key as well.
  • CN = commonName, it will be shown as certiciate name in certificates list.
  • OU = organizationUnit, department name for example.
@Eng-Fouad
Eng-Fouad / UserDao.java
Last active December 29, 2023 20:38
Using JDBI in Quarkus (native mode) [JDBI 3.38.2]
package io.fouad.demo.db;
public interface UserDao {
@SqlUpdate("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR)")
void createTable();
@SqlUpdate("INSERT INTO user(id, name) VALUES (?, ?)")
void insertPositional(int id, String name);
@SqlUpdate("INSERT INTO user(id, name) VALUES (:id, :name)")
@Eng-Fouad
Eng-Fouad / SampleMingw.kt
Created July 9, 2019 22:38
Kotlin Native Win32 GUI Sample
package sample
import kotlinx.cinterop.*
import platform.windows.*
@ExperimentalUnsignedTypes
fun WndProc(hwnd: HWND?, msg: UINT, wParam: WPARAM, lParam: LPARAM) : LRESULT
{
// This switch block differentiates between the message type that could have been received. If you want to
// handle a specific type of message in your application, just define it in this block.
@Eng-Fouad
Eng-Fouad / java.md
Created August 29, 2017 01:33
Generating ECPrivateKey and ECPublicKey

Generate keys:

KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
kpg.initialize(new ECGenParameterSpec("secp521r1"), new SecureRandom());
KeyPair keyPair = kpg.generateKeyPair();
ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();
ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
byte[] privateKeyS = privateKey.getS().toByteArray();
byte[] publicKeyX = publicKey.getW().getAffineX().toByteArray();

byte[] publicKeyY = publicKey.getW().getAffineY().toByteArray();

@Eng-Fouad
Eng-Fouad / Dockerfile
Last active August 28, 2023 03:24
Spring Boot Native with Mandrel
# Based on RedHat OS
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8-1037
# Variables
ARG JAVA_VERSION=20
ARG MANDREL_VERSION=23.0.1.2-Final
ARG MANDREL_ARCH=amd64
ARG MANDREL_FILE_NAME=mandrel-java$JAVA_VERSION-linux-$MANDREL_ARCH-$MANDREL_VERSION.tar.gz
ARG MANDREL_URL=https://github.com/MANDREL/mandrel/releases/download/mandrel-$MANDREL_VERSION/$MANDREL_FILE_NAME
@Eng-Fouad
Eng-Fouad / db-versioning-strategy.md
Last active January 12, 2023 23:46
Database Versioning Strategy

SQL Folder Structure Example:

./src/main/sql
|___ deprecated/
|              |___ postgres/
|                           |___ v2/
|                                  |___ ddl.sql (contains CREATE TABLE statements)
|                                  |___ dml.sql (contains INSERT INTO statements)
|                                  |___ test-data.sql (contains INSERT INTO statements)

|___ latest/

@Eng-Fouad
Eng-Fouad / javafx-combo-box-auto-completion.md
Last active June 15, 2020 02:49
JavaFX 8 ComboBox with Auto-Completion Support
@Eng-Fouad
Eng-Fouad / website.css
Created May 16, 2017 18:25
GitBook RTL Theme
@import url(//fonts.googleapis.com/earlyaccess/notonaskharabic.css);
@import url(//fonts.googleapis.com/earlyaccess/notokufiarabic.css);
body, html {
overflow-x: hidden;
font-family: "Noto Naskh Arabic", "Helvetica Neue", Helvetica, Arial, sans-serif;
direction: rtl;
}
.book.font-family-0 {
@Eng-Fouad
Eng-Fouad / Dockerfile
Created February 16, 2019 11:40
Dockerfile Example
FROM ubuntu:18.10
# install latest updates
RUN apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get autoclean -y
# install unzip & wget
RUN apt-get install -y unzip wget
# install OpenJDK JRE
RUN apt-get install -y openjdk-11-jre
@Eng-Fouad
Eng-Fouad / server.xml
Created August 3, 2018 13:23
typical wlp server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>transportSecurity-1.0</feature>
<feature>jaxrs-2.1</feature>
<feature>jpa-2.2</feature>
<feature>cdi-2.0</feature>
</featureManager>