Skip to content

Instantly share code, notes, and snippets.

@srikanth4b9
srikanth4b9 / angular_review_comments.ts
Last active October 8, 2024 00:58
Angular Review comments
pattern tap({ next: ..., error: ... }) allows you to handle both success and error scenarios inside the tap operator without needing to use a separate catchError
Before Refactoring (with tap + catchError):
```
this.someService.getData().pipe(
tap(data => {
console.log('Data received:', data);
}),
catchError(error => {
/*
* Total of numbers in an array
*/
const myArray1 = [1, 2, 3, 4, 5, 6, 7];
const reducedArray = myArray1.reduce((a, b) => a + b, 0)
console.log(reducedArray);
/*
* Turn an array of numbers into a long string of all those numbers
@srikanth4b9
srikanth4b9 / format.ts
Created June 13, 2022 13:27
'3h 20m 00s' ms to time format
public static formatDurationms(t: number) {
let h = Math.floor(t / 3600000);
t -= h * 3600000;
let m = Math.floor(t / 60000);
t -= m * 60000;
let s = Math.floor(t / 1000);
let time = '';
PPT: https://docs.google.com/presentation/d/1G_zdDOYbCNk1oOacHiV94DpU3jrfwicH/edit
open in html present: https://docs.google.com/presentation/u/0/d/1G_zdDOYbCNk1oOacHiV94DpU3jrfwicH/htmlpresent
Use online tool: https://webtopdf.com/
options: width, height (px to mm), zoom, page no.
Download
const SHOW_DELAY = 1000;
const DISAPPEAR_DELAY = 1000;
@HostListener('mouseenter')
handleMouseEnter() {
let delay = SHOW_DELAY; //1000ms
this.timeoutEnter = this.setTimeout(() => this.setState({isShown: true}), delay);
this.clearTimeout(this.timeoutLeave);
import {Injectable} from '@angular/core';
@Injectable()
export class IPValidateService {
isIPWithInRange = (ipPartNumber: string) => {
if (isNaN(Number(ipPartNumber))) return false;
if (Number(ipPartNumber) > 255 || Number(ipPartNumber) < 0 || ipPartNumber === '') {
return false;
}
return true;
Paste here
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
{
"$schema": "node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "",
"projects": {
"rate-reset": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"