Monday, March 27, 2023

ChatGPT in ESLint (I will soon lose my job, replaced by this little bastard...)



please write a ESLint rule to flag as deprecated the usage of variable names like Button.size.NORMAL


To write an ESLint rule to flag the usage of variable names like Button.size.NORMAL, you can use the following code:


module.exports = {
  rules: {
    "no-deprecated-variable-name": {
      meta: {
        deprecated: true,
        type: "problem"
      create: function(context) {
        return {
          MemberExpression(node) {
            const { object, property } = node;
            if (object.type === "Identifier" && === "Button" &&
                property.type === "MemberExpression" && === "NORMAL") {
                message: "The use of 'Button.size.NORMAL' is deprecated. Use a different value instead."

This rule creates a new ESLint rule called no-deprecated-variable-name, which checks for the usage of Button.size.NORMAL variables. When the rule encounters this variable, it reports a warning message to the user indicating that the usage of this variable is deprecated and suggests using a different value instead.

To use this rule, you will need to add it to your .eslintrc configuration file:


  "rules": {
    "no-deprecated-variable-name": "warn"

In this configuration, the rule is set to "warn", which means it will produce a warning message but will not fail the build. You can set it to "error" to make it fail the build.

Sunday, March 19, 2023

Reverse Proxy with Docker httpd container on Windows


I have followed these instructions for Windows and it works, the only change I had to do is to start the container with the  "--net=host" options, and from the container I had to configure the ReverseProxyPass to use the IP address of the host (NOT the WSL IP).

Reverse Proxy with Spring Boot 


I really like the simplicity and power of this CHARON, a Spring Boot- based Swiss knife for load balancing and request forwarding. 


Here a lot more examples  

Saturday, March 18, 2023

Reverse Proxy with nodejs
npm install http-proxy --save
node .\server.js

var http = require('http'),
    httpProxy = require('http-proxy');
// Create your proxy server and set the target in the options.

Docker container connecting to host service on Windows

docker run -d -p 80:80 --name webserver nginx
docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                NAMES
2733688156aa   nginx     "/docker-entrypoint.…"   14 seconds ago   Up 13 seconds>80/tcp   webserver

on my windows host I have a Spring Boot application running at port 10090:
netstat -an | grep 10090
  TCP              LISTENING
  TCP    [::]:10090             [::]:0                 LISTENING
  TCP    [::1]:53110            [::1]:10090            TIME_WAIT
  TCP    [::1]:53123            [::1]:10090            TIME_WAIT
  TCP    [::1]:53126            [::1]:10090            TIME_WAIT

and I can also see the nginx container
netstat -an | grep 80
  TCP                 LISTENING
  TCP    [::]:80                [::]:0                 LISTENING
  TCP    [::1]:80               [::]:0                 LISTENING

If in browser you type "localhost" you should get nginx welcome page (at port 80, default)

Now log into container:
docker exec -it webserver sh

from the container you can connect to
curl host.docker.internal
curl host.docker.internal:10090
they both work, because they "resolve to the internal IP address used by the host"
On my Windows host, if I type "ipconfig" I see that I have
Ethernet adapter vEthernet (WSL):
Ethernet adapter Ethernet:
If I try:
they both work on both host and container, but the first is a lot more responsive.
This proves that from container you can access a service running on host.


NB: besides host.docker.internal , also can be used, but they have different values (which?)

Saturday, March 11, 2023

Intellij Java remote debug with SSH tunnel

This is the simplest explanation how to do it: (it is a bit confusing, as is uses localhost for both remote and local)
and which clearly runs the ssh command locally forwarding to remote and highlights the role of -N parameter)
also worth reading: this is about PHP debugging

SSH tunneling explained visually

this command does the trick:
ssh -f -L -N

Chrome Developer Tools devtools

2 interesting crash courses :