Home » Articles by: Brad Morton

LinuxScrew’s Linux Shell/Bash Scripting Tips

Bash script hot tips

Here are some handy tips to keep in mind when writing your shell scripts in Linux. Shell scripts are a versatile way to automate your workflows in Linux (and MacOS, and now Windows, with the Windows Subsystem for Linux). Shell scripting syntax and behaviour does have its quirks, and there are useful shortcuts you can take as well to simplify your scripts. Bash Scripting Tips These tips are collected from around the internet, with a few of my own thrown in. Bash scripts will keep … Read more

Home » Articles by: Brad Morton

How to Generate the Fibonacci Sequence of Numbers in Python

This quick tutorial will show you how to generate the Fibonacci sequence of numbers in Python. This is a useful example for new coders and those just learning Python as it shows how variables, loops, and arithmetic are used in Python. What is the Fibonacci Sequence The Fibonacci sequence is a procession of numbers in which each number is the sum of the preceding two numbers. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144… Above, the first 13 numbers in the Fibonacci … Read more

Home » Articles by: Brad Morton

Linux Tip: Free Self Hosted Cloud Desktops Using Linux and TailScale

This article will show you how to build your own cloud desktop environment. Virtual desktops have become a popular way to make your work space portable. You can leave all of your applications running in the cloud, and log into your desktop from anywhere and resume work. Here’s how you can build your own cloud desktops, for free. Google, Amazon, Microsoft, and other vendors all provide cloud-based virtual desktop solutions, but the costs can quickly add up. By using a VPN and some virtualisation software, … Read more

Home » Articles by: Brad Morton

Converting String to Boolean in JavaScript, With Examples

This tutorial will show you how to convert a string value to boolean in JavaScript, with working code examples for several situations. Why Are You Converting Strings to Booleans? Really, you should not be storing boolean data in a string, but there are several scenarios where it can arise: Boolean values arising from user input Values taken from HTML form elements, which can only contain string values Data taken from poorly formatted third party sources, like APIs or CSV files Once you have data containing … Read more

Home » Articles by: Brad Morton

Using the JavaScript toUpperCase() String Method [Examples]

This article shows how the toUpperCase() method is used in JavaScript to make all letters in a string UPPER CASE. The toUpperCase() method is included in the string object and is fully supported in all browsers. In the JavaScript programming language, strings can either be a primitive or an object – primitives are the most basic kinds of variables – they have no methods, and simply represent the raw data for the given characters. String objects, however, have additional methods for manipulating and measuring the string – the toUpperCase() is one of these helpful methods. String variables in … Read more

Home » Articles by: Brad Morton

Linux Tip: Using visudo to Avoid Costly Mistakes

Linux Tip: Use visudo to Edit the sudoers File to Avoid Costly Mistakes This article will show you how to use visudo to edit the sudoers file to grant root access to users – and protect against making mistakes that could lock you out of your Linux system forever. What is the sudoers File? The sudoers file defines which users have access to the sudo command on Linux systems. The file is located at: /etc/sudoers …and it looks like this: # # This file MUST be edited with the ‘visudo’ command as root. # # … Read more

Home » Articles by: Brad Morton

How to Create and Use JavaScript Classes [Examples]

This tutorial will explain JavaScript classes and how they relate to objects. Syntax and code examples are provided. But first, a quick refresher on JavaScript objects. JavaScript Objects In JavaScript, objects are a container for a set of properties and methods. A car, for example, could be modelled as an object. It could have properties describing the manufacturer, year it was made, and the colour. Methods are functions which are part of the object, which when called, interact with the object in some way. A car might have a honk method which triggers an alert, … Read more

Home » Articles by: Brad Morton

How to Check if a Variable is a String in JavaScript

This quick tip will show you how to check if a variable is a string in the JavaScript Programming Language. What is a String? A string is a type of variable. A variable type determines what values a variable can contain and what can be done with the variable. Strings are a series of characters – letters or numbers or symbols. They can be joined, split, and iterated over. Strings are used to store words, sentences, and other non-numeric data like encoded images or serialized data which is going … Read more

Home » Articles by: Brad Morton

JavaScript Functions Tutorial, With Examples

Functions are reusable bits of code which are encapsulated so that you can easily call them by name when you need them. Here’s how they work in JavaScript, with examples. What are Functions? When programming, you will need to perform the same set of actions multiple times on different data. For example, you may need to perform a calculation on all of the rows in a table, or update the values in a list of objects. It is not wise, or practical, to re-write the same … Read more

Home » Articles by: Brad Morton

Current Time in Another Location/Timezone [JavaScript]

This article will demonstrate how to get the current time in another location/timezone in Javascript, with just one line of code. The Simplest Pure-JavaScript Way The below function converts a given date to a different timezone, and contains just 1 line of code. function timezoneConvert(date, tzString) { return new Date((typeof date === “string” ? new Date(date) : date).toLocaleString(“en-US”, {timeZone: tzString})); } This function expects: A date, as either a Date object or string A string containing the name of the timezone to convert to This … Read more

Exit mobile version