Skip to content

Instantly share code, notes, and snippets.

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

Alexandr Vetrov bree7e

🏠
Working from home
View GitHub Profile
@rajaramtt
rajaramtt / ElementRef, TemplateRef, ViewRef, ComponentRef and ViewContainerRef.ts
Last active October 22, 2023 17:26
ElementRef, TemplateRef, ViewRef, ComponentRef and ViewContainerRef
//--------------- ElementRef----------------------
@ViewChild('foo', {static: false}) foo: ElementRef;
@Component({
selector: 'sample',
template: `
@mohanpedala
mohanpedala / inside_nginx.md
Last active March 28, 2023 12:39
Inside Nginx

Virtual Host and Serving Static Content

  • Default path: vim /etc/nginx/conf.d/default.conf

  • Custom Config vim /etc/nginx/conf.d/example.com.conf

  • Default index.html: /usr/share/nginx/html/index.html

  • Custom index.html: /var/www/example.com/html/index.html

    • Path explanation:
      • Default path : /var/www/
  • Virtualhostname : example.com
const log = (tag: string) => tap(
next => console.log(`%c[${tag}: Next]`, 'color: #4CAF50;', next),
error => console.log(`%c${tag}: Error]`, 'color: #F44336;', error),
() => console.log(`%c[${tag}: Complete]`, 'color: #2196F3;')
);
@sulco
sulco / theme.directive.ts
Created November 4, 2018 16:12
Angular theme directive
import { Directive, ElementRef, Input, OnChanges } from '@angular/core';
/**
* Usage:
* <mycomponent [dtTheme]="{'color-main': '#bada55'}"></mycomponent>
*/
@Directive({
selector: '[dtTheme]'
})
export class ThemeDirective implements OnChanges {
function changeInput(inputName, value) {
ng.probe($0).componentInstance[inputName] = value;
ng.probe($0).injector.get(ng.coreTokens.ApplicationRef).tick();
}
function subscribeOutput(outputName, cb) {
const subscription = ng.probe($0).componentInstance[outputName].subscribe((value) => {
console.log(`${outputName} => ${value}`);
});
@KRostyslav
KRostyslav / tsconfig.json
Last active April 17, 2025 12:34
tsconfig.json с комментариями.
// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".
@adcreare
adcreare / npm-beta-publish.md
Last active March 26, 2025 16:15
npm publish a beta package

Steps to publish a npm package to beta that won't be available via latest and won't auto install on ncu updates etc

  1. Ensure any compile is run npm run dist etc
  2. Modify version in package.json to the following format (match with existing verion numbers etc) "version": "0.1.120-beta.1" where beta.x is the number of those betas
  3. Publish to npm npm publish --tag beta

There are two options for install:

  • Always install beta with npm install packagename@beta
  • Install specific version with npm install [email protected]
@OliverJAsh
OliverJAsh / foo.ts
Last active January 27, 2025 18:24
Records and dictionaries in TypeScript
/*
In JavaScript, objects can be used to serve various purposes.
To maximise our usage of the type system, we should assign different types to our objects depending
on the desired purpose.
In this blog post I will clarify two common purposes for objects known as records and dictionaries
(aka maps), and how they can both be used with regards to the type system.
@caroso1222
caroso1222 / dom.service.ts
Last active August 18, 2023 13:34
Service to dynamically append Angular components to the body
import {
Injectable,
Injector,
ComponentFactoryResolver,
EmbeddedViewRef,
ApplicationRef
} from '@angular/core';
@Injectable()
export class DomService {
@fongandrew
fongandrew / react-bind.md
Last active January 14, 2024 16:02
Explaining why we bind things in React

Start With This

Before getting to React, it's helpful to know what this does generally in Javascript. Take the following snippet of code. It's written in ES6 but the principles for this predate ES6.

class Dog {
  constructor() {