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

Using Recursion/Recursive Functions in Python, with Examples

Recursive Functions in Python

This article will explain how to use recursion in Python functions, with some example code to illustrate the concept. A recursive function is a function which calls itself one or more times until a condition is met. If a function that uses recursion calls itself too many times, Python will throw an error. As this is a demonstration of a code structure rather than anything with any specific syntax, I’ll show a simple example of a recursive function and leave comments explaining what is going on. Python … Read more

Raspberry Pi & Python Powered Tank Part III: More Tank

Python Powered Tank Part III More Tank

This was only meant to be a two-parter, but I couldn’t leave well enough alone. Raspberry Pi & Python Powered Tank Part III is an update with better Python code and an improved design. I’ve gone back to fix the biggest issues that were left after Part II. I’ve omitted a bit of the mucking about in this article to keep it focused on what worked. How Did We Get Here? If you haven’t yet checked out the full build process, here are the previous … Read more

DIY Arduino Powered Soldering Extraction Fan

Arduino Fan

This article will show you to build a DIY soldering extraction fan (to ventilate fumes) using an Arduino and a temperature sensor to activate the fan when the soldering iron is hot. Before you read this, why not open up my other projects in some new tabs for further reading when you’re done? Smart Mirror Wikipedia Scraper Photo Resizer and watermarker Raspberry Pi Powered Palmtop/Laptop Raspberry-Pi augmented Apple Macintosh Python Powered Tank! The Project A thoughtful commenter on a previous article suggested I get an … Read more

Installing OpenWrt on a BT HomeHub 5 (or Plusnet Hub One), Full Instructions

BT HomeHub OpenWrt

This article documents my success in getting the OpenWrt operating system up and running on a BT HomeHub 5A (also sold as the Plusnet Hub One). This was checked with the latest version of OpenWRT as of early 2021, so it’s up to date and ready to do some networking. Once you’ve got an OpenWrt device set up, you can start mucking around with a bunch of useful computer networking concepts and tools like ad blockers and segregated networks – I’ll explore some common usage in … Read more

DIY Arduino Powered Electronic Morning Checklist

Arduino Morning Checklist

If you’re the sort of person who has to check the stove is off before leaving the house, then recheck it because you can’t remember if you checked it (and maybe even turn around at the front gate, unlock the door, go back inside and check a final time) – this might be the project for you. Before I get into it, if you haven’t already, check out the other projects I’ve built for LinuxScrew: Python Powered Tank! Python Powered Tank Part II Python Powered … Read more

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

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

The MySQL LIMIT and OFFSET Clauses [with Examples]

MySQL LIMIT and OFFSET Clauses

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

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

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