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

NVM Node Version Manager – Why it’s Great, How to Use it in Linux

NVM Node Version Manager Linux

The Node Version Manager (NVM) is an indispensible tool for JavaScript Developers. Here’s why it’s so useful, and how to use it in Linux. What is Node.js Node.js is a JavaScript runtime which allows you to build and run JavaScript apps outside of the web browser. It’s commonly used to build APIs, webapps and even desktop applications. New versions of Node.js are released periodically, with major version releases often breaking compatibility with code written for earlier versions. Managing Code Dependencies Sucks A code dependency is any software … Read more

How to Reverse a String in JavaScript in One Line of Code [Example]

Javascript Reverse String

This quick tutorial will show you how to reverse a string in JavaScript. Strings are Array-Like Strings in JavaScript are considered array-like. A string is an ordered series of characters, so it can be considered as an array of characters. This makes it easy to convert a string to an array. We can then use any one of the methods available for reversing the array to reverse the string. This means you can use any of the methods we’ve previously outlined on reversing arrays on strings. … Read more

How to Sort Arrays in JavaScript with the sort() Method [Examples]

Javascript Sort Array

This tutorial will show you how to sort arrays in the JavaScript programming language with the array sort() method and provide some code examples. What is an Array in JavaScript? An array is a type of JavaScript variable that can hold a series of variables, references to variables, or values. It’s like a list of items. Each item or element in the array has a value and a position. The position is the order the element appears in the array and is called the index. Indexes are zero-indexed – meaning … Read more

How to Generate a Range (Numbers/Letters) in JavaScript

JavaScript Generate Range

This article will show you how to generate a range of numbers or letters in JavaScript, and provide some functions you can copy and paste into your own project. The Python, PHP, and many other popular programming languages provide a range() function, for generating a range of numbers or letters between two values. JavaScript does not have a built-in function for doing this, but it’s easy functionality to implement yourself. Here’s how to do it, and some pre-made functions you can just paste into your own project to use … Read more

Copy/Clone an Array or Object in JavaScript The Right Way [Examples]

How to Copy/Clone JavaScript Array

This tutorial will show you how to properly copy/clone an array or object in JavaScript – it’s not as simple as it seems! Copying an array or object may seem simple – but JavaScript throws a spanner in the works – the fact that when you assign the value of one variable to another it references the original variable. This means that if the value of the original variable is changed, the value of the copy will change too! To get around this, you will need to clone the array – ensuring … Read more

Exiting JavaScript Loops: ‘break’ & ‘continue’ [Examples]

Javascript Break Continue Statements

This article will explain the JavaScript break and continue statements and how they are used to exit and skip iterations in loops. JavaScript Loops In programming, a loop iterates through a series of values, performing an action on each value it encounters. Arrays can be looped through using the forEach method, and the for statement can be used to loop through a set of values generated by a JavaScript expression. You may encounter situations where you want to prematurely exit a loop, or skip processing certain values in the loop. This is what … Read more

Searching JavaScript Arrays with the Array.find() Method [Examples]

Javascript Array find()

This tutorial will show you how to search arrays in JavaScript using the Array.find() method, and show some code examples. JavaScript Arrays An array is a type of variable that holds an ordered list of values (or references to other variables), called array elements. Each element has a position in the array, called the index – and can be accessed by using that index. We’ve got a whole pile of things you can do with JavaScript arrays. Accessing elements in the array by their index is convenient, … Read more

How to Write/Save to a File with PHP [Examples]

PHP Write/Save File

This tutorial will demonstrate how to write data to a file on the server in the PHP programming language. Code examples are provided to show you how it’s done. Writing data to a file server-side is a common task. Whether you’re writing log files so you can debug your app, or saving user submitted data, you will need to save a file at some point in your web development career. Writing data to a file in PHP is a three-step process. You must first open … Read more

Categories PHP

Ultimate Guide to Uploading Multiple Files With PHP [Examples]

PHP Multiple File Uploads Ultimate Guide

This tutorial will explain how to upload one or multiple files from the web browser to the server using PHP. Code examples are included, including the code for limiting file size and type. Being able to have your users upload files to your app has become expected functionality in most web apps. Photos, filled out PDF forms, videos, recordings – any kind of file can be uploaded, and the process is relatively straight forward. PHP provides all of the required tools for file uploading and … Read more

Categories PHP

How to Resize/Crop Images in PHP with the GD Library

PHP Resize/Crop Image

This tutorial will show you how to resize or crop images in the PHP programming language. Code examples are provided which can be copy and pasted into your project. GD Library vs ImageMagick Image resizing in PHP is performed by an optional image processing library. The two most popular image processing libraries for PHP are GD and ImageMagick. Both work well, but I’ll be sticking to the GD Library for this tutorial as it is the most popular and supported. Installing the GD PHP Extension The GD library … Read more

Categories PHP