Monday, 25 October 2021

PHP chgrp function

chgrp(string $filenamestring|int $group): bool

Attempts to change the group of the file filename to group.

Only the superuser may change the group of a file arbitrarily; other users may change the group of a file to any group of which that user is a member.

PHP or syntax function

Let's just say that:

$result = first() || second();

will evaluate to:

if (first()) {
    $result = true;
} elseif (second()) {
    $result = true;
} else {
    $result = false;


$result = first() or second();

will evaluate to:

if ($result = first()) {
    // nothing
} else {

In other words you may consider:

$result = first() || second();

$result = (first() || second());


$result = first() or second();

to be:

($result = first()) || second();

It is just matter of precedence.

Thursday, 21 October 2021

JavaScript = Check if array contains at least one element of another array

    // Check if arra1 contains at least 1 element of arr2

const found = arr1.some(r=> arr2.includes(r))

some(..) checks each element of the array against a test function and returns true if any element of the array passes the test function, otherwise, it returns false. indexOf(..) >= 0 and

Wednesday, 20 October 2021

Javascript Decode encoded html entities in a JSON object into decoded ones 

HTML entities such as <p>In this course, you'll learn:</p> is usally encoded in JSON string as 

&lt;p&gt;In this course, you&amp;rsquo;ll learn:&lt;/p&gt; to avoid quots "" errors in JSON string

To decode HTML entites (to get <p>) back in JS so that it is properly shown in a web page(If do not decode HTML entities browser will show HTML tag <p> as text instead of having any effects),

we will need to utlize textarea, as getting values in text area will automatically be converted into decoded HTML entities

// Create globally used textarea

var domTextArea =  document.createElement('textarea');

// Function that takes a JSON object, and recursively decode encoded HTML entities if needed        

decodeHTML(testObj) {


            for (var key in testObj) {

                if (typeof (testObj[key]) == 'string') {

                    domTextArea.innerHTML = testObj[key];

                    testObj[key] = this.domTextArea.value;






NOTE: for (var key in testObj) will also work for array :

var a = [1,2,3];

for (var key in a) { console.log(a[key]) }

// Output:




Tuesday, 19 October 2021

Remote Desktop get to lock screen

 ctrl alt delete does not work on remote desktop for lock screen

use ctrl alt end

RXJS, finalize is same as finally can only be used whe observable complete or subject completes

 Observable automatically completes after emission for example of(1), observer=> hence for observable, usally piple(fianlize()) can always be used. Note finalize is always called in the end when observable completes.

For subject, it does not complete after next,,, it can keep emitting, for subject to complete use

var complete  = subject.piple(take(1))

For some observable, it may not always be completed after emission such as this.route.queryParams,

Need to call  this.route.queryParams.pipe(take(1)),

Thursday, 14 October 2021

Git 'fatal: Unable to write new index file'

the disk ran out of space, so I had to delete files from the hard drive to make space.