Skip to content

Instantly share code, notes, and snippets.

Add mixins from Library

SOURCE

The example library is angular-mdc-web.

In order to use the custom mixins from the library add this to angular.json file in the project.architect.build.options section:

...

Firebase Firestore Best Practice

1. Correct way to structure data in Firestore:

SOURCE, SOURCE, SOURCE

2. Managing Denormalized/Duplicated Data in Cloud Firestore:

SOURCE

3. Collections, Maps, Arrays and their limitations Firestore:

SOURCE

On hover show and hide different div's at the same time?

SOURCE

<div class="showhim">
     HOVER ME
     <div class="showme">hai</div>
     <div class="ok">ok</div>

Hover over DIV to expand width

SOURCE

<div id="growContainer">
  <div class="grow" style="background-color:#2A75A9;"></div>
  <div class="grow" style="background-color:#274257;"></div>
  <div class="grow" style="background-color:#644436;"></div>
 

Fix Firebase Function Cannot Start Emulator Error

SOURCE

# install current working directory dependencies
yarn --ignore-engines

# install firebase-tools if u didn't
yarn global add firebase-tools

Firebase CLI Command

SOURCE

yarn run lint : lint check for error

firebase list

firebase deploy : deploy everything

Connect Firebase Hosting to Namecheap Custom Domain

SOURCE, SOURCE, SOURCE

  1. Go to Firebase's Dashboard > Develop > Hosting > Connect Domain.
  2. Enter the custom domain that you'd like to connect to your Hosting site.
  3. (Optional) Check the box to redirect of all requests on the custom domain to a second specified domain.
  4. Click Continue to initiate the validation process.
  5. Go to Namecheap's Dashboard > Domain List > Manage > Advanced DNS.
  6. Under Host Records, add a new record with:

How to Change Position of background-color

SOURCE, SOURCE, SOURCE

Actually you can't change the position of a background-color, instead we need to use a trick to create a background-image with solid gradient and position that instead.

Here is the example of a div that have color background fill up and leave around 100px at the bottom unfilled.

Scale SVG on Safari

SOURCE, SOURCE

Safari has trouble scaling SVG image so it will distort image if use with attribute like object-fit: cover;. To fix this add preserveAspectRatio="none" to the <svg>:

<svg width="200" height="200" viewBox="0 0 200 200" fill="none" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

Import JavaScript library into Angular

SOURCE, SOURCE

What works in Angular 7:

The JS library trie-search doesn't have the definition .dt.ts file to be used in TypeScript file. so we need to use the following method in order to use it.

Tips: using Type Search to see if there's any pre created .d.ts for your library SOURCE.