Let’s say I want to create a list of 10 numbers that are between the values of 0 and 1. This can be done with a simple for loop. For example: let length = 10; let max = 1; let randArray = []; for (i=0; i < length; i++) { randArray.push(Math.random(max)); } console.log(randArray); Setting the … Continue reading JavaScript: How to generate an array of random numbers
Month: February 2018
How to install PHP/MySQL and confirm the installation
The quickest way I found to install PHP and MySQL was to download the Bitnami WAMP stack module, which also installs a fresh Apache 2 server. See: https://bitnami.com/stack/wamp The installer I found for Windows 10 was called “bitnami-wampstack-7.1.14-0-windows-x64-installer.exe”. In running the installation, Bitnami creates a folder for apache2, php, and mysql here: C:\Bitnami\wampstack-7.1.14-0 Bitnami also … Continue reading How to install PHP/MySQL and confirm the installation
JavaScript: How to use the conditional ternary operator
In addition to “normal” comparison operators (see the links below), JavaScript has a unique comparison operator that can assign values rather than just return a boolean true or false. This is called the “Conditional (Ternary) Operator”. It follows this syntactical construction: variablename = (condition) ? value1 : value2 The question mark means: If the condition … Continue reading JavaScript: How to use the conditional ternary operator
Apache: How to change the server name from localhost to custom name
I recently installed the Bitnami WAMP stack which simultaneously installs Apache 2, PHP, and MySQL. The default domain name when installing Apache server is either “localhost” which is found at the default IP address of 127.0.0.1. For example, web pages can be found at: http://localhost/ http://127.0.0.1/ and scripts in the cgi-bin can be accessed like … Continue reading Apache: How to change the server name from localhost to custom name
How to install Perl and confirm the installation
To install Perl on Windows 10, I went to perl.org and followed the links to get to the Windows Binaries, where I clicked a link to download ActivePerl. The name of the file that was downloaded was ‘ActivePerl-5.24.3.2404-MSWin32-x64-404865.exe’. Then I installed Perl by clicking the .exe. Note: On one of the installation screens I chose … Continue reading How to install Perl and confirm the installation
HTML & CSS: How to get text to appear over an image on hover
I have an image on a web page that I want to display a text message whenever the mouse pointer hovers over the image. For example, I want to display the text “Placeholder Image” whenever the mouse pointer hovers over the image. The image itself is round with a blue border. This was styled with … Continue reading HTML & CSS: How to get text to appear over an image on hover
HTML: How to get vector icon images into your web page using Font Awesome
FontAwesome is a website where you can get free vector Icon images for your website. As described on their “get-started” page, they offer a CDN (Content Delivery Network) URL that you can place into your web page and the SVG icons will be loaded asynchronously into the page: https://fontawesome.com/get-started Here is what the CDN would … Continue reading HTML: How to get vector icon images into your web page using Font Awesome
HTML: How to get random stock images on your web page using unsplash.com
The website https://unsplash.com provides a free service that allows web developers to use random images of any size on their websites. All you have to do is place a URL like this in your HTML img tag, with the size of the image listed at the end of the URL. For example, this will produce … Continue reading HTML: How to get random stock images on your web page using unsplash.com
CSS: How to use the display property
Here is what w3schools.com says about the CSS display property: The display property specifies the display behavior of an element. Note: Every element on a web page is a rectangular box. The CSS display property determines how that rectangular box behaves. There are multiple settings that can be used with the CSS display property. Here … Continue reading CSS: How to use the display property
CSS: How to define and use variables
CSS has a mechanism that allows you to set up custom properties and then use them in CSS definitions as if they are variables. For example: /* CSS Variables */ :root { –primary: #fff; –dark: #333; –light: #fff; –shadow: 0 1px 5px rgba(104, 104, 104, 0.8); } When defining CSS variables, there are two syntactical … Continue reading CSS: How to define and use variables