Get the number of CPU cores in Node.js

May 28, 2020 Goodman

Node has a built-in module called os that can help you find out how many cores your CPU has. Example:

Excluding node_modules when using tree command on Mac

May 28, 2020 Goodman

The node_modules folder is often super big and contains countless files and subdirectories. Therefore, when using the tree command to display your project structure, you should ignore node_modules. To do so, try this: The result: If…

PHP array_push examples

May 23, 2020 Goodman

The array_push function in PHP pushes the input variables onto the end of the given array. Note that the input variables can be string, number, array… Example 1 Code: Output: Example 2 Code: Output:

React Native ImageBackground examples

May 7, 2020 Goodman

A few examples on how to use ImageBackground in React Native. Example 1: Full screen image background Result: Example 2: Using resizeMode Note: resizeMode and style are at the same level. What you should see when…

PHP array_filter() examples

May 5, 2020 Goodman

The array_filter() function in PHP, as its name so precisely explains, is used to filter elements of an input array using a callback function. The flag argument is optional. Its default value is 0 and will…

PHP array_slice examples

May 5, 2020 Goodman

The array_slice() function (available in PHP 4, PHP 5, PHP 7) is used to extract a slice of a given array. It returns a new array that contains elements from the input array as specified by…

Xampp on Mac: Permission denied error fix

May 4, 2020 Goodman

After installing Xampp (even the latest version) on your Mac, you may face some errors related to permissions when working with files (uploading files, resizing images…). The most common output you could see will look like…

PHP: Generating a random number between Min and Max

May 3, 2020 Goodman

In order to generate a random number within a given range, you can use the rand() or the mt_rand() functions. They are both built-in features in PHP (4, 5, 7). Example: Note: mt_rand() is 4 times…

[PHP 7] Merging arrays with array_merge() and spread syntax

May 3, 2020 Goodman

In order to merge arrays in PHP, you can use the spread syntax (AKA argument unpacking, splat operator) or the array_merge() method. A few examples below will help you understand clearly. Notes: If the input arrays…

3 great libraries to create pie charts in React (including examples)

April 30, 2020 Goodman

There are various libraries out there to help you create a beautiful pie chart (AKA circle chart, pie graph e.t.c) in React without any pain. victory-pie A very-easy-to-use chart drawing library. Example Install victory-pie by executing:…

Express: Automatically download an image when clicking a link

April 30, 2020 Goodman

The simple project below will show you how to automatically download an image served from Express server when clicking a link. Our project structure: The code in app.js (don’t forget to install express before running your…

React Native: Alert example & explanation

April 28, 2020 Goodman

Alert is a commonly used API in React Native which can launch a dialog with title, message, and buttons. Example and explanation Create a new React Native project with React Native CLI or Expo, then replace…

React Native: No bundle URL present

April 28, 2020 Goodman

I am using React Native 0.62.2, Xcode 11.4, macOS 10.15.4 (Catalina), the latest version of VS Code, and Node 14. The deadly screen appears when I run: I also notice that the Metro terminal doesn’t launch…

React Native 0.62: KeyboardAvoidingView example

April 25, 2020 Goodman

KeyboardAvoidingView is a core component in React Native. This component makes sure the virtual keyboard will never cover the TextInput component so that you can type without annoyance. Without KeyboardAvodingView: With KeyboardAvoidingView: Full example The KeyboardAvodingView…

React Native ActivityIndicator examples

April 23, 2020 Goodman

A few easy-to-understand examples of how to use the ActivityIndicator API in React Native. The First Example Displaying a loading indicator. The Second Example In this example, we’ll create a simple React Native app that has…

React Native: Opening a website URL with the default browser

April 23, 2020 Goodman

This article will show you how to open a website URL with the default device’s browser in a React Native app. There is no <a> tag in React Native and to open a web link in…

React Navigation 5: A basic example

April 22, 2020 Goodman

A simple, concise example below will help you understand how to use React Navigation 5 in a React Native project, regardless you’re a fan of React Native CLI or a loyal Expo user. Create a completely…

1 2