Navigation Menu

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 / 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 / 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 / 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>
@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 / 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 / steps.md
Last active June 15, 2018 22:05
Hosting Websphere Liberty behind a proxy server (apache) under a subdomain

/opt/wlp/usr/servers/defaultServer/server.xml:

...

<keyStore id="defaultKeyStore"
       type="JKS" password="{xor}Lz4sLB80OiZmZmY=" 
       pollingRate="5s" 
       updateTrigger="polled" />

...

@Eng-Fouad
Eng-Fouad / steps.md
Last active August 25, 2017 12:58
Importing Let's Encrypt SSL certificates into Websphere Liberty server
  1. After creating the server (i.e. /opt/wlp/bin/server create), create the security directory:
cd /opt/wlp/usr/servers/defaultServer/
mkdir resources
mkdir resources/security
  1. Export your certificates into pkcs12 keystore (replace fouad.io with appropriate parameter):
sudo openssl pkcs12 -export -out key.p12 -in /etc/letsencrypt/live/fouad.io/fullchain.pem -name default -inkey /etc/letsencrypt/live/fouad.io/privkey.pem -password pass:123456