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

How to Use the PHP ‘do while’ Loop, With Examples

PHP do while

This tutorial will teach you how to use the do while statement to build loops in the PHP programming language, and show some examples. The do while loop is one of the simplest types of loop in PHP. The code inside the loop will execute for as long as the do while condition is true. Change the condition, and the loop will exit. do while loops are a fundamental part of PHP (and loops are an essential part of computer programming in general) – so it’s good to get to know how they … Read more

Categories PHP

How to Use the Python slice() Function, With Examples

Python slice()

The Python slice() function can be used to get a portion of a list, tuple, string, or other sequence. This article will show you how to use it. Python slice() Function Syntax Here’s the syntax for the Python slice() function: slice(START, STOP, STEP) Note that: slice() does not return the specified portion of an object It returns a slice object which is used to retrieve the specified portion from a sequence – it does not contain the sequence itself. This is probably best demonstrated in the below examples START is the starting position (index) of the sequence you … Read more

What is a Python Dictionary? Explanation and Code Examples

Python dictionary

Here’s everything you need to know about the Dictionary data type in Python, what it can store, and how to use it. Python has several built-in data types for storing data (more than other languages like JavaScript) – from basic types like integers, floating-point numbers, and strings to more complex types like lists, tuples, and dictionaries. What is a Type? A variable’s type defines what kind of value it can store and what can be done with it. What is a Dictionary? A dictionary is a variable type … Read more

How to Add/Append Items to a Dictionary in Python [Examples]

Add Item to Python Dictionary

This short tutorial will show you how to add single or multiple items (as key:value pairs) to a dictionary in the Python programming language. What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. There are a couple of ways to add items to a dictionary, so we’ve put together this article separately to make sure we’ve got everything covered! Checking Whether a Key Exists in a Dictionary As outlined in the article linked above, dictionaries store data as a series of key:value pairs. Before … Read more

Quick and Dirty CCTV with Raspberry Pi, MotionEyeOS + Webcam

home cctv motioneyeos

In this article, I’ll walk through the process of setting up MotionEyeOS on a Raspberry Pi, using a cheap USB webcam to create a DIY CCTV system. MotionEyeOS is a pre-configured Linux distribution that turns your Raspberry Pi into a home CCTV system.  You can set up multiple cameras and set them to detect motion or record on a timer, and send the resulting photos and videos to you via email or save them to online storage. What You’ll Need A Raspberry Pi A USB … Read more

How to Merge Dictionaries in Python, With Examples

Python Merge Dictionaries

This article will show you the simplest ways to merge two or more dictionaries in the Python programming language. Note that the code examples in this article are written for Python version 3 – and will not work with Python version 2! What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. As there are a couple of ways to merge multiple dictionaries in Python, we’ve put together this article separately to make sure we’ve got everything covered! Merging/Joining Using Dictionary Union … Read more

The Python ord() Function – What it Does and How to Use It

Python ord()

The ord() function returns an integer representation of a Unicode character. Here’s why it does that and how it’s used. Python ord() Function Syntax First, here’s the syntax for the ord() function: ord(CHAR) Note that: CHAR is the single Unicode character you wish to receive the corresponding integer representation of Only a single character is allowed! OK, But Why? The integer returned by ord() is the Unicode code point of the character. It’s a unique number that identifies the character. Unicode represents characters from several languages and includes symbols, emojis, and combinations of all of them. When data is saved … Read more

How to Slice a Dictionary in Python, With Examples

Python Dictionary slice()

We’ve covered how to use the slice function to slice strings, tuples, lists, and other sequences. This tutorial will show you how to slice dictionaries, with examples. Dictionaries Not sure what a dictionary is in the Python programming language? Get up to speed with our article here. The slice() Function and the islice() Function Check out the full article here on how the slice() function works – we’ve covered it in-depth. Unfortunately, the slice() function built-in to Python does not work with dictionaries. If you do try to use slice() with a dictionary type variable, you will receive the following error: TypeError: … Read more

How to use Comments in JavaScript

JavaScript Comments

This short article will explain how and why you should use comments in JavaScript. First up, how to comment. What is a Comment? A comment in programing is one or more lines of text that aren’t interpreted as programming instructions. Instead, the computer skips them when executing your code, completely ignoring them. Therefore, comments don’t have to conform to any valid syntax. They’re just text that you read, and the computer doesn’t. Single-Line Comments in JavaScript Commenting is easy. How easy? This easy: // This is a comment … Read more

How to Unzip Files in Linux with the unzip Command

Linux unzip

We’ve zipped files from the Linux command line; now, let’s unzip them. This short article will show you how. Zipping Files Zipping files is common parlance for compressing one or more files or directories into a .zip file – a compressed file format. We cover how to do that in this article, so there’s no need to repeat too much of it here. The Unzip Command The unzip command may not be installed on your system by default. If it isn’t, it can be installed on Debian/Ubuntu-based OS by running: … Read more