Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anumber8
anumber8 / chatgpt-api-in-java.md
Created June 22, 2023 21:57 — forked from gantoin/chatgpt-api-in-java.md
🤖 How to use ChatGPT API in your Java application?

🤖 How to use ChatGPT API in your Java application?

tags: chatgpt, java, api

Hi guys 👋 I'm sure you enjoy using chat GPT to produce, optimise, or translate code from any programming language to Java.

Today I'll show you how to use OpenAI ChatGPT API with Java, it's pretty easy.

1. Register for an API key

@anumber8
anumber8 / EncryptionUtil.java
Created February 17, 2023 13:34 — forked from cxubrix/EncryptionUtil.java
Simple encrypt/decrypt util for url parameters
package lv.org.substance.crypt
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
@anumber8
anumber8 / KeycloakAdminClientExample.java
Created December 6, 2022 17:24 — forked from thomasdarimont/KeycloakAdminClientExample.java
Using Keycloak Admin Client to create user with roles (Realm and Client level)
package demo.plain;
import org.keycloak.OAuth2Constants;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.ClientRepresentation;
@anumber8
anumber8 / docker-compose.yml
Created October 13, 2022 07:27 — forked from rmoff/docker-compose.yml
Multi-node Kafka cluster (three brokers)
---
version: '3.8'
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:5.5.1
ports:
- '32181:32181'
environment:
ZOOKEEPER_CLIENT_PORT: 32181
ZOOKEEPER_TICK_TIME: 2000
@anumber8
anumber8 / keycloak.ts
Created October 10, 2021 11:19 — forked from alvistar/keycloak.ts
Nuxtjs Logout Fix for Keycloak
import Oauth2Scheme from '@nuxtjs/auth-next/dist/schemes/oauth2'
import { encodeQuery } from '@nuxtjs/auth-next/dist/utils'
export default class KeycloakScheme extends Oauth2Scheme {
logout () {
if (this.options.endpoints.logout) {
const opts = {
client_id: this.options.clientId,
post_logout_redirect_uri: this._logoutRedirectURI
}
@anumber8
anumber8 / nginxproxy.md
Created September 30, 2020 08:26 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@anumber8
anumber8 / mdb2postgres.sh
Created September 24, 2020 18:18 — forked from mutolisp/mdb2postgres.sh
Convert Microsoft Access *.mdb file into PostgreSQL database
#!/usr/bin/env bash
# install mdbtools first!
# mdbtools: https://github.com/brianb/mdbtools
# ref: https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL
DBMS=postgres
for MDB in `ls | grep .mdb$`
@anumber8
anumber8 / wildfly-9.0.2.Final-standalone-full-ha.cli
Created August 19, 2020 16:50 — forked from cheinema/wildfly-9.0.2.Final-standalone-full-ha.cli
WildFly CLI scripts to build the default configurations
embed-server --server-config=custom-full-ha.xml --empty-config --remove-existing
# Extensions first
batch
/extension=org.jboss.as.clustering.infinispan:add
/extension=org.jboss.as.clustering.jgroups:add
/extension=org.jboss.as.connector:add
/extension=org.jboss.as.deployment-scanner:add
/extension=org.jboss.as.ee:add
/extension=org.jboss.as.ejb3:add
/extension=org.jboss.as.jaxrs:add
@anumber8
anumber8 / script.sh
Created May 19, 2020 14:36 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@anumber8
anumber8 / localhost-ssl.sh
Created February 8, 2020 05:00 — forked from jonsamp/localhost-ssl.sh
Create https key and cert on localhost
cd ~/
mkdir .localhost-ssl
sudo openssl genrsa -out ~/.localhost-ssl/localhost.key 2048
sudo openssl req -new -x509 -key ~/.localhost-ssl/localhost.key -out ~/.localhost-ssl/localhost.crt -days 3650 -subj /CN=localhost
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.localhost-ssl/localhost.crt
npm install -g http-server
echo "
function https-server() {