Jul 15, 2020

WebLogic Debug Option

Use below JAVA_OPTIONS setting to run WebLogic Server in debug mode

JAVA_OPTIONS="-Xdebug -Djava.compiler=NONE -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=10171,suspend=n $JAVA_OPTIONS"

Oct 17, 2019

Run Docker commands without sudo

1. Add the docker group if it doesn't already exist
$ sudo groupadd docker
2. Add the connected user $USER to the docker group and chance sock permission
Optionally change the username to match your preferred user.
$ sudo gpasswd -aG $USER docker

$ sudo chmod 666 /var/run/docker.sock 

3. Restart the docker daemon

$ sudo service docker restart

Source: https://github.com/sindresorhus/guides/blob/master/docker-without-sudo.md

Apr 17, 2019

Got permission denied while trying to connect to the Docker daemon socket

bash-4.2$ docker info
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.27/info: dial unix /var/run/docker.sock: connect: permission denied

Solution: 
bash-4.2$ sudo usermod -a -G docker $USER 
 
https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/

Docker Proxy Settings

Docker Proxy Settings

$ cd /etc/systemd/system/docker.service.d
$ touch http-proxy.conf
$ sudo vi http-proxy.conf

Add below content to http-proxy.conf
[Service]
Environment="HTTP_PROXY=YourProxyURL:port"
Environment="HTTPS_PROXY=YourProxyURL:port"

Mar 15, 2019

Graph Traversal from given start node to end node

package algo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

public class GraphTraversal {
    public static void main(String[] args) {
        Map<String, List<String>> graph = new HashMap<>();
        List<String> aList = new ArrayList<String>();
        aList.add("F");
        aList.add("B");
        aList.add("C");
        graph.put("A", aList);
       
        List<String> bList = new ArrayList<String>();
        bList.add("E");
        bList.add("A");
        bList.add("D");
        graph.put("B", bList);
       
        List<String> dList = new ArrayList<String>();
        dList.add("E");
        dList.add("A");
        dList.add("Z");
        graph.put("D", dList);
       
       
       
        buildPath(graph, "A", "Z");
       
    }
    public static void buildPath(Map<String, List<String>> graph, String start, String end){
        Set<String> processedNode = new HashSet<>();
        Stack<String> stack = new Stack<>();
        processedNode.add(start);
        stack.push(start);
        processPath(graph, processedNode, stack, start, end);
    }
   
    public static void processPath(Map<String, List<String>> graph, Set<String> processedNode, Stack<String> stack, String start, String end){
        if(start.equals(end)){
            System.out.println(stack);
            return;
        }
        List<String> children = graph.get(start);
        if(children != null) {
            for(String child : children){
                if(!processedNode.contains(child)){
                    stack.push(child);
                    processPath(graph, processedNode, stack, child, end);
                }
            }
        }
        stack.pop();
    }
}




Oct 16, 2017

Aug 18, 2017

How to configure tomcat server with SSL configuration?

1. Create private key and CSR using OpenSSL

openssl genrsa -out www.mydomain.com.key 2048
openssl req -new -sha256 -key www.mydomain.com.key  -out www.mydomain.com.csr

2. Submit CSR file to your Certificate Authority to generate & share valid CA certificates.

Valid CA certificates would have following files
a.  www.mydomain.com.crt
b.  xxxxCARoot.crt
c.  xxxxTrustxxx.crt
d.  xxxxxxxCA2.crt

3. Bundle CA, CA2 and Trust certificate into single file bundle.crt

4. Generate pkcs12 file using below command and provide keystorePass as 'changeit'
>openssl pkcs12 -export -in www.mydomain.com.crt -inkey www.mydomain.com.key -out www.mydomain.com.p12 -name tomcat -CAfile bundle.crt -caname root -chain


5. Configure tomcat server.xml with below <Connector>
<Connector SSLEnabled="true" keystoreFile="conf/ssl/www.mydomain.com.p12" keystorePass="changeit" keystoreType="PKCS12" port="443" protocol="HTTP/1.1" scheme="https" secure="true" sslProtocol="TLSv1.2"/>