Install Go on Ubuntu 18.04, Using Snap

Refer: https://www.codeooze.com/ubuntu/ubuntu-18-golang-snap/

Step 1: Check if Go is already installed
$ go version

Step 2: Install Go using snap, see what's available
$ snap info go

Step 3: Classic confinement error
Explanation: Most snaps are installed in confined containers and only have limited access to other system resources. However, snaps published with classic confinement have greater access to the rest of the system, which is desirable for scripting packages such as Go.

$ sudo snap install go --classic

Step 4: Verify the install
$ snap list
$ go version
$ go env

Conclusion
You have now successfully installed Go in Ubuntu 18 using snap

Disable Windows Git Credential Manager

Refer: https://stackoverflow.com/questions/37182847/how-do-i-disable-git-credential-manager-for-windows

OK, I discovered that you need to either avoid checking the "Git Credential Manager" checkbox during the Git for Windows installer, or (after installation) run the Bash shell as Administrator and use git config --edit --system to remove the helper = manager line so that it is no longer registered as a credential helper.

For bonus points, use git config --edit --global and insert:

git config --edit --system

[core]
   askpass =

To disable the OpenSSH credentials popup too.

24 Python Libraries

Refer: https://www.infoworld.com/article/3008915/24-python-libraries-for-every-python-developer.html

Another web browser like flask, called bottle
Refer: http://bottlepy.org/docs/dev/
$ sudo pip install bottle

Run Linux sh command inside python
# Refer: http://amoffat.github.io/sh/
$ sudo pip install sh

Abstracts Selenium and can run Chrome and headless Chrome
Refer: https://splinter.readthedocs.io/en/latest/drivers/chrome.html
$ sudo pip install splinter

 

API Mock Testing

Simple tool to verify you can send various requests
Refer: https://httpbin.org

Simple Debug Post Tools

  • https://webhook.site/#!/
  • https://pipedream.com

Mocking Tools

  • https://getsandbox.com
    • https://github.com/getsandbox/sandbox
  • https://www.mockable.io
  • http://jsonstub.com

You can run it locally:
$ docker run -p 80:80 kennethreitz/httpbin

Announcing Httpbin.org

June 12, 2011
The development of Requests, the Python HTTP Module for Humans, led to some annoying testing practices. Relying on random websites and services in order to test different capabilities of the HTTP client became annoying quickly. PostBin.org was perfect for testing POST request behavior, but is usless for other situations. I was hoping to extend its functionality to other request types, but it turns out that PostBin runs on the Google App Engine platform. No.

Thus, httpbin.org was born.

Example Endpoints

To get a feel for what HttpBin does, here are a few endpoint examples:

$ curl http://httpbin.org/ip :

{"origin": "::ffff:24.127.96.129"}
$ curl http://httpbin.org/user-agent :

{"user-agent": "curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3"}

Debug NodeJS Application

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!

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: