How Do You Generate a Load for Your Nginx or Apache Web Server?

Problem scenario
You set up a load balancing mechanism for your Nginx or Apache web server.  You want to test it and set up an artificial load of traffic.  You want to generate a significant amount of traffic to test the HTTP load balancing mechanism.  How do you do this?

Solution
Here are three scripts that can, by themselves, download a web page 100 times when they execute. 

How Do You Detect the Hard Drive Letter That Your PowerShell Script (.ps1 File) Is Saved On?

Problem scenario
You have a PowerShell script that you want to be able to detect the hard drive letter it resides on.  How can PowerShell detect the hard drive letter that the .ps1 file itself is stored on?

Solution
Use this command: (get-location).drive.name

To get the drive letter to be in a variable named $dl, use this:
$dl = (get-location).drive.name

Now you can use $dl as the drive letter in the PowerShell script.  

How Do You Troubleshoot the Scala Error “No such file or class on class path”?

Problem scenario
You know Scala is installed because you use “man scala” and see the correct man page.  But when you try to find the version, you get an error.  Specifically you run this command:  scala version

You see this: “No such file or class on classpath: version.”  How do you find out what version of Scala you have installed?

Solution
Reboot the server.

How Do You Install Scala on an Ubuntu Instance of AWS?

Problem scenario
You want to install Scala to an Ubuntu instance of AWS.  How do you do this?

Solution

Prerequisite
Verify you have 1 GB of RAM.  Run this command:  sudo dmidecode -t 17 | grep Size

If you see 512 MB in the output, then you will not be able to get Scala installed.  You will need an AWS instance with a flavor that has 1 GB of RAM or more. 

How Do You Install Scala on a RHEL Instance of AWS?

Problem scenario
You want to install Scala to a Red Hat Enterprise Linux instance of AWS.  How do you do this?

Solution
1.  Install Java:  sudo yum -y install java-1.8*

2.  Log off and log back on.

3.  Run these three commands:
curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum -y install sbt
sbt new scala/hello-world.g8

4. 

How Do You Troubleshoot the Java Error “java.lang.Error: Properties init: Could not determine current working directory”?

Problem scenario
You run this command:
javac -version

But you receive this error:  “Error occurred during initialization of VM java.lang.Error: Properties init: Could not determine current working directory.”

How do you solve this problem?

Solution
Log out of Linux and log back in.

How Do You Read in Keyboard Input from a User and Invoke a Unix Shell Command with a C++ Program?

Problem scenario
You want to see how C++ works.  You want to read in user input from the keyboard and have the C++ program run a bash command.  How do you do this?

Solution
Compile this code (e.g., as a file named “test.cpp” with “g++ test.cpp”) and run it (e.g., ./a.out):

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

How Do You Use the C++ Connector for Libpqxx?

Problem scenario
You want to integrate C++ programs with Postgresql on an Ubuntu instance of AWS.  You want to use pqxx (http://pqxx.org/development/libpqxx/) as it is an API connector for C++ to Postgres.  How do you use libqxx?

Solution
#1  Install Postgresql.  To install Postgresql, run this as root or with a “sudo ” in front of it: apt-get install postgresql

#2  To execute SQL commands,

How Do You Install pqxx on an AWS Instance of Ubuntu?

Problem scenario
You try to compile a C++ program (i.e., a .cpp file).  You get this message:  “fatal error:  pqxx/pqxx: No such file or directory.”  You want to install pqxx on your Ubuntu server in AWS.  What do you do?

Solution
#1  Log into the server.  Run this command as root or with a sudo in front it:

add-apt-repository ppa:jtv/ppa 
#Press enter in response to the prompt from the command above.