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 Remove Duplicates From a List In Python, With Examples

Python remove duplicates from list

This article explores several ways to remove duplicate items from lists in the Python programming language. Using The dict.fromkeys() Method To Remove Duplicates From a List in Python This is the fastest way to remove duplicates from a list in Python. However, the order of the items in the list is not preserved. The fromkeys() method creates a dictionary (a collection of key:value pairs) with keys from a supplied sequence of elements (in this case, a list). As a dictionary cannot contain duplicate keys, they are removed. … Read more

PHP isset() – Check if A Variable is Set, With Examples

Using PHP isset()

This article shows you how to use the PHP isset() function to check whether a variable exists and is populated. So, it’s checking if a variable is set. Why would you want to do this? You can’t perform actions on a variable that doesn’t exist or that has no value – you’ll either get unexpected output or an error. So, being able to check that a variable is set and is populated is pretty useful. Syntax for isset() isset ( $var1 , $var2…) Note that: $var1 should be … Read more

Categories PHP

Using the Python ‘accumulate()’ Function to Aggregate Data, With Examples

Python accumulate()

This article will detail how to use the ‘accumulate()’ function in Python and provide some easy-to-follow example code. The accumulate() function in Python will process an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items which can be looped over) – returning the accumulated sum of the value of each item or running a given function on each item. The value of the accumulated value is stored for each step and returned with the result. The syntax and code in this article are written for … Read more

Using the Python ‘filter()’ Function to Filter a List, with Examples

Using Python filter()

This article will cover the syntax and usage of the filter function. It will work for both Python 2 and Python 3. The filter function in Python takes an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over) and checks that each item matches a set of criteria, removing those that don’t match. It’s a fast and easy way to filter the values in a list or array. Syntax for Python filter() The filter() function does not need to be imported to … Read more

Using the Python ‘map()’ Function to Process a List, With Examples

Using Python Map()

This article will explain the map() function in Python and show you how to use it. The Python map() function applies a given function for all items in an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over). The syntax and code in this article will work for both Python 2 and Python 3. Syntax for Python map() The map() function is built into Python, so nothing needs to be imported. Here’s the syntax: map(FUNCTION, ITERABLE) Note that: FUNCTION is a standard … Read more

Using the Python ‘reduce()’ Function to Aggregate Data, With Examples

Using Python reduce()

This article will show you how to use the Python reduce() function to aggregate data from values in an iterable (iterables are things like lists, dictionaries, sets, or tuples – collections containing items that can be looped over) and reduce them to a single accumulated value. The code and examples in this tutorial will work in Python 3. Syntax for Python reduce() functools.reduce(FUNCTION, ITERABLE[, INITIALIZER]) Note that: FUNCTION is a standard Python function, previously defined in your code It should accept two parameters The first parameter is the current accumulated value up until this point … Read more

PHP vs JavaScript – The Best Choice For Your Project

PHP vs JavaScript

PHP and JavaScript are the most commonly used programming languages on the web – so which one should you use for your project? Check out our recent article on JavaScript vs. Node.js for another commonly searched programming comparison. Choosing which programming language to use for a project is important. Some of the questions you’ll want to run through are: Where will the application be run, and which languages are supported in that environment? Do I already have knowledge of one of the languages being considered? … Read more

PHP Timezones- How to Set/Change Timezone, With Examples

Managing PHP Timezones

This article provides a combined tutorial for the PHP timezone functions, showing how to change the timezone globally or temporarily for a script/object. Timezones are a huge hassle. If your app has users from around the world, you’ll eventually run into the annoying task of ensuring that date handling works effectively for everyone – including the accuracy of times displayed and the format they are displayed in. PHP provides several tools to make timezone handling easier, allowing you to set the default timezone for the system, a … Read more

Categories PHP

Looping over Array using JavaScript forEach(), With Examples

JavaScript foreach

This article will show you how to use the JavaScript forEach() method to loop over an array. Pretty much any application of any complexity will require the looping over arrays (lists) of data. The JavaScript forEach() method, which is built into JavaScript array variables, does just this. You’ll be using it a lot – so thankfully, it’s pretty darn easy to use. JavaScript forEach() Syntax arr.forEach(callback(currentValue[, index[, array]]) { // execute something }[, thisArg]); Note that: arr is an array or a variable containing an array callback is the … Read more

TypeScript Vs JavaScript – What’s the Difference & Which Should You Use?

TypeScript Vs JavaScript

This article will discuss the differences between typescript and JavaScript, the problems they solve, and which is best to use. I really like TypeScript, and I use it a lot. It solves so many of JavaScript’s problems and makes writing good JavaScript code much easier (once you’ve learned to use TypeScript). So, this article is more about why you should use TypeScript (when you can use it), when/where you can use it, and the problems it solves. This article goes well with the following articles, giving you an … Read more