Managing loading status for React is much easier with loadio

Managing loading status for React is much easier with loadio

Introduction

Many projects contain asynchronous calls. The operation of these may be unaware of the user, or the user may need to know about that status. 

In order to notify the user of this, the loading component is shown on the screen and the user is informed that something is running. At this point, the management of asynchronous methods should be managed in various ways and the component should be demonstrated.

Today, I will show you how you can handle this in an easy way with loadio.

loadio

This package is a simple to use tool that allows you to manage status information with promises.

Install it with:

Wrap the method you want to follow the status information.

Or add promise directly into it with PoolManager

And that’s all. You can easily view the status on your home page by calling the new method you have wrapped in place of the old one.

It also generates a percentage of information according to the number of tasks.

A complete example with React Component is as follows.

Demo

@Credit Dev.to

20 useful free resources for Web Developers

20 useful free resources for Web Developers

Checkout some useful resources for Web Developer

1.  HTML and CSS Free Templates

2.  The Modern JavaScript Tutorial

3.  JavaScript questions

4.  JavaScript Cheat Sheet

5.  Squarespace logo Maker

6.  Flexbox Defense

7.  Grid Garden

8.  100 Free Illustrations

9.  Curated Colors in Context

10. Learn Git Branching Interactively

11.  Free Image and Photo Resizer

12.  Public APIs

13.  Lorem Picsum

14.  Responsively

15.  Website Speed test

16.  Dev fonts 

17.  Codeimg

18.  Generative Placeholders

19.  Wireframer

20.  Git Command Explorer

@Credit https://dev.to/pascavld/20-useful-free-resources-for-web-developers-2c3n

Apache Install and Running PHP 5.6 / PHP 7.2 on the Centos 7 x64

Apache Install and Running PHP 5.6 / PHP 7.2 on the Centos 7 x64

In this tutorial we will set up multiple PHP Versions which is 5.6 & 7.2 on the Apache same machine.

it’s very practical and common to have multiple php versions and run it simultaneously with apache on a single server. Maybe you have a php script and want to test it with multiple php version. in such case this article is for you.

 

1- Install prerequisites

before installing and running two php versions, we need to install apache and some repository. so execute these commands:

2- Install multiple php versions

php-fpm is available in remi repository. so we install this repo and then after multiple php versions:

3- Configure SELinux

Install Selinux Policy Targeted

to allow selinux run php-fpms scripts, run these commands:

4- Configure php-fpm

by default, each php-fpm version is listening on port 9000. because we want to run multiple php versions, we need to change default port:

Start the php-fpm

now we need to make script wrapper to call php56-cgi and php72-cgi:

Then we set executable bit on both scripts:

5- Configure apache

Here we create two path. one for php-fpm56 and another for php-fpm72. you can change these paths with your own:

Php7.2 /var/www/html

Php5.6 /var/www/html56

Edit conf file /etc/httpd/conf.d/php.conf

gt;
SetHandler “proxy:fcgi://127.0.0.1:9072”
</FilesMatch>
# Some legacy application use PHP 5.5
<Directory /var/www/html56>
<FilesMatch \.php

gt;
SetHandler “proxy:fcgi://127.0.0.1:9056”
</FilesMatch>
</Directory>

6- Start services

Now we enable and start apache and php-fpm services:

7- Check for result

 

Good luck! All Done

5 curated frontend UI kits for your next web app

5 curated frontend UI kits for your next web app

Frontend UI kits enable developers to quickly launch digital products without having to consider the design language surrounding their coded components. They also enable UX designers to quickly iterate on product flows and test options during the MVP stage of product development.

Most great startups don’t find their perfect design language or color palette on their first iteration. With time and much customer feedback, those things fall into place as a product is assigned value by the market.

During the early MVP (minimum viable product) days, having a way for both the UX design side, and the coding side to quickly combine their efforts in a unified way increases group performance ten fold. UX kits provide that role.

Below, I’ve curated some of the best options currently available on the market, along with the pros and cons of each to help you better choose amongst them. At the end, I’ve also given you a custom option that, while initially time consuming, will enable you to create your own custom, quick-start UI kit for any future projects you begin.

Shards by Design Revision

Price: Free & Premium
Framework: Bootstrap 4
Available for: Vue, React, Bootstrap HTML

(The FREE version includes some components that are NOT in the PRO version, so reference the demos of both if you are looking for something specific)

 

Pros:

  • Beautiful use of color, shadow and white space. Overall, this is one of the best-looking UI kits I’ve seen with many well-considered details
  • Includes a Sketch design file
  • Having personally used this in a few projects already, I can say that the documentation is robust and very easy to use
  • Plenty of components and layouts. Everything is easy to customize for whatever kind of web app you want to build. Components include a text editor, file management, blog layout, and many others

Cons:

  • Code is not quite as flushed out as some other options, but good developers probably won’t mind this
  • Sketch design file does not utilize symbols or responsive layout features

Xtreme Vuesax by WrapPixel

Price: Free & Premium
Framework: Bootstrap 4
Available for: Vue, React, Angular, Bootstrap HTML


 

Pros

  • Based on Vuesax, so you get the power of that kit and their user community of components out of the box
  • Includes light, dark, and color-based themes
  • Many components, including a drag-n-drop Trello-style UI and a form wizard for quick multi-page form creation
  • Some of the most comprehensive tables I’ve seen. If your app is table-heavy, definitely check this one out
  • Component code is quite extensive and not just stubbed out like many other kits
  • Quick-reference icon library

Cons

  • This isn’t the prettiest kit out there, but with a bit of customization you should be able to tailor it to your own style
  • Based on Vuesax (that’s right, it’s a pro and a con). According to Vuesax’s on website, it isn’t recommended to be used in a production level app, however depending on what you’re building, this still seems like a viable option, or a good choice for an MVP. Do your research and make the correct choice accordingly.

Element

Price: Free
Framework: Bootstrap 4
Available for: Vue, React, Angular

 

Pros

  • Create and download custom themes via their website
  • Includes a Sketch design file
  • Lots of components, including some that other kits lack, like form steps and file upload components
  • Includes animations with clean transitions
  • List rendering options including infinite scroll with smart loading
  • Utility naming is short and easy to remember
  • Available in ScaffoldHub which quickly generates project structures

Cons

  • Default language is Chinese. Setting to English requires some i18n settings
  • Doesn’t have much in the way of pre-made layouts or structured pages
  • Sketch design file does not utilize symbols or responsive layout features

Evergreen by Segment

Price: Free
Framework: UIBox (segment’s own CSS-in-JS framework)
Available for: React

 

Pros

  • Visual design is clean and simple
  • Minimal set of components
  • Created by Segment, meaning it will likely continue to be updated
  • Includes a Sketch design file

Cons

  • No pages or layouts included, just basic components here folks
  • Fairly verbose component names
  • Customization is somewhat limited on components like tables

Rebass

Price: Free
Framework: Reflexbox (Rebass’s own grid system)
Available for: React

 

Pros

  • Minimal kit of only essential components
  • Includes dark mode options
  • Increases the maintainability of visual styles
  • Stateless, functional UI components
  • Supports theming

Cons

  • Some devs may not like Reflexbox, but there are simple ways around that
  • Rebass’ CSS-in-JS styling may not be for everyone (it’s not for me)

Bonus #1:

Build Your Own (with a kickstart)

Price: Spend time now, save time later
Framework: Custom
Available for: Everything (!)

If you want to build quickly and launch your product ASAP, definitely go for a proven UI kit, especially if design isn’t on your list of skill sets.

However, after you’ve had experience with a few kits and understand how they work, I would urge you to move on to a minimal framework with which you can build out something to fit your unique needs. At the very least, you’ll learn a tremendous amount from the experience.

There are plenty of minimal, JS framework-agnostic CSS frameworks available for your choosing. SkeletonPureCSSMiniCSS, or Milligram are all great. However, there were things I both liked and disliked of each. One of the dislikes being the inclusion of a grid system.

Why? Because these days CSS Grid is supported on nearly every browser, and is both incredibly powerful and easy to learn. If you aren’t familiar, I recommend you watch this talk by Rachel Andrews.

To get everything I needed without the things I didn’t, I decided to build my own open source minimal CSS framework. I call it Blueframe, and you’re welcome to download it from my Github. It includes CSS Normalize while using many of the utility class names of Bootstrap for easier adoption. If you’re familiar with Bootstrap’s classes, you already know how to use Blueframe.

Is it worth going fully custom?

While full UI kits save you time by providing tons of components to build with right away, you’ll also spend time ripping out the pieces you aren’t using. Build sizes will also be larger (meaning longer compile times), and overriding default styles is often a frustrating, and sometimes impossible task.

Building your own UI kit enables you to develop a unique style that fits your design preferences, rather than looking like every other app on the market. Evergreen and Rebass are a great place to start, but if React isn’t your thing, starting from scratch with Blueframe, Tailwind, Skeleton, or any other minimal frontend framework is a great idea.

Pros

  • Grows with you and your style
  • Easily customize new projects from a single master file, and never worry about fighting bootstrap or any other framework’s default styles again
  • Forget complex grid systems and do everything with CSS Grid
  • UI kits might come with curated packages already installed, but sometimes spending the time to choose your own for tables, animations, alerts, and other elements means you’ll be getting exactly what you want without any of the fluff

Cons

  • Time consuming to start, but pays off in the end
  • Maintaining your UI kit can take second chair to getting projects done. For some, it may not be worth the time, while others may find it more efficient in the long-run

@Credit UxDesign.CC

Centos7 Monit configure to monitor disk space usage detail report

Centos7 Monit configure to monitor disk space usage detail report

These steps will guide how to add Disk Storage monitor report into the Monit web access

First, you need to know which drive you want to be included into the Monit  report by following command

 

For example here I have one partition /dev/vda1 and I want to monitor it with the usage detail.

Update the Monit configuration file

Now open the monit config file by the path: /etc/monit.d/storagespace 

Create that file if it is not existed. Paste the following content

If you have multiple volumes, easy that clone those 2 lines in multiple breakdown. Note that Ubuntu is the optional name you want to be showed as alias name in report.

Done, save it.

Check and Restart Monit process

Check the configuration file is ok by command

It will output *Control file syntax OK* means fine, otherwise try to review again your config file.

Restart monit service

Check for status of service

 

So everything is fine, now point to web browser to access monit report, by default port is 2812 and your url will look like http://<host>:2812

 

The monit monitoring my disk right now, so click on it will go to details

 

Finished!

How to use Async Await in JavaScript.

How to use Async Await in JavaScript.

JavaScript is a bit like The Faceless Men of the programming world.

It can be Asynchronous. It can be Functional. It can be Object-oriented. It can be Client-side. It can be Server-side. The list goes on.

This article will focus on Asynchronous JavaScript.

But wait, JavaScript is a synchronous language!

This means only one operation can be carried out at a time. But that’s not the entire picture here. There are many ways JavaScript provides us with the ability to make it behave like an asynchronous language. One of them is with the Async-Await clause.

What is async-await?

Async and Await are extensions of promises. If you are not clear with the concepts of Promise, you can refer my previous post How to write Promises in JavaScript.

Async

Async functions enable us to write promise based code as if it were synchronous, but without blocking the execution thread. It operates asynchronously via the event-loop. Async functions will always return a value. Using async simply implies that a promise will be returned, and if a promise is not returned, JavaScript automatically wraps it in a resolved promise with its value.

Running the above code gives the alert output as 27, it means that a promise was returned, otherwise the .then() method simply would not be possible.

Await

The await operator is used to wait for a Promise. It can be used inside an Async block only. The keyword Await makes JavaScript wait until the promise returns a result. It has to be noted that it only makes the async function block wait and not the whole program execution.

The code block below shows the use of Async Await together.

Things to remember when using Async Await

We can’t use the await keyword inside of regular functions.

To make the above function work properly, we need to add async before the function firstAsync();

Async Await makes execution sequential

Not necessarily a bad thing, but having paralleled execution is much much faster.

For example:

The above takes 100ms to complete, not a huge amount of time but still slow.

This is because it is happening in sequence. Two promises are returned, both of which takes 50ms to complete. The second promise executes only after the first promise is resolved. This is not a good practice, as large requests can be very time consuming. We have to make the execution parallel.

That can be achieved by using Promise.all() .

According to MDN:

The Promise.all() method returns a single Promise that resolves when all of the promises passed as an iterable have resolved or when the iterable contains no promises. It rejects with the reason of the first promise that rejects.

Promise.all()

The promise.all() function resolves when all the promises inside the iterable have been resolved and then returns the result.

Another method:

Async Await is very powerful but they come with caveats. But if we use them properly, they help to make our code very readable and efficient.

I hope you have learned something new! If you found this article useful, be sure to share, clap, follow and support!

Credit @Medium