Welcome to LinuxScrew

A site for Linux lovers worldwide. For newbies, system engineers, administrators, and everybody in between. We cover all things Linux, plus various programming languages, including Python, Javascript, and PHP.

View our featured tutorials and projects in the slider below or scroll down to see all recent articles.

How to Convert a USB Printer to Wireless with a Raspberry Pi
How to Use a Raspberry Pi for Digital Signage
The Worst Things You’ll Probably Google As a Programmer on Linux
How to Build a Raspberry Pi Internet Kiosk
Browsing the Internet on a 1989 Macintosh II with a Web Rendering Proxy
previous arrow
next arrow
Slider

Calculating Factorials in Python – The Easy Way

Python Factorial

This short article will show you the quickest and easiest way to calculate a factorial in Python using the factorial() function. This article is written for the Python 3 programming language. What is a Factorial, and How is it Calculated? A factorial is a mathematical formula in which a given positive integer is multiplied by all of the positive integers less than itself – the resulting number being the factorial of the original number. It is denoted with ! (exclamation mark) – so the factorial of 4 is written as 4! And is calculated out like so: … Read more

Converting to Float Numbers with the parseFloat() JavaScript Function, With Examples

JavaScript ParseFloat()

This article will explain floating-point numbers and how to convert values to floating-point numbers using parseFloat() in JavaScript. Looking to convert to an integer value instead – use parseInt()! What is a Floating Point Number? In programming, a floating-point number (commonly just called a float) is a number with any number of characters before or after a decimal point. A floating-point number might look something like this: 14.392 A floating-point number or float is also a type of variable. A variable’s type determines what kind of values it can store and what can be done with the variable … Read more

How to Compare Dates in PHP, With Examples

PHP Compare Dates

This tutorial will show you the best way to compare dates in the PHP programming language – and provide code examples. It’s essential to be able to accurately compare dates when building your app. For example, you may wish to compare dates for reporting purposes – retrieving a list of transactions from a shop for a given reporting period, or you may want to have your user enter a fake birthday into your webpage so that they can pretend that they are over 18. Anyway, … Read more

Categories PHP

Using the PHP ‘exit’ (AKA ‘die’) Function to Terminate your Script [Examples]

PHP exit die

This short article will explain the PHP exit function and how it is used to quit/exit/terminate a PHP script. PHP exit Function Syntax The syntax for the PHP exit function is as follows: exit(STATUS) Note that: exit will terminate the execution of the script at the point it is called STATUS is an optional integer or string value containing a status code or exit message If an integer value with a status code, the script will return this code as the exit status if running on the command line Exit status should be 0 for … Read more

Categories PHP

How to Convert String to Date in JavaScript, With Examples

JavaScript String to Date

Here are some easy-to-understand methods for converting strings to date objects in the JavaScript Programming language. Looking to compare dates in JavaScript? Find out how here. The Hard Way – Using Vanilla JavaScript JavaScript contains built-in functions for parsing a date from a string – but it’s severely limited. So here it is in action: var myString = ’01 Jan 1970 00:00:00 GMT’; var myDate = new Date(Date.parse(myString)); What’s happening here? A string is defined containing a date. A new Date object is then defined using the … Read more

Checking for Inequality in Python: ‘!=’ vs ‘is not’ [Examples]

Python Not Equal

Should you use the != operator or the ‘is not’ statement when comparing values in Python? Read on to find out! The != Comparison Operator The != operator can be used to compare two variables or statements’ return values. If they are not equal, the statement will return TRUE. Python is forgiving when it comes to comparing variables of different types. So if the type of the variables being compared is different, but the value is the same, it will return TRUE (rather than throwing an error) as they are not equal in both type and value. myNumber … Read more

How to Use the PHP *strstr()* Function to Search a String

PHP strstr()

This tutorial will show you how to use the PHP strstr() function to search and return a portion of a string, with examples. What is the strstr() Function For? The strstr() function searches a string and returns the matching portion of the string and everything that follows or precedes it. If the string does not contain a match for the search, a value of false is returned. It’s a hard one to visualize – the examples below will show you precisely what this means. If you’re simply looking to confirm whether … Read more

Categories PHP

How to Round Numbers (Integer, Decimals) in PHP with the round() Function

PHP round()

This article will show you how to round numbers in PHP with the round() function, including rounding to the nearest integer or a set number of decimal places. Why Round Numbers? There are various reasons you may want to round numbers. You don’t need incredible accuracy for many day-to-day calculations. You probably don’t need to know your height to several thousandths of a centimeter if converting from feet – knowing to the nearest whole centimeter is perhaps enough. If you’re calculating tax, you only need to know … Read more

Categories PHP

Implementing a Queue Data Structure in JavaScript [Examples]

JavaScript Queue

A queue is a commonly used data structure in programming. Here’s how to implement and use a queue in JavaScript. JavaScript doesn’t include a data structure specifically called a queue – but that doesn’t mean the functionality isn’t there. JavaScript arrays can be used in the same way – it’s just the terminology that’s a bit different. Rather than duplicating array functionality for queues, queue functionality exists in the array functions of JavaScript. What is a Queue Data Structure? A queue is a sequence of items in a specific order. Items can be enqueued (added … Read more

Rasperry Pi RetroPie Emulation Station Install Walkthrough (Video Games on Pi)

retropie video game emulation raspberry pi

This guide will walk you through the installation and configuration of RetroPie (a Linux distribution with Emulation Station pre-configured) and where to source some legal retro game console ROMS. RetroPie is a ready-to-use Linux OS for your Raspberry Pi, which has everything already configured and ready to emulate NES, SNES, GameBoy, Nintendo 64, Playstation, Sega, and many other game consoles. The installation and configuration steps are super easy.  I’ve documented them below with screenshots and notes.  Once RetroPie is up and running, I’ll install a … Read more