How Do You Run Code in the Eclipse IDE?

Problem scenario
You are using Eclipse for the first time. You try to to use Run, but you get an error message like this: “Unable to Launch The selection cannot be launched, and there are no recent launches.” Or you try to go to “Run configuration” and you have a prototype, but the “Run” button is grayed out. What should you do?

Solution
In the Run configuration section,

How Do You Find the JQuery Version from the Command Prompt of a Linux Server?

Problem scenario
You are using Linux, and you want to know what JQuery version is installed. What do you do?

Solution
JQuery is a library to work with Javascript. There are many ways to install JQuery: git, using a .tar.gz file, the YARN CLI, or the npm command.

If it was installed with npm, one way find out the version is to run one of these command:

npm view jquery versions
npm view jquery version
npm view jquery
npm info jquery
npm ls jquery

This solution was partially taken from this external page.

How Do You Write a Python Program to Extract Lines of a Specific Date?

Problem scenario:
You have a log like this:

Sep 18 07:28:11 server1 sshd[29284]: Received disconnect from 125.52.17.109 port 46970:11: Bye Bye [preauth]
Sep 18 07:28:11 server1 sshd[29284]: Disconnected from 125.52.17.109 port 46970 [preauth]
Sep 18 07:28:11 server1 sshd[29282]: Failed password for root from 51.12.19.109 port 24844 ssh2
Sep 18 07:28:13 server1 sshd[29287]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=119.29.155.214 user=root
Sep 18 07:28:13 server1 sshd[29282]: Failed password for root from 51.12.19.109 port 24844 ssh2
Sep 18 07:28:14 server1 sshd[29282]: Received disconnect from 51.12.19.109 port 24844:11: [preauth]
Sep 18 07:28:14 server1 sshd[29282]: Disconnected from 51.12.19.109 port 24844 [preauth]
Sep 18 07:28:14 server1 sshd[29282]: PAM 2 more authentication failures; …

How Do You Troubleshoot a “SyntaxError: invalid syntax” Error in Python?

Problem scenario
You do not know why you are getting the error. The line has an “l” (a lowercase “L”) or a numeral one (“1”) in it.

You may have identified that the line of code is different in one file from another. You cannot tell what is different about your code or why you are getting this error. What should you do?

Solution
Enter vi or open Notepad++ to view the code.

How Do You Troubleshoot The Message “no module named pandas”?

Problem scenario
From a Python command prompt or when you run a Python program, you get the error message “no module named pandas”. You have used pip and pip3 to install pandas. What should you do?

Solution
Use “python3” instead of “python” to ensure you are using Python 3.

You may also want to see this posting.

How Do You Write a Python Program to Parse a Log File and Return Lines with the Word “Failed”?

Problem scenario
You want to retrieve lines from a log file with the word “failed”. How do you do this with Python?

Solution

Assuming the log file is named “auth.log”, this will work:

log_reader = open(‘auth.log’, ‘r’)
for line in log_reader:
lower_line = line.lower()
if lower_line.find(“failed”) != -1:
print(line) …

How Do You Get a Table in HTML/Javascript to Display Only The First n (or 10) Rows?

Problem scenario
You have a web page with a table. It uses HTML and Javascript. You want only a sub-portion of the rows to be displayed and allow the user from the front-end to click a drop down menu to see more results. What should you do?

Possible Solution #1
Have two blocks in the .html file. Have the top one define a function that accepts a parameter and filters the table results if/when called.