how to focus on an input in Angular

 https://stackoverflow.com/questions/49927624/how-to-focus-on-an-input-in-angular


You are using ViewChildren which returns a QueryList You need to use ViewChild and your code should work.

export class MyClass {
    @ViewChild('swiper') swiper: ElementRef;

    constructor(private renderer: Renderer) {}

    onClick() {
        this.swiper.nativeElement.focus();
    }
}

Change default background color of md-slider of Angular Material

 https://stackoverflow.com/questions/45389498/change-default-background-color-of-md-slider-of-angular-material


Then in your CSS, you can customize each of them as such:

:host ::ng-deep .average .mat-slider-thumb {
  background-color: #ff3967;
}

:host ::ng-deep .min .mat-slider-thumb {
  background-color: blue;
}

:host ::ng-deep .min .mat-slider-thumb-label {
  background-color: blue;
}

:host ::ng-deep .min .mat-slider-track-fill {
  background-color: blue;
}

:host ::ng-deep .max .mat-slider-thumb {
  background-color: orange;
}

:host ::ng-deep .max .mat-slider-thumb-label {
  background-color: orange;
}

:host ::ng-deep .max .mat-slider-track-fill {
  background-color: orange;
}

All info about :host and ::ng-deep in the offical Angular documentation for component styles

What's the double exclamation mark for in JavaScript?

 https://brianflove.com/2014-09-02/whats-the-double-exclamation-mark-for-in-javascript/


So, why double exclamation marks?

In some cases you may want to cast a variable to be explicitly boolean. Why? Well, the number one reason is that most of time developers do not use type safe comparison operators.

The type safe comparison operators are:

  • Strictly equal: ===
  • Strictly unequal: !==

When using the type safe comparison operators you are both checking that the values are equal (or unequal) and that their type is the same. Without the type safe comparison operators you are allowing the JavaScript engine the freedom to coerce your variables to true or false based on the truthy/falsey logic.

To cast your JavaScript variables to boolean, simply use two exclamation signs:

function() {
  var name = 'Brian';

  //alert 'string'
  window.alert(typeof name);

  //cast to boolean
  var bool = !!name;

  //alert 'boolean'
  window.alert(typeof bool);
}

In the example code above we are casting the string "Brian" to a boolean value. Therefore the second alert will indicate that the variable is now a boolean value.

This class is visible to consumers via SomeModule -> SomeComponent, but is not exported from the top-level library entrypoint

 https://stackoverflow.com/questions/60121962/this-class-is-visible-to-consumers-via-somemodule-somecomponent-but-is-not-e

This error happens if any component is exported in NgModuleand not included in your public_api.tsangular 9 will through error now.


This error was not coming in angular 8 but after upgrading to angular 9 it started showing.

If you exported any servicemodule or component, etc in NgModule make sure to include them in public_api.ts or else angular 9 will throw error now.


Fix: add your component to the public_api.ts

export * from './lib/components/some-me/some-me.component';

Sending multiple emails at once with nodemailer

 https://stackoverflow.com/questions/64412815/sending-multiple-emails-at-once-with-nodemailer


 static async resendUndeliveredMails() {
try {
  const mails = await findAll();
  const mailerPromises = mails.map((mail) => transporter.sendMail(mail.dataValues));
  const responses = await Promise.all(mailerPromises);
  console.log(responses, "All Mails Have Been Sent Successfully");
} catch (e) {
  console.log(e);
}

const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    user: "user",
    pass: "pass", // naturally, replace both with your real credentials or an application-specific password
  },
});

const mailOptions = {
  from: "user@gmail.com",
  to: "test@gmail.com",
  subject: "testing due",
  text: "Dudes, we really need your money.",
};

const mailOptions2 = {
  from: "user@gmail.com",
  to: "test1@gmail.com",
  subject: "LOL due",
  text: "Dudes, we really need your money.",
};

Promise.all([
  transporter.sendMail(mailOptions),
  transporter.sendMail(mailOptions2),
])
  .then((res) => console.log(res))
  .catch((err) => console.log(err));

What is the mouse down selector in CSS?

 https://stackoverflow.com/questions/16715274/what-is-the-mouse-down-selector-in-css

I figured out that this behaves like a mousedown event:

&,

    &:hover,

    &:focus,

    &:active,

    &.active,

    &:active:focus,

    &:active:hover,

    &.active:focus,

    &.active:hover,

    .open > &.dropdown-toggle,

    .open > &.dropdown-toggle:focus,

    .open > &.dropdown-toggle:hover {

      background-color: $btn-color;

      color: $white-color;

    }

    &:focus,

    &:active,

    &:hover{

      @include button-shadow-color($btn-color);

    }

button:active:hover {}

How to comment ejs code ( JS node)

 https://stackoverflow.com/questions/29180611/how-to-comment-ejs-code-js-node


There is two solutions:

  • <%# comment %> ( it's from documentation )
  • <%/* comment */%> ( it works too but it's pretty ugly and uncomfortable for use )

Download website

 https://stackoverflow.com/questions/23446635/how-to-download-http-directory-with-all-files-and-sub-directories-as-they-appear

Solution:

wget -r -np -nH --cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

Explanation:

  • It will download all files and subfolders in ddd directory
  • -r : recursively
  • -np : not going to upper directories, like ccc/…
  • -nH : not saving files to hostname folder
  • --cut-dirs=3 : but saving it to ddd by omitting first 3 folders aaabbbccc
  • -R index.html : excluding index.html files
If not wget, get it by:

sudo yum install wget

Is it okay to use both fetchpriority="high" and loading="eager" in img tag?

 https://stackoverflow.com/questions/77744344/is-it-okay-to-use-both-fetchpriority-high-and-loading-eager-in-img-tag Yes Fetchpriority and l...