editor.js – a web-based WYSIWYG editor that outputs JSON

Many web developers are familiar with online editors like TinyCME. If you’ve edited a blog post in WordPress using the classic editor, then you know what I mean.

The problem with this type of editor is it’s too easy to accidentally output garbage HTML. WordPress has switched to offering a block style editor.

If you need to create a similar editor for your web project, editor.js offers inline block-style editing and it outputs clean data in json format.

Here’s a screenshot of example JSON output which can then be used with

This JSON data can then be used with a templating language like Handlebars to build web pages.

Need Icons For a Website? Use FontAwesome!

Icons make a big difference in the look of a website. When placed beside text links, they make the links stand out. They can be used to replace text links, especially on mobile. They accompany text to make boring, text heavy pages easier to read. But, finding icons or creating them can be difficult. FontAwesome solves this by offering thousands of icons that are easily searchable. If I search for car, here’s what I see.

To use an icon, e.g. of a car, just paste this HTML code.

<script src="https://kit.fontawesome.com/8758af3809.js" crossorigin="anonymous"></script>

<i class="fas fa-car"></i>

Here’s a demo.

Batch Search and Replace in VisualStudio Code

Have you ever needed to do search and replace multiple times against the same file or set of files. If so, the Batch Replacer extension for VisualStudio Code makes this very simple.

  1. Open a folder or file in VisualStudio Code
  2. Create a new file (no need to save it) and enter some search and replace instructions, e.g.

In the example above, I want 3 different replacements done in the order shown and I only want the replacements done to a specific file. The “in” command is followed by the path of the file relative to the root of the workspace open in VS Code. If the file is open, you can get it by right clicking on its tab and selecting “Copy relative path”.

3. Execute the replacer script

To run the batch replacements, you active tab must be the tab containing your replacement instructions. Then, hit CTRL+SHIFT+P -> Batch Replace. A status window will appear in the bottom right corner telling you how many files have been modified. If you want to batch replace across all files in your workspace, don’t include the “in” instruction.

Get Silky, Shiny, Soft, Smooth and Frizz-free Hair

A few years ago I tried a product called Leave-in Hair Treatment with Argan Oil by HSI Professional. It came in a red box and bottle.

You just dab a little in the palm of your hand and massage it through your hair and it instantly makes your hair look and feel better. The ingredients are

Cyclopentasiloxane
Dimethicone Crosspolymer,
Argania Spinosa (Argan) Oil,
Fragrance (Parfum)
D&C Red #17 (CI 26100)
D&C Yellow #11 (CI 47000)
Benzyl Benzoate
Benzyl Salicylate
Amyl Cinnamal
Benzyl Salicylate
Butylphenyl Methylpropional
Geraniol
Hexyl Cinnamal

Unsurprisingly, it got many good reviews on Amazon.

Unfortunately, this product has been replaced with a similar but slightly different product. It’s good but definitely not as good as the original formula.

The ingredients are

Cyclopentasiloxane
Cyclotetrasiloxane
Dimethicone Crosspolymer,
Argania Spinosa (Argan) Oil,
Fragrance (Parfum)
D&C Green #6 (CI 61565)
D&C Red #17 (CI 26100)
D&C Yellow #11 (CI 47000)
Benzyl Benzoate
Hexyl Cinnamal
Lillial

The new formula has the same ingredients as the old formula except it’s missing the following

Benzyl Salicylate
Amyl Cinnamal
Benzyl Salicylate
Butylphenyl Methylpropional
Geraniol

To understand the difference and find products that are just as good, if not better, here is a list of products that have similar ingredients. Note that the percent amount of each ingredient is in descending order.

Leave-in Argan Oil Treatment by Dermorganic

Cyclopentasiloxane
Dimethicone
Organic Argania Spinosa (Argan) Kernel Oil
Organic Vitis Vinifera (Grape) Seed Extract
Tocopheryl Acetate (Vitamin E)
Organic Helianthus Annuus (Sunflower) Seed Extract
Glycereth-2 Cocoate/Benzoic Acid
Parfum/Fragrance

http://www.dermorganic.com/shop/index.php?main_page=product_info&cPath=1&products_id=5

https://www.amazon.com/DermOrganic-Leave-Argan-Oil-Treatment/dp/B0057OU50E/

Kiehl’s Smoothing Oil-Infused Leave-In Concentrate

https://www.kiehls.com/skincare/travel-size-products/smoothing-oil-infused-leave-in-concentrate/3605970914455.html

Cyclopentasiloxane
Dimethiconol
Parfum fragrance
Argan Oil
Orbignya oleifera oil
Linalool
Benzyl salicylate
Hexyl cinnamal
Benzyl alcohol
Coumarin
Limonene
Eugenol
Isoeugenol

Agadir Argan Oil Hair Treatment

Cyclopentasiloxane
Dimethicone
Cyclomethicone
Argania Spinosa (Argan) Kernel Oil (Argan)
Caprylyl Methicone
Phenyl Trimethicone
Fragrance (Parfum)

https://agadirint.com/products/4-oz-agadir%C2%AE-argan-oil-hair-treatment

https://www.amazon.com/AGADIR-Argan-Oil-Treatment-Oz/dp/B001U9M2EW

Moroccanoil Treatment

Cyclomethicone
Dimethicone
Argania Spinosa (Argan) Kernel Oil
Fragrance
Linum Usitatissimum (Linseed) Seed Extract
CI 26100 (Red 17)
CI 47000 (Yellow 11)

https://www.amazon.com/MO100ML-Tratamiento-Moroccanoil/dp/B001AO0WCG/ref=sr_1_1_sspa

One ‘n Only® Argan Oil Oil Treatment

Dimethicone
Cyclopentasiloxane
Dimethiconol
C12-15 Alkyl Benzoate
Fragrance (Parfum)
Argania Spinosa Kernel Oil
Red 17 (CI 26100)
Yellow 11 (CI 47000)

https://www.amazon.com/One-Only-Argan-Treatment-Ounce/dp/B004Q0BIFQ/ref=pd_lpo_194_t_2/136-1507301-2060236

Hask Argan Oil Repairing Shine Hair Oil

Cyclopentasiloxane
Dimethiconol
Argania Spinosa (Argan) Kernel Oil
Keratin Amino Acids
Glycine Soja (Soybean) Oil
Vitis Vinifera (Grape) Seed Oil
Citrus Aurantium Dulcis (Orange) Oil
Tocopherol
Aqua/Water/Eau
Peg-4 Laurate
Peg-4 Dilaurate
Lodopropynyl Butylcarbamate
Peg-4
Butylene Glycol
Phenoxyethanol
Ethylhexylglycerin
Citral
Limonene
Linalool
Ci 26100 (Red 17)
Ci 47000 (Yellow 11)

https://www.amazon.com/Hask-Repairing-Shine-Argan-Ounce/dp/B01EUNA3VS/ref=sr_1_2

Redken All Soft Argan-6 Oil

Cyclopentasiloxane
Dimethiconol
Dimethicone
Argania Spinosa Oil/Argania Spinosa Kernel Oil
Parfum/Fragrance
Benzyl Alcohol
Linalool
Coumarin
Limonene
Hexyl Cinnamal
Citronellol
Benzyl Benzoate
Amyl Cinnamal (D159206/2)

https://www.amazon.com/Redken-Soft-Argan-6-Multi-Care-Ounce/dp/B005KL2IAY/ref=sr_1_3

Ingredient functions

The information below was obtained from https://cosmeticsinfo.org/.

Cyclomethicone, Cyclotetrasiloxane, Cyclopentasiloxane

Detangle your hair, prevent breakage, and reduce frizz

Other names: D5, decamethylcyclopentasiloxane, cyclomethicone

Dimethicone, Dimethicone Crosspolymer, Dimethiconol, Dimethiconol

Hair fixative, viscosity increasing agent

Argan Oil

You can apply argan oil directly to damp or dry hair to improve moisture, reduce breakage, or reduce frizz.

Benzyl Benzoate, Benzyl Alcohol, Benzyl Salicylate, Amyl Cinnamal, Butylphenyl Methylpropional, Geraniol, Hexyl Cinnamal, Amyl Cinnamal, Lillial, Glycereth-2 Cocoate/Benzoic Acid, Linalool, Coumarin, Limonene, Eugenol, Isoeugenol, Citral, Citronellol

Fragrance

Organic Vitis Vinifera (Grape) Seed Extract (Oil), Organic Helianthus Annuus (Sunflower) Seed Extract (Oil)

Viscosity increasing agent, skin conditioning agent

Tocopheryl Acetate (Vitamin E), Orbignya oleifera oil, Caprylyl Methicone, Linum Usitatissimum (Linseed) Seed Extract (oil), C12-15 Alkyl Benzoate, Glycine Soja (Soybean) Oil, Citrus Aurantium Dulcis (Orange) Oil, Tocopherol

Skin conditioning agent

Phenyl Trimethicone

Phenyl Trimethicone reduces the tendency of finished products to generate foam when shaken. It also enhances the appearance and feel of hair, by increasing hair body, suppleness, or sheen, or by improving the texture of hair that has been damaged physically or by chemical treatment. Phenyl Trimethicone slows the loss of water from the skin by forming a barrier on the skin’s surface.

Keratin Amino Acids

Used for conditioning, moisturizing, known to make hair glossy, give it more body, and also for its marketing appeal (natural ingredient as well as hair is made from this). It’s a strong humectant, and pulls water into the hair. 

Peg-4 Laurate, Peg-4 Dilaurate

They also clean the skin and hair by helping water to mix with oil and dirt so that they can be rinsed away.

Lodopropynyl Butylcarbamate, Phenoxyethanol

Prevents or retards bacterial growth, thereby protecting cosmetics and personal-care products from spoilage.

Butylene Glycol

Solvents, viscosity decreasing agent

Ethylhexylglycerin

Deodorant, skin conditioning agent

Create a Time Lapse Video Using Smartphone (Android)

Creating a time lapse video is great for quickly showing changes that happen over a long period of time, e.g. the sky changing from day to night. I recently made a time lapse video of a pergola construction project using an Android app called Framelapse. It’s a very simple app which takes pictures at a user-specified interval over a set period of time or until you stop recording. What’s great is this method doesn’t fill up your phone by taking an actual video at the normal frame rate of 30 frames per second. For my first timelapse video, I chose a frame interval of 4 seconds. When I stopped recording, the timelapse video was instantly done and available in my Google Photos app and backed up to Google Photos in the cloud. I added some background music and I was done. Here’s the final video.

Easily Find and Remove Duplicate Files in Windows 10

I’ve decided to move move and back up files files in the cloud. This includes moving all photos to Google Photos. Apparently, I had many duplicate photos in different folders that needed to be reorganized and deduped. Fortunately, CCCleaner makes finding and duplicating files of any time free, safe and easy. As you can see in the screenshot below, you can compare files and mark which ones to remove before removing them. There are many filters and controls so you can customize the search.

Test Rest APIs Using Postman

Testing HTTP connections and Rest APIs can easily be done using Postman. This handy tool allows you to provide HTTP headers, among many other things, to test connections and view responses.

Here’s a test of querying a Rest API from restdb.io. The query URL is https://testdb-cd69.restdb.io/rest/people. For authentication, an HTTP header called “x-apikey” is provided with its value (redacted). The response from the call is in the body panel in JSON format.

Restdb.io – Super Simple, Low Code CMS and Database Backend for Web Apps

If you need a quick and easy way to create a CMS (content management system) or a database backend for an app, then Restdb.io will amaze! Here are some features:

  • super developer-friendly with crystal clear documentation
  • affordable and even has a free plan
  • example code for popular programming languages, including client side JavaScript and server side NodeJS, which makes it quick to get up and running
  • webhooks whenever a record is created, updated or deleted
  • codehooks to run custom code before and after a record is created, updated or deleted, e.g. for data normalizing and validation. codehooks also support scheduled tasks like cron jobs.
  • auto-generate test data to seed a table
  • ability to import data from a CSV file
  • native and custom field validation
  • non-technical users can log in and add/edit/delete records using intuitive forms and controls without seeing any developer features
  • ability to upload and host images and files

Below is a tutorial on how to create a simple CRUD (Create, Read, Update, Delete) app using Restdb.io with a PHP backend.

1. Log in to Restdb.io account and create a table (collection)

After you log in, you’ll need to be in Developer Mode to create a table. When creating fields in the table, Restdb.io offers numerous field property options including native and custom field validation.

2. Add or import data

To populate the table, you can

  • Add data field by field, row by row
  • Import data from a CSV file
  • Auto-generate data by clicking on the Test Data tab

Using the Test Data option, I chose to generate 5 rows which gave me this.

3. Get sample CRUD code

Click on [Table] > API Docs and choose a language to see sample code for

  • getting records (using HTTP GET method)
  • creating a record (using HTTP POST method)
  • update a record (using HTTP PUT method)
  • delete a record using (HTTP DELETE method)

PHP

The sample PHP CRUD code provided by RestDB.io requires the use of the HttpRequest PEAR PECEL HTTP_Request extension. To avoid having to install this dependency, you can just use cURL which is included with PHP.

NodeJS

Below is a screenshot using NodeJS using the Request library.

JavaScript using jQuery AJAX

You can also perform CRUD actions using client-side JavaScript but you need to set up CORS (cross-origin resource sharing). The example below shows JavaScript using jQuery AJAX.

For client-side JavaScript, you need to generate a CORS API key. The screenshot below shows a CORS API key (redacted) that allows connections from any origin server but only allows the GET method to read data.

In the screenshot above, the API key would only work for the “people” table / collection. To have one key work for all tables / collections, use “/**” instead.

4. PHP: Create a file to test reading from the database

I created a test file called read-curl.php which uses cURL to connect to the remote database.

After uploading it to my web host, opening the file in a browser shows me the data in JSON format, as expected, which you can see live at http://zabuun.com/restdb.io/read-curl.php

You can also test the API by installing Postman (free), entering a query in the form of a REST URL, and entering your API key as an HTTP header.

4. JavaScript (jQuery + AJAX): Create a file to test reading from the database

I created a test file called read.html with the following code. This code uses the CORS key for cross-origin resource sharing.

After uploading it to my web host, opening the file in a browser shows me the data in JSON format, as expected, which you can see live at http://zabuun.com/restdb.io/read.html

If you have JSON data as in the example above, you can use Handlebars.JS to format the output in HTML.

5. Query data

When reading data from RestDB , you will often want to filter data based on conditions rather than retrieve an entire collection (all records). RestDB supports many MongoDB-like query syntax. Read the docs. Here’s an example of RestDB queries for equivalent relational DB SQL queries.

SQLRestDB
SELECT * FROM usershttps://<db-name>.restdb.io/rest/users?q={}
SELECT id, user_id, status FROM users/rest/users?q={}&h={"$fields": {"user_id": 1, "status": 1} }
SELECT * FROM users WHERE status = “A”/rest/users?q={ "status": "A" }
SELECT * FROM users WHERE status != “A”/rest/users?q={"status":{"$not":"A"}}
SELECT * FROM users WHERE status = “A” AND age = 50/rest/users?q={ "status": "A", "age": 50 }
SELECT * FROM users WHERE status = “A” OR age = 50/rest/users?q={ "$or": [ { "status": "A" } ,{ "age": 50 } ] }
SELECT * FROM users WHERE age > 25/rest/users?q={ "age": { "$gt": 25 } }
SELECT * FROM users WHERE age < 25/rest/users?q={ "age": { "$lt": 25 } }
SELECT * FROM users WHERE age > 25 AND age <= 50/rest/users?q={ "age": { "$gt": 25, "$lte": 50 } }
SELECT * FROM users WHERE user_id like “%bc%”/rest/users?q={ "user_id": {"$regex" :"bc"}}
SELECT * FROM users WHERE user_id like “bc%”/rest/users?q={ "user_id": {"$regex" :"^bc"}}
SELECT * FROM users WHERE status = “A” ORDER BY user_id ASC/rest/users?q={ "status": "A" }&sort=user_id&dir=1
SELECT * FROM users WHERE status = “A” ORDER BY user_id DESC/rest/users?q={ "status": "A" }&sort=user_id&dir=-1
SELECT COUNT(*) FROM users/rest/users?q={}&h={"$aggregate":["COUNT:"]}
SELECT COUNT(*) FROM users WHERE age > 30/rest/users?q={"age":{"$gt": 30}}&h={"$aggregate":["COUNT:"]}
SELECT * FROM users LIMIT 1/rest/users?q={}&max=1
SELECT * FROM users LIMIT 5 SKIP 10/rest/users?q={}&max=5&skip=10

You can also aggregate data, e.g. min, max, avg, count, groupby, etc, using aggregation and grouping functions. Read the docs.

If you already have an entire JSON dataset and you want to query against it, you can use JSONata. JSONata is a lightweight query and transformation language for JSON data. 

6. Auto-generate a web form

If you want to create a web form for public use, you can have restdb.io auto-generate one for you, complete with JavaScript validation and code to publish the data to your restdb.io database. See an example at

http://zabuun.com/restdb.io/form.html

7. Filesystem

Below is a screenshot of my remote filesystem on a shared GoDaddy server. The error.log file is auto-generated.

8. Create users with editor access

If you work with other developers or editors, you can give them role-based access to your restdb.io account to manage data. An editor, for example, will not see the developer features and can simply add records using a user-friendly web form like shown below.