Skip to content

Instantly share code, notes, and snippets.

@guzmanoj
guzmanoj / local-fonts-icons-angular
Created March 26, 2020 19:04 — forked from timbophillips/local-fonts-icons-angular
host roboto font and material icons locally in angular app
//// npm install --save roboto-fontface material-icons
//// put the below stuff into src/styles.scss
// for npm roboto-fontface package (to load local files)
$roboto-font-path: "~roboto-fontface/fonts" !default;
@import "~roboto-fontface/css/roboto/sass/roboto-fontface";
// for npm material-icons package (to load local files)
$material-icons-font-path: '~material-icons/iconfont/';
@guzmanoj
guzmanoj / format-relative.js
Created May 19, 2020 16:21 — forked from liamnewmarch/format-relative.js
Utility to format dates relatively without having to specify units.
const { language = 'en-US' } = navigator;
const formatter = new Intl.RelativeTimeFormat(language, {
numeric: 'auto',
style: 'long',
});
export function formatRelative(when) {
const ms = when - Date.now();
const years = Math.ceil(ms / 31536e6);
import { Observable } from 'rxjs';
const createInput = (acceptType: string) => {
const input = document.createElement('input');
input.type = 'file';
input.accept = `.${acceptType}`;
input.style.display = 'none';
return input;
};