Home » 2021 » March

Converting Bytes To String In Python [Guide]

Converting Bytes To String

This tutorial covers converting Bytes to a string variable (and a string to Bytes) in Python versions 2 and 3. What is the difference between a string and a byte string? A string is a series of characters. When stored on disk, the characters are converted to a series of bytes. What series of bytes represents what character is defined by the character encoding. When a string is stored to disk, it is converted to bytes (encoding). When it is read back into a program, the bytes must be converted back to a … Read more

Home » 2021 » March

Checking Type in Python [Guide]

Checking Type in Python

This article explains how to check the type of a variable in the Python programming language. What are Types? The type of a variable determines what it can or can’t do. It determines what value the variable may take and what can be done with that value. Using the type() Function Pass a variable or value to the type() function, and the variable’s type will be returned: myNumber = 4 type(myNumber) # int myString = ‘foo’ type(myString) # str Using the isinstance() Function For more examples, check out the similar isinstance() function: To compare the … Read more

Home » 2021 » March

The MySQL LIMIT and OFFSET Clauses [with Examples]


This tutorial covers limiting the number of results from a MySQL database query using the LIMIT clause and skipping results using the OFFSET clause. This is especially useful when wanting to paginate results in web applications – spreading them out over several pages by retrieving a subset of the database results. Examples Examples will use the following table and data: table_people id name 1 Bob 2 Ted 3 Jim 4 Pip 5 Zak 6 Tim LIMIT Here’s how to limit the results to 2 records using LIMIT: SELECT * FROM table_people LIMIT … Read more

Home » 2021 » March

MySQL CASE Statement and CASE Operator – Difference and Examples

MySQL CASE Statement and CASE Operator

There are two things called CASE in MySQL (and, by extension, the compatible MariaDB). The CASE Operator, for use in queries. The CASE Statement, for use in stored programs and procedures. Both have similar syntax and the same purpose. Both MySQL CASE Operator and Statement provide control over the results based on a set of conditions. Examples in this article will use the following test data: table_people id name 1 Bob 2 Ted 3 Jim 4 Pip 5 Zak 6 Tim CASE Operator The CASE operator is used … Read more

Home » 2021 » March

Showing Errors in PHP [Tutorial]

Showing Errors in PHP

This tutorial explains how to use several methods for displaying errors in a PHP application for debugging purposes. Be Careful There are security considerations when displaying errors in any application. Be careful when and where errors are displayed – especially when building products for the web – as the errors may contain sensitive information. For example, if an application connects to a database and the database crashes, an error will be produced. That error may contain the username and password used to connect to the database. If … Read more

Categories PHP

Home » 2021 » March

Why You Should Wrap File Paths in Strings in Your Shell Scripts

Why You Should Wrap File Paths

I stumbled across a thread about terrible programming mistakes and found this: https://github.com/MrMEEE/bumblebee-Old-and-abbandoned/commit/a047be85247755cdbe0acce6f1dafc8beb84f2ac Which contains the line: rm -rf /foo-bar-usr /lib/nvidia-current/xorg/xorg Note – I’ve added foo-bar- to the string so that if you try to run it, it won’t do the thing I’m warning about –even having that on my clipboard makes me nervous!. What happens when it’s run? It wipes out the entire /usr/ directory – essentially bricking your computer! All because of a single space. Due to the space after /usr, the rm command interprets it as two separate directories … Read more

Home » 2021 » March

Add Days (or Minutes, or Hours) to Javascript Date [or Subtract]

Add Days to Javascript Date

This article will explain how to add (or subtract) days, minutes, hours, seconds (etc.) to a JavaScript date. Why would you want to do this? Perhaps you want to tell a user that their assignment is due in a week and provide the date, or maybe your application needs to know what the date was 30 days ago to pop up a reminder – there are near-infinite usage cases. Add Days to Date Using Vanilla JavaScript First, here’s how it’s done in plain old JavaScript: … Read more

Home » 2021 » March

MySQL vs MariaDB vs MongoDB vs PostgreSQL vs SQLite vs MS SQL – Which to Choose?

Which database to Choose

There is a lot of weird-sounding language around databases. Most of it centers on the names of the popular database software which is available. It can make it tough to choose. Each strangely named database solution offers features making it suitable for different tasks. This article should shed some light on what’s what. SQL Is a Language SQL (pronounced ESS-QUE-ELL or sequel depending on which side of the raging debate you side with). It stands for Structured Query Language. It is not a piece of software – it’s the … Read more