Skip to content

Instantly share code, notes, and snippets.

View patelvimal's full-sized avatar
🏠
Working from home

vimal patel patelvimal

🏠
Working from home
View GitHub Profile
@patelvimal
patelvimal / DeviceViewportService.ts
Last active January 31, 2022 11:20
Angular cdk BreakpointObserver get device ViewPort Service
import { Injectable, OnDestroy } from '@angular/core';
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
import { distinctUntilChanged, Observable, pluck, Subject, takeUntil, tap } from 'rxjs';
export type DeviceType = 'mobile' | 'tablet' | 'desktop';
export const DeviceMediaQuery: Record<DeviceType, string> = {
mobile: '(max-width: 400px)',
tablet: '(min-width: 401px) and (max-width: 700px)',
desktop: '(min-width: 701px) and (max-width: 1800px)'
@patelvimal
patelvimal / gist:6bfb93b4d30bffd7d9f4e57c213a71a7
Created December 5, 2021 07:11
angular schematics workspace
import { virtualFs, workspaces } from "@angular-devkit/core";
import { Rule, SchematicsException, Tree, noop } from '@angular-devkit/schematics';
/*
These functions referene has been taken from below links:-
https://angular.io/guide/schematics-for-libraries#define-a-generation-rule
https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/workspace.ts
*/
@patelvimal
patelvimal / filterArray.js
Created July 27, 2021 16:00 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
@patelvimal
patelvimal / Useful stack-overflow review comments.txt
Last active November 13, 2022 16:45
Useful stack-overflow review comments.txt
Please be a bit more specific when asking a question: What have you tried so far, with a code example? / What do you expect? / What error do you get? For help, take a look at "[How to ask](//stackoverflow.com/help/how-to-ask)".
You should consider posting this as an answer and accepting it so others can see that your problem was solved, especially if you solved it yourself :)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes
We will not do your entire homework for you, only help you with it. Show us your code and focus on a specific problem you're having. Tell us what you already understood, where you are struggling, and [what you've tried](https://stackoverflow.com/help/how-to-ask)
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce