blog RSS
PHP - How to Redirect
Creating a PHP redirect allows you to redirect a user to a different page on your site. PHP redirection typically is used when you are attempting to permanently redirect the page, therefore it should return a 301 Moved Permanently response. If you are only temporarily redirecting you should use a 302 Found response. Check below for a examples of each implementation. ...
Java - Generating random integers
While generating random int values in a specific range is fairly simple, it still requires that you understand the syntax and how to use the Java Random class. Let's take a quick look at some examples below which go over some options when generating a random number in Java depending on your Java version. Java 1.6 and older In older version of java it...
Java - "Could not find or load main class" Error
One of the most frequently encountered errors when learning Java programming is the "Could not find or load main class" error. Before we dive into understanding the cause of the error, it's first important to understand how to launch a program using the java command. The "Could not find or load main class" error can be caused by many things, let's start with the basics...
Python - Reading a file line-by-line into a list
A common question asked when programming with Python is How do I read every line of a file in Python and store each line as an element in a list? Below we will go over an example to show you how to read the file and append each line to the end of a list. Reading a small file into a...
Python - Call an External Command
Learning how to run an external command from inside python is fairly straightforward. Python supports several methods for calling an external command. Determining which method to use depends on the use case, view our examples below of calling an external command. Use subprocess.call() The recommended way to execute an external command in Python is by using the subprocess module. The example below uses the call() method to invoke...