Update global npm packages

// Updating all globally-installed packages
npm update -g
// or 
npm install npm@latest -g

// Determining which global packages need updating
npm outdated -g --depth=0

// Updating a single global package
npm update -g <package_name>


Could not fetch URL https://pypi.org … There was a problem confirming the ssl certificate.

// Full error message
Could not fetch URL https://pypi.org/simple/autopep8/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='some.host.net', port=444): Max retries exceeded with url: /?cfru=aHR0cHM6Ly9weXBpLm9yZy9zaW1wbGUvYXV0b3BlcDgv (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))) - skipping

// This could mean there is no local certificate to read from. See this post

Could not install packages due to an EnvironmentError [Error 13] Permission denied:

// error message when installing a pip package
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'C:\\Python38\\Lib\\site-packages\\__pycache__\\pycodestyle.cpython-38.pyc'
Consider using the `--user` option or check the permissions.

// just add --user to the command. ex:
python -m pip install autopep8 --user --trusted-host files.pythonhosted.org --trusted-host pypi.org

nginx error with Angular routing

404 Not Found

nginx/1.14.0 (Ubuntu)



#change this line:
try_files $uri $uri/ =404;
#to this:
try_files $uri $uri/ /index.html;
#then restart nginx
sudo systemctl restart nginx

Call API from Python

import requests
import urllib3

# suppress the HTTPS warnings in terminal

session = requests.Session()
session.verify = False

url = "https://some.url.com?param1=something&param2=something"
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'}

# call the HTTP endpoint
httpResult = session.get(url, headers=headers)

# some extra details
elapsedSeconds = httpResult.elapsed.total_seconds()
statusCode = httpResult.status_code

Get user credentials securely in PowerShell

#Get user credentials securely
Try {
	$credentials = Get-Credential "$env:username"
Catch {
	$log += "`n- " + $_.Exception.Message

#Get current domain to use for authentication. ADSI = Active Directory
$currentDomain = "LDAP://" + ([ADSI]"").distinguishedName

$activeDirectoryEntry = New-Object System.DirectoryServices.DirectoryEntry($currentDomain,$credentials.GetNetworkCredential().UserName,$credentials.GetNetworkCredential().Password)
if ($activeDirectoryEntry.name -eq $null)
    $log += "`n- Failed to authenticate that username and password."
} else {
    $log += "`n- Authentication was successful."

#Display Results
$log = "Results:"
function Output-Result {
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") > null

Startup.cs example for .NET Core API w/ Swagger

using Swashbuckle.AspNetCore.Swagger;

public void ConfigureServices(IServiceCollection services)
    services.AddSwaggerGen(c =>
        c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });

    services.AddTransient<ISomeInterface, SomeDependency>();

// -----------------

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    if (env.IsDevelopment())
        app.UseSwaggerUI(c =>
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API");