Skip to content

Instantly share code, notes, and snippets.

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

SnisarOnline SnisarOnline

🏠
Working from home
View GitHub Profile
@SnisarOnline
SnisarOnline / component-destroyed.mixin.ts
Last active July 29, 2021 07:48
Класс-Mixin для расширения ангуляр компонента и стандартизации отписок от потока
export type Constructor<T> = new (...args: any[]) => T;
/**
* Расширение компонентов для стадартизации/централизации отпуска от потока.
* Expansion of the components to centralize the dispensing from the flow.
* @see [unsubscribe in Angular components](https://medium.com/@gesteira2046/goodbye-to-unsubscribe-in-angular-components-8817e1b21db2)
*
* @Example
* ```ts
* export class AppComponent extends ComponentDestroyedMixin() {
@SnisarOnline
SnisarOnline / mixin-scrollbar.scss
Last active July 29, 2021 07:39
SCSS-mixin для быстрого ре-дизайна стандартного scrollbars
/**
* @see https://css-tricks.com/custom-scrollbars-in-webkit/
*/
@mixin scrollbars($size, $foreground-color, $background-color: mix($foreground-color, white, 50%)) {
// For Google Chrome
&::-webkit-scrollbar {
width: $size;
height: $size;
}
@SnisarOnline
SnisarOnline / ResetCSS.css
Last active October 18, 2019 15:19
Reset CSS
* {
box-sizing: border-box;
}
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
@SnisarOnline
SnisarOnline / time-elapsed.pipe.ts
Last active March 7, 2023 15:10
An Angular pipe for converting a date string into a time ago
// Angular
import { Pipe, PipeTransform, OnDestroy, ChangeDetectorRef, NgZone } from '@angular/core';
/**
* https://github.com/AndrewPoyntz/time-ago-pipe
* An Angular pipe for converting a date string into a time ago
*
* Example :
* <span>Last {{ date | kTimeElapsed}} ago</span>
*/
@SnisarOnline
SnisarOnline / filter.pipe.ts
Last active July 11, 2019 11:01
Фильтер масива обьектов по ключу / вводимым данным / уникальным значениям.
import {Pipe, PipeTransform} from '@angular/core';
/**
* Returns filtered array
*/
@Pipe({ name: 'filter' })
export class FilterPipe implements PipeTransform {
/**
* @param array incoming array not sort
* @param field name Fields to sort
@SnisarOnline
SnisarOnline / autosize.directive.ts
Created July 6, 2019 18:35
Изменение высоты input/textarea
import {AfterViewInit, Directive, HostListener, Input, ElementRef} from '@angular/core';
@Directive({
selector: '[Autosize]'
})
export class AutosizeDirective implements AfterViewInit {
private el: HTMLElement;
private _minHeight: string;
private _maxHeight: string;
import { Directive, AfterViewInit, ElementRef } from '@angular/core';
@Directive({
selector: '[appAutofocus]'
})
export class AutofocusDirective implements AfterViewInit {
constructor(private el: ElementRef) {}
ngAfterViewInit() {
@SnisarOnline
SnisarOnline / если комит с не правельными кредами
Created June 25, 2019 07:26
перезапись комита с неправельным авторством
1) БЫСТРО ИЩЕМ ПОСЛЕДНИЙ КОММИТ С ВЕРНЫМИ КРЕДАМИ И КОПИРУЕМ ЕГО АЙДИ
2) ПИШЕМ
git reset --hard 6534hds8sda
где *6534hds8sda* и есть тот айдишник
3) ИСПРАВЛЯЕМ КОНФИГ:
git config --local user.name "ПРАВИЛЬНОЕ ИМЯ"
git config --local user.email "ПРАВИЛЬНОЕ МЫЛО"
4) ПРОВЕРЯЕМ ЧТО НАПИСАЛИ:
git config --local user.name
git config --local user.email
@SnisarOnline
SnisarOnline / PastTimePipe.ts
Last active March 6, 2023 15:00
грубый подсчет времени после публикации
import {Pipe, PipeTransform} from '@angular/core';
/**
* Фильтер Расчет прошедшего времени от времени публикации,
* @Example <div>{{news.time | past_time}} ago</div>
* @param {number} create_post время создания поста
* @returns {string} Сколько времени прошло с момента создания поста
*/
@Pipe({
name: 'past_time'
@SnisarOnline
SnisarOnline / limit-symbols.pipe.ts
Last active May 21, 2023 09:57
Angular Pipe. Ограничение на количество символов. В случае привышения ставим ...
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "limitSymbols"
})
export class limitSymbols implements PipeTransform {
/**
* ограничение выводимых символов с добавлением троеточия