Creating a Stand-alone Jar File in IntelliJ

Navigate IntelliJ
File, "Project Structure", Artifacts
Click + "Plus Sign", and Select "Jar", "From modules with dependencies"
Now select the "Main Class" you wish to use (e.g. "DemoClass")

Keep defaults as-is
"extract to the target JAR"
"Directory to META-INF/MANIFEST.MF" points to source folder
Click "OK"

Now build the jar file
Build, "Build Artifacts", "Build"

Your jar file should now be in, or the equivalent
JavaFun/out/artifacts/JavaFun_jar

Run the file with
java -jar JavaFun.jar

VirtualBox Company VPN Issues with DNS

Refer: https://superuser.com/questions/570984/virtualbox-guest-ubuntu-loses-dns-when-host-connects-to-vpn

$ sudo gedit /etc/NetworkManager/NetworkManager.conf

Comment out, the plugins line below (shown before commenting)

[main]
plugins=ifupdown,keyfile,ofono
# dns=dnsmasq

Notes: had a very similar situation with Lubuntu 16.04 (should be identical in other Ubuntus) but this fix did not improve the situation. At least with 16.04, the problem appears to be that NetworkManager uses a local DNS proxy (dnsmasq), and this doesn't play nice with VPN connections, at least in the default configuration.

Commenting/deleting dns=dnsmasq in /etc/NetworkManager/NetworkManager.conf

Note: This fixed was applied too on the Windows host, but it did not seem to make a difference, go ahead and do both.

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvm Ubuntu-1804-Convert --natdnshostresolver1 on

Visual Studio Code Missing Underline Character

Easier solution is to just set the terminal font to monospace
Refer: https://github.com/microsoft/vscode/issues/35901

Refer: https://github.com/microsoft/vscode/issues/35901

The underscore or underline character is missing in Visual Studio Code terminal.  I changed the fonts to match Sublime and the font was too small.

{
    "terminal.integrated.fontFamily": "Monospace",
    "terminal.integrated.fontSize": 15,
    "python.pythonPath": "/usr/bin/python",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true
}

Install SQL Developer on Ubuntu 18.04 with OpenJDK 8

## Install Java 8 SDK

```Bash
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get -y update
sudo apt-get -y install openjdk-8-jdk
```

## Install Oracle SQL Developer

Before you can use SQL Developer with OpenJDK 8, you need to install JFX. Please note, that Oracle does not officially support OpenJDK, but it does work; however, you need to use JFX version 8. You will have to download the "Other Platform" where the JRE is NOT included with the installation.

Refer: <https://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html>

## Install JFX

Refer: <https://stackoverflow.com/questions/52484814/oracle-sql-developer-problem-initializing-welcome-page>

```Bash
sudo apt install -y libopenjfx-java=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt install -y libopenjfx-jni=8u161-b12-1ubuntu2 --allow-downgrades
sudo apt install -y openjfx=8u161-b12-1ubuntu2 --allow-downgrades
```

Verify you have OpenJFX 8 installed:

```Bash
dpkg -l | grep openjfx
```

Location of Java, required for Oracle SQL Developer:

```Text
/usr/lib/jvm/java-8-openjdk-amd64
```

Python Pathlib Module

Refer: https://stackabuse.com/introduction-to-the-python-pathlib-module/

How to use the Pathlib Module?

To use the pathlib module conveniently within our scripts, we import all the classes in it using:

from pathlib import *
As a first task, let's retrieve the current working directory and home directory objects, respectively, using the code below:

current_dir = Path.cwd()
home_dir = Path.home()
print(current_dir)
print(home_dir)
We can choose to import pathlib instead of importing all the classes. In that case, all the subsequent uses of classes within the module should be prefixed with pathlib.

import pathlib

current_dir = pathlib.Path.cwd()
home_dir = pathlib.Path.home()
print(current_dir)
print(home_dir)
Why use the Pathlib Module?
If you've been working with the Python language for a while, you would be wondering what is the necessity of Pathlib module when os, os.path, glob, etc. modules are already available? This is a fully justified concern. Let's try to address this via an example.

Let's say we want to make a file called "output/output.xlsx" within the current working directory. The following code tries to achieve this using the os.path module. For this, os.getcwd and os.path.join functions are used.

import os
outpath = os.path.join(os.getcwd(), 'output')
outpath_file = os.path.join(outpath, 'out.xlsx')
Alternately,

outpath_file = os.pathjoin(os.path.join(os.getcwd(), 'output'), "out.xlsx")
Though the code works, it looks clunky and is not readable nor easy to maintain. Imagine how this code would look if we wanted to create a new file inside multiple nested directories.

The same code can be re-written using Pathlib module, as follows:

from pathlib import Path
outpath = Path.cwd() / 'output' / 'output.xlsx'
This format is easier to parse mentally. In Pathlib, the Path.cwd() function is used to get the current working directory and / operator is used in place of os.path.join to combine parts of the path into a compound path object. The function nesting pattern in the os.path module is replaced by the Path class of Pathlib module that represents the path by chaining methods and attributes. The clever overloading of the / operator makes the code readable and easy to maintain.

Another benefit of the method provided by the Pathlib module is that a Path object is created rather than creating a string representation of the path. This object has several handy methods that make life easier than working with raw strings that represent paths.

Performing Operations on Paths
The classic os.path module is used only for manipulating path strings. To do something with the path, for example, creating a directory, we need the os module. The os module provides a set of functions for working with files and directories, like: mkdir for creating a directory, rename to rename a directory, getsize to get the size of a directory and so on.

Let's write some of these operations using the os module and then rewrite the same code using the Pathlib module.

Sample code written using os module:

if os.path.isdir(path):
os.rmdir(path)
If we use Pathlib module's path objects to achieve the same functionality, the resulting code will be much more readable and easier to maintain as shown below:

if path.is_dir()
path.rmdir()
It is cumbersome to find path related utilies in the os module. The Pathlib module solves the problem by replacing the utilities of os module with methods on path objects. Let us understand it even better with a code:

Debug NodeJS

Refer: https://dev.to/john_papa/debug-your-nodejs-app-in-60-seconds-5cni

Visual Studio Code (aka VS Code) has changed the game on Node.js debugging. There is a feature called Node: Auto Attach (you can learn more about it here in the docs). Or keep reading — this will only take a minute.

When you enable this feature, you can run your node app from a command line, from an npm script, or from a tool that runs one of those. Just make sure you add the Node Inspector flag to let Node know you are planning on debugging. Once you do this, the debugger lights up in VS Code!

Auto-Attach the Debugger to Node.js Apps with VS Code

Step by Step

Open the settings in VS Code (CMD + , on Mac or CTRL + , on Windows). You can also go to the Command Palette (CMD + SHIFT + P on Mac or CTRL + SHIFT + P on Windows) and search for settings.

Search for “auto attach” and you’ll see a setting for Node: Auto Attach. Go ahead and turn that on.

Now run your Node.js app from your favorite command line whether that be integrated terminal, external terminal.

node --inspect=0.0.0.0:9229 server.js

Now when you launch your app with the --inspect flag the debugger attaches to your app in VS Code! From here you can set breakpoints, step through your code, and have all the great debugging goodness!