After creating a script that included closing a firefox tab and hiding the window I realized I could not open firefox and just got a “Firefox is already running” error every time after running this script once. I tried running the command: $ sudo killall firefox As there may have been some hidden windows however […]
Archives for June 2021
How to create a Python Dictionary
Dictionaries in python are quite similar to arrays in how they look however arrays are indexed by a range of numbers i.e. 1-10, but dictionaries are indexed by their key. You can set these keys to immutable data types only. They can also be known as key pair arrays. You will be used to seeing […]
Command line parameters in shell scripts
Command line parameters are a way to pass information into a program or script in order for it to do what you want it to. Some examples of command line parameters: $ ls -l $ cat textfile The command line parameters here are the “-l” and “textfile”. How are command line parameters accessed within a […]
How to format code within web pages
When displaying code within web pages it can be hard to read if it hasn’t been separated from the other text and images on the page. To get around this problem you can use google code-prettify JavaScript. This allows code to be displayed like this: To implement this within your HTML you need to add […]
Python Quadratic Formula
An equation with the form ax^2+bx+c=0 is known as a quadratic equation. When plotted on a graph it will take the general shape of the graph seen below. The points at which the quadratic graph crosses the x-axis are known as the solutions of the quadratic equation. For this example, the quadratic crosses the x-axis […]
How to Check if the script is run by root at the start of the script
Check root at start of script Some scripts need to be run as root and you may want to check at the start of that script that it is running as root. This can be done by checking the environment variable $EUID. This variable will hold the value 0 if it’s being run as root. […]