Skip to content

Instantly share code, notes, and snippets.

View NjengaFelix's full-sized avatar
🎯
Focusing

Felix Njenga NjengaFelix

🎯
Focusing
  • FelsTech
  • Nairobi, Kenya
View GitHub Profile
@NjengaFelix
NjengaFelix / create-java-keystore.txt
Last active April 11, 2024 09:04
Creating a java keystore given a certificate and private key
# creating a java keystore given a certificate and private key
# A java keystore can be created by importing a pkcs12 keystore into a new java keystore
# step 1: create a pkcs12 keystore
# certificate.crt - type in your actual certificate file name
# (if its in a different location type in the location - /path/to/certificate.crt)
# privatekey.key - type in your privatekey
@NjengaFelix
NjengaFelix / application.properties
Created August 17, 2023 12:52
Postgres spring boot connection properties
#spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://localhost:5432/database_name
spring.datasource.username=username
spring.datasource.password=password
#jpa
spring.jpa.hibernate.ddl-auto = update
#logs
@NjengaFelix
NjengaFelix / countries.sql
Created August 7, 2023 09:01 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@NjengaFelix
NjengaFelix / kind.txt
Created May 27, 2023 10:13
How to use kind kubernetes
#create a cluster
kind create cluster --name prod1
#cluster info
kubectl cluster-info --context kind-prod1
#delete cluster
kind delete cluster --name prod1
@NjengaFelix
NjengaFelix / nginx_reverse_proxy.txt
Created May 25, 2023 10:47
How to setup a nginx reverse proxy for an application secured in SSL
#cd into nginx config directory
cd /etc/nginx/conf.d
#create a config file for your application
nano myapp.conf
#Paste the configuration
server {
listen 443 ssl;
#server name refers to your domain name
@NjengaFelix
NjengaFelix / extract_private-key.txt
Created May 25, 2023 10:39
How to extract a private key from a java keystore
#First save the key in a p.12 file
#The p.12 file is password protected it shall prompt you to key in a new password
#You shall require to also key in the keystore password
keytool -v -importkeystore -srckeystore /path/to/keystore.jks -srcalias <alias> -destkeystore /path/to/output.p12 -deststoretype PKCS12
#Use openssl to store the private-key in a .pem file
openssl pkcs12 -in /path/to/output.p12 -out /path/to/private-key.pem -nodes
@NjengaFelix
NjengaFelix / java_linux_service.txt
Last active May 24, 2023 12:07
How to create a service for a Java application in Linux
cd /etc/systemd/system/
#create a service file, in my case I am creating myapp.service
sudo nano myapp.service
#Contents of the file
[Unit]
Description=Manage myapp java service
@NjengaFelix
NjengaFelix / keytool.txt
Created May 23, 2023 11:19
How to generate keystore, generate a CSR and import certificate using keytool
#Note the commands below should be run on the server that hosts the application or website
# Create a keystore with an entry of a privatekeyentry
#replace <keystore.jks> with a keystore name (i.e., opencalenderkeystore.jks) and alias with a alias for your key (i.e., opencalender.com)
keytool -genkeypair -keystore <keystore.jks> -alias <alias> -keyalg RSA -validity 365 -keysize 2048
#first and last name - I recommend using the domain name (opencalender.com)
#OU - IT or Software Dev or Deployment
#Check the privatekeyentry and its alias
keytool -list -v -keystore <keystore>