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

Concatenating (Joining) Strings in JavaScript [3 Methods]

javascript string concatenation

Being able to concatenate (join) two or more strings together is pretty useful – you may be combining user input for storage in a single database column or doing the reverse – combining data from multiple database columns into a single string for display or output. There are several ways to concatenate strings in Javascript, and we’ll cover these methods below, along with some useful examples. The string.concat() Method The string.concat() method will join any number of strings to a given initial string. Syntax string.concat(string1, string2, string3…) Note that: string is … Read more

Javascript String includes() Method – Check if a String Contains Another String

Javascript String includes

Here’s a guide on checking whether a string contains another string in the JavaScript programming language using the includes() method. includes() Syntax string.includes(search, start) Note that: string should be a string value or variable search should be the string you are checking for start is the index (position) you want to start searching at. It’s optional Indexes start counting at 0 – The first character of the string is at index 0 returns bool Examples var string = “Linux all over the world”; var result = string.includes(“over”); // Will … Read more

Python isinstance Function, With Example [Guide]

Python isinstance Function

The Python isinstance() function determines the type or class of a variable. Read on to find out exactly how isinstance works, with an example below. 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. isinstance Syntax isinstance(OBJECT, CLASS) Note that: OBJECT is the variable or value to check the type or class of CLASS is the type or class we want to see if the variable type matches The function returns a boolean value (True/False) Types in Python Generally, … Read more

What is a Tuple in the Python Programming Language?

python tuple

A Tuple is a type of variable in Python – a data structure containing multiple parts. It’s a collection (or array) of data – but a specific kind of collection. It’s Ordered (Indexed) Elements in a tuple are stored in order – stored with an index or position – their position in the collection is fixed, and they can be found by their position. It’s Unchangeable (Or Immutable) Once a tuple is created, elements in it cannot be moved, removed, added, or altered. Duplicates are Allowed Duplicate values are allowed as tuples are indexed, so multiple elements with the same … Read more

Using JavaScript try/catch/finally Statements [With Examples]

JavaScript try catch finally

This tutorial explains how to use the try/catch/finally statements in Javascript to handle errors, with some useful examples. Sometimes an error is expected – and rather than wanting the application to halt execution on the error; you want to do something else. Other times, an error is unexpected or detrimental to the running of an application, and you want to make sure that it is reported. try/catch statements in JavaScript let you do this. try/catch will attempt to run a block of code and take a specified action … Read more

Array slice() Method in JavaScript, with Examples

Array slice in JavaScript

We have covered removing items from arrays in JavaScript, as well as checking whether an item is present in an array. This article will look at copying or returning a subsection of arrays using the slice() method in Javascript. slice() Syntax arr.slice([start[, end]]) Where: arr is an array or existing array variable start is the index to start the slice at If it is undefined, it will default to 0 The index is the position of the item within the array. Remember, they start at 0! end is the index to end the slice at If it … Read more

The Macintosh Pi – Vintage Apple Macintosh + Raspberry Pi!

Vintage Apple Macintosh Raspberry Pi

In this project, I will be putting a vintage Apple Macintosh to use with Linux and Raspberry Pi! My latest purchase. The Powermac G4. Stylish. Powerful (For 2001). Completely impractical in 2021. Why did I get it? Because it looks cool, and I really like the late 90’s/early 2000’s design of Apple’s hardware. It’s all translucent and cool. There’s still a lot of good software for these old macs – and the simplicity of them is kind of nice, so I thought – could I use … Read more

Top 3 Best Linux Distro for Gaming in 2021

Best Linux Distro for Gaming

This article will take you through our top 3 picks of the best Linux distributions for gaming in 2021. Best Linux Gaming Distros There are so many Linux distributions available for a multitude of purposes, but there are not many Linux distros with gaming at the forefront. However, many distros are great for gaming. Let’s discuss the honorable mentions, each distribution has its purpose and could be a good fit for you. Pop!_OS Aside from the asinine use of punctuation, Pop!_OS is a really great Linux … Read more

Read a File Line by Line in Python [3 Methods]

Line by Line in Python

This tutorial will examine several methods and best practices for reading a file line-by-line in the Python programming language. Reading a file line-by-line will be useful for parsing log files, CSV spreadsheet files, or even reading files you have generated from an application yourself. Line by Line File Reading – Examples The examples on this page will read from a text file named mytext.txt with the following content: Linux Is Very Cool Using the readlines() Function The following python code will call the built-in open() function, which … Read more

PHP foreach Loop [With Examples]

PHP foreach Loop

Looping over arrays and iterating over an object’s attributes form the foundation of a lot of application logic. The foreach construct in PHP can do both and is a crucial tool for building your application logic. PHP foreach Syntax The syntax for a foreach construct in PHP is as follows: foreach (iterable_expression as $value) { # statement(s) } Or, if you also wish to access the array key as well: foreach (iterable_expression as $key => $value) { # statement(s) } Note that: iterable_expression is the variable or value to … Read more

Categories PHP