How Do You Harden a Website Application?

Problem scenario
You want to ensure you web application is protected from buffer overflows, injection attacks and other vulnerabilities that could reveal sensitive information. How do you harden a website application and follow security recommended practices?

Possible Solution #1
Endeavor to prevent injection attacks. Minify the website application by not allowing file uploads and limit POST requests to 2 MB (page 28 of Node.js Security by Liran Tal).

 » Read more..

Using Python How Do You Convert Each Line to Be an Item in a List?

Problem scenario
You have a multi-line variable in Python. You want to convert each line to be its own item in a list. How do you make a multi-line string variable to become a list with the same contents?

Use the .splitlines() method to manipulate the string in this way.

Here is an example:

list_of_input=”””a line here
another line there.  » Read more..

How Can a Base Branch Not Be a Master Branch in Git?

Problem scenario
You have seen the term “base branch” in Git documentation. How can it not be the main branch?

In the context of a Pull Request, where one branch’s changes will update the same files (if any exist) and any new files will be copied into another branch, the branch receiving the changes and/or files is the base branch. The term “base” is used in GitHub’s GUI and Atlassian BitBucket.

 » Read more..

How Do You Iterate Through Two Lists of Unequal Length in Python?

Problem scenario
You want to iterate through two lists and perform some operation. The lists are not equal length. You want to iterate through them in some type of step-by-step fashion despite their lack of equality. What should you do?

Use this as an example:

list_a = [1, 2, 3]
list_b = [”dog”, “cat”, “rat”, “chicken”]

i = 0
j = 0

while (i <  » Read more..

What Does the “^” Operator in Python Do?

Problem scenario
In Python you try operations like these two:

5 ^ 6
9 ^ 10

Both return “3”. Why is this?

The exclusive or (aka XOR) symbol “^” “copies the bit if it is set in one operand but not both.” (Taken from

Here are some integers with their binary representation one space away:

3 11

5 101
6 110

9 1001
10 1010

5 is represented as 101.

 » Read more..

How Do You Connect over Port 5986 on a Windows Server?

Problem scenario
Port 5986 is blocked from your Linux server to your Windows server. You have used the nmap command and see that it is filtered. You believe there are no intermediate firewalls or OS firewalls blocking this port. What should you do?

This assumes you have no firewall blocking port 5986 for incoming connections to the Windows server. nmap will report 5986 is filtered despite there being nothing blocking this port if wsman’s listener has not been properly configured.*

  1. Run this script on the Windows server:

$hostName = $env:COMPUTERNAME
$serverCert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $hostName
Export-Certificate -Cert $serverCert -FilePath c:\vagrant\PsRemoting-Cert1.cer
Get-ChildItem c:\vagrant\PsRemoting-Cert1.cer
Enable-PSRemoting -Force
New-Item -Path WSMan:\localhost\Listener\ -Transport HTTPS -Address * -CertificateThumbPrint $serverCert.Thumbprint -Force

  1. That is it.

 » Read more..

How Do You Repurpose Disk Space from a Windows Install (e.g., /dev/sdbc) to Be Used by Your Linux Server?

Problem scenario
Your Linux server was installed over an old Windows server. You want to repurpose sections of the hard disk (e.g., sda1 and sda3). Linux has been installed, but some sections of the disk are not usable by Linux. What do you do?

Warning: This could permanently delete data. If you make a mistake you may need to reformat your Linux server.

 » Read more..

How Do You Troubleshoot the AWS Error “Subnets specified must be in at least two different AZs”?

Problem scenario
You run an AWS CLI command, but you get this error message:
“An error occurred (InvalidParameterException) when calling the CreateCluster operation: Subnets specified must be in at least two different AZs”
How do you find subnets in different availability zones?

Run commands such as these (but replace the “us-west-x” and “us-east-x” with the availability zones that you use):

aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-west-1a]’
aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-west-1b]’
aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-west-1c]’
aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-east-2a]’
aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-east-2b]’
aws ec2 describe-subnets –query ‘Subnets[?AvailabilityZone==us-east-2c]’

Now you will see more subnet IDs for your original command.

 » Read more..

How Do You Troubleshoot the Vagrant Message “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — winrm (LoadError)”?

Problem scenario
You are running Vagrant, but you get this error: “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — winrm (LoadError)”

You run “gem list” (or “sudo gem list”) and see winrm is installed.

What should you do?

Possible Solution #1 (recommended)

  1. Run this command:

gem list | grep libvirt

2. Verify that libvirt’s version is at least 0.6 or higher.

 » Read more..

How Do You Fix a Error when Running PHP Too?

Problem scenario
You get an error about memcache and you are running PHP. Or you get an error “Unable to load dynamic library “”? You run “php –version” and you see an error about memcache or memcached (e.g., a missing file). What should you do?

Possible Solution #1
Get a file from a working Linux server and place it in the directory that the error message showed in the “php –version” command.

 » Read more..