Skip to content

Instantly share code, notes, and snippets.

View AravindaM's full-sized avatar
🏠
Working from home

Aravinda Liyanage AravindaM

🏠
Working from home
View GitHub Profile
@AravindaM
AravindaM / Dockerfile
Created July 19, 2022 07:47 — forked from kaysush/Dockerfile
remote debug enabled dockerfile
FROM openjdk:8
WORKDIR /app
ENV JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
COPY remote-debugging-1.0-SNAPSHOT.jar remote-debugging.jar
ENTRYPOINT ["java", "-cp", "remote-debugging.jar", "com.kaysush.App"]
@AravindaM
AravindaM / FilterEntryFromJavaStream.md
Last active June 30, 2022 16:43
[Java snippet - 1 ] Filter an entry from a stream .flatMap vs .mapMulti in java

How to filter an entry from a stream in Java

1. Using .flatmap

List<Integer> numbers = listOfStrings.stream()
        .flatMap(s -> {
            try {
                return Stream.of(Integer.parseInt(s));
 } catch (Exception e) {
@AravindaM
AravindaM / ParseRSAKeys.java
Created March 16, 2021 05:33 — forked from destan/ParseRSAKeys.java
Parse RSA public and private key pair from string in Java
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@AravindaM
AravindaM / native-mem-tracking.md
Created August 18, 2020 14:36 — forked from prasanthj/native-mem-tracking.md
Native memory tracking in JVM

Enable native memory tracking in JVM by specifying the following flag

-XX:NativeMemoryTracking=detail

Know the <PID> of the java process

jps

To print ps based RSS

ps -p <PID> -o pcpu,rss,size,vsize

To print native memory tracking summary

@AravindaM
AravindaM / node-mtls-auth.md
Last active September 17, 2019 10:32 — forked from pcan/README.md
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Prepare certificates

Generate a Certificate Authority:

openssl req -new -x509 -days 9999 -keyout ca-key.pem -out ca-crt.pem
@AravindaM
AravindaM / osxCmd.sh
Created June 7, 2019 07:11
Linux/ossx commands
#Get osx process listining on port 8081
lsof -i tcp:8081
@AravindaM
AravindaM / AddCustomHealthIndicato.java
Created August 31, 2018 07:52
Add custom health indicator to spring boot actuators
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;
@Component
public class AddCustomHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) {
@AravindaM
AravindaM / private_fork.md
Created August 28, 2018 07:28 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@AravindaM
AravindaM / sysctl.conf
Created May 21, 2018 08:14 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@AravindaM
AravindaM / Http2client.java
Last active January 8, 2018 04:16
Sample Http2 Client - Java 9
import jdk.incubator.http.HttpClient;
import jdk.incubator.http.HttpRequest;
import jdk.incubator.http.HttpResponse;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class Http2client {