Home » 2021 » September

Encode Strings with PHP urlencode/rawurlencode [Examples]

PHP urlencode()

One way to pass data to a web page is via the URL query string. The data must be properly encoded – urlencode() and rawurlencode() in PHP do this. The PHP urlencode() function URL encodes strings in PHP and is widely used, but it is not the best tool for the job.  rawurlencode() is the modern replacement for urlencode() – though you may need to use the older urlencode() for compatibility if you’re working on older code. urlencode() Syntax urlencode($string) Note that: urlencode() will return a string variable containing … Read more

Categories PHP

Home » 2021 » September

How To Run Commands in the Background [Linux/Ubuntu]

Linux Ubuntu Run Command in Background

This article will show you how to run commands in the Linux (including Ubuntu) shell background. This is useful when working remotely via SSH. Say you’re connected remotely via SSH to a remote computer, and you want to execute a lengthy task. While the task is running, usually, you’d have to keep the connection open, with the terminal window open. However, this can be a hassle if you need to close the window to perform another task or if you have a spotty internet connection … Read more

Home » 2021 » September

The tr Command in Linux – What It Is and How To Use It

Linux tr Command

The tr (translate) command in Linux reads text from standard input, performs some modification to the text, and then sends it to standard output. This article explains and shows why and how you might use it. tr Command Syntax Here’s the syntax you’ll need to use the command: tr OPTIONS SET1 [SET2] Note that: OPTIONS should be a list of options from the below table The characters in SET1 will be replaced with the characters in the corresponding position in SET2 These are optional – some of the OPTIONS are capable of performing translations, … Read more

Home » 2021 » September

How to Use MySQL ‘alias’ to Make Queries Easier to Read

MySQL Alias

This article will explain and demonstrate the use of aliases in MySQL (and MariaDB). MySQL queries can get pretty gnarly – especially if you’re selecting multiple columns from multiple tables. An alias statement is a great tool for simplifying these queries. An alias is just another name for the column or table in question, which you can use to refer to the column or table by. It’s a nickname that can be used to quickly refer to something complex to save time when writing queries. MySQL Column Alias … Read more

Home » 2021 » September

Enums in Python – What They Are, How to Use Them

Python Enum

This article will teach you what an Enum is, and how they are used in the Python programming language. What is an Enum? An Enum (Enumerated Type) is a data structure containing multiple values. Each value is assigned to an identifier – and can be accessed by that identifier. Enums contain pre-defined constants that aren’t expected to change (they’ll be the same when the application is written and when it is run so that you can always refer to the data in the enum by the same identifier and get … Read more

Home » 2021 » September

Square Numbers and Exponents in Python, With Examples

Square Numbers and Exponents in Python

This tutorial will show you how to use exponents (e.g., calculating the square root of a number) in Python, with some code examples. This tutorial covers several ways to calculate exponents in Python 3. Using ** (Power Operator) The ** mathematical operator (known as the power operator) will calculate an exponent, raising the number on the left to the power of the number on the right of the operator: 4**5 # Will evaluate 4*4*4*4*4 and return the integer value 1024 Note that: You will receive a ZeroDivisionError if you try to raise 0 (zero) … Read more

Home » 2021 » September

How to Use ‘for’ Loops in Python, With Examples

Python for Loops

This article will show you how to use for loops in Python 3 and provide examples. Loops are one of the fundamentals of programming. So you’ll use them almost constantly. Data in computer software is often stored in arrays (or lists), for example, a record of students enrolled in a course, with each item in a list representing a student. These arrays of data need to be processed – and this is done using loops that step through each item in the array and perform some … Read more

Home » 2021 » September

Python lstrip and rstrip Methods – With Examples

Python lstrip and rstrip Methods

This short tutorial will show you how to use lstrip and rstrip to remove whitespace (or any other characters) from the beginning/end of strings in Python. The lstrip and rstrip methods are available on any string type variable in Python 3. Python lstrip String Method The lstrip (Left strip) method will remove leading characters from the string – that is, characters starting from the left of the string. Syntax Here’s the syntax for the lstrip method: string.lstrip(characters) Note that: string can be any string value or variable with a string value characters is an optional parameter for the lstrip method These are the characters that … Read more

Home » 2021 » September

How to use the Python zip() Function, With Examples

Python zip

This tutorial will explain how to use the python zip() function to merge or aggregate several iterables (including lists and tuples). First up, the Python zip() function has NOTHING to do with compressing files. It’s got nothing to do with making a .zip file. It’s a totally different thing. So if that’s what you’re looking for, this isn’t it! What are Iterables? In the Python programming language, iterables are data types that can be iterated over item by item. It includes variables called lists, tuples, sets, and dictionaries … Read more

Home » 2021 » September

How to Generate Random Numbers and Strings in Python

Python Generate Random Strings Numbers

This article will outline several methods for generating random numbers and strings in the Python programming language. Generating random values is a common and important task when programming almost any kind of application of moderate complexity. Random strings and numbers are used to generate unique identifiers (e.g., for the short URLs in URL shortening services), for identifying unique records in a database, and (most importantly) are frequently used to determine the behavior of gameplay elements in video games (for example, simulating a coin flip, or … Read more