Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / using-javadoc-command-line.cmd
Created August 19, 2020 22:31
Example on how to use javadoc in jdk8
zulu8.44.0.11-ca-jdk8.0.242-win_x64\bin>javadoc.exe -quiet -d destination -sourcepath quarkus\extensions\panache\hibernate-orm-panache\runtime\src\main\java\ io.quarkus.hibernate.orm.panache
@tivrfoa
tivrfoa / Async1.java
Created August 25, 2020 13:46
Java Async with callback
import java.util.concurrent.*;
/**
* A good tutorial can be found here:
* @see <a href="https://www.baeldung.com/java-completablefuture">
* https://www.baeldung.com/java-completablefuture</a>
*/
class Async1 {
static String f1(String result) {
@tivrfoa
tivrfoa / java-async-rest-response.java
Created August 27, 2020 13:23
Java AsyncResponse CompletableFuture supplyAsync
package org;
import java.util.concurrent.*;
import java.util.*;
import java.net.URI;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
@tivrfoa
tivrfoa / basic-maven-pom-junit-5-jupiter-java-11.xml
Created September 1, 2020 14:50
Simple maven pom.xml using JUnit 5 Jupiter and Java 11
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lsc.tests</groupId>
<artifactId>min-maven-pom</artifactId>
<version>1</version>
@tivrfoa
tivrfoa / DumpLoadedClassList.sh
Last active September 10, 2020 13:52
Application CDS
// Generate the app classes list
java -XX:DumpLoadedClassList=classes.cds -jar myApp.jar
// Generate the shared archive
java -Xshare:dump -XX:SharedClassListFile=classes.cds -XX:SharedArchiveFile=app-cds.jsa --class-path myApp.jar
// and use it
java -XX:SharedArchiveFile=app-cds.jsa -jar myApp.jar
@tivrfoa
tivrfoa / perf42.sh
Created September 10, 2020 15:38
perf monitoring
$type perf42
perf42 is aliased to `sudo env "PATH=/usr/local/sbin:/usr/local/bin" perf stat -e cpu-clock -r42`
@tivrfoa
tivrfoa / postgresql-docker.sh
Created September 13, 2020 18:41
Running PostgreSQL on Docker
# Want to start a PostgreSQL server on the side with Docker?
docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \
--name postgres-quarkus-hibernate -e POSTGRES_USER=hibernate \
-e POSTGRES_PASSWORD=hibernate -e POSTGRES_DB=hibernate_db \
-p 5432:5432 postgres:10.5
# then you can use the client: pgadmin3 connecting to localhost:5432
@tivrfoa
tivrfoa / strtok-test.c
Last active September 14, 2020 01:24
String tokenizer in C - strtok
#include <string.h>
#include <stdio.h>
int main() {
printf("%s", "/home/username/projects2/p2.geany\n");
char path[100] = "/home/username/projects2/p2.geany";
@tivrfoa
tivrfoa / ends-with.c
Created September 14, 2020 01:42
Checking if a string ends with another string in C
#include <string.h>
#include <stdio.h>
int main() {
printf("%s", "/home/username/projects2/p2.geany\n");
char path[100] = "/home/username/projects2/p2.geany";
@tivrfoa
tivrfoa / ImmutableList.java
Last active September 22, 2020 00:49
Attempt to create an immutable list in Java
/*
IT DOES NOT WORK
there was a bug in the code ...
It was returning to early from isEverythingFinal and so
not checking all fields.
For example, it does not work for String: