Home » Programming

Python 2 vs Python 3 – Which Should I Be Using?

Python 2 vs Python 3

There are still many tutorials and resources online that are written for Python 2 rather than the newer Python 3 – So, which should you be using? The short answer is below: Python 3. Why You Should Use Python 3 Python 3 is better in every way. It is a major revision that was released almost a decade after Python 2. The smart people who build programming languages probably learned a lot of lessons in that time. The syntax in Python 3 is more consistent … Read more

Home » Programming

10 Fun Python Projects for Beginners – Kids and Adults

Python Projects For Beginners

Here are 10 projects to get you started learning the Python programming language. Not a newbie? Check them out anyway for some Saturday afternoon project ideas. If you’re trying to learn something new, making it fun can be a big help. Being engaged in a project means you remember why you did something the way you did and helps to make you more confident when using the same tools again. Bonus if you get creative and start adding your own touches – it’s the best way to … Read more

Home » Programming

How to Create and Use Enums in JavaScript (Not TypeScript)

JavaScript Enum

This article will show you how to create and consume Enums in JavaScript. Unfortunately, javaScript does not include native support for Enums, but you can add comparable functionality yourself. Note that TypeScript, a language that builds on JavaScript, does include support for Enums natively. So we’re only looking at plain JavaScript here – not TypeScript. 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 … Read more

Home » Programming

Generate Random Numbers and Strings in JavaScript [Examples]

Javascript Random String Number

This guide will show you how to quickly and easily generate random numbers and strings in the JavaScript 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 … Read more

Home » Programming

JavaScript String split() Method, With Examples

JavaScript Split Method

Want to split a string up into several smaller strings using JavaScript? This is the article for you. The JavaScript string.split() method will split up a string and return an array of strings. The string will be split at the position noted by a specified character. Here’s how to use it. JavaScript string.split() Syntax A method is a function or procedure available to run from an object or variable which will be run using the value from that variable. The split() method is available on any string typed variable. Here’s the … Read more

Home » Programming

How to Use the Ternary Operator in JavaScript, With Examples

JavaScript Ternary Operator

This short article will explain what the ternary operator is in JavaScript and how to use it. The ternary operator is a short-hand if statement for quickly executing code based on whether a condition is met. It simplifies your code and reduces visual clutter. Here’s how to use it. JavaScript Ternary Operator Syntax The syntax for using the ternary operator is as follows: CONDITION ? TRUE_EXPRESSION : FALSE_EXPRESSION Note that: CONDITION should be a value or expression which can be evaluated as truthy or not truthy TRUE_EXPRESSION is the expression that will be … Read more

Home » Programming

What is ‘undefined’ in JavaScript?

JavaScript Undefined

This short article will explain what ‘undefined’ means in JavaScript – as both a type and a variable value. Creating a Variable with an undefined value To create a variable with an undefined value, it simply needs to be declared with no assigned value, for example: var myVariable; console.log(myVariable); If the above code is executed, undefined is logged as the value of myVariable as no value was assigned. undefined is a Type of Variable undefined is one of the primitive variable types in JavaScript. A variable type describes what a variable can be used for (for … Read more

Home » Programming

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 » Programming

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 » Programming

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