Skip to content

Instantly share code, notes, and snippets.

@Dok11
Dok11 / bx-image.ts
Created May 7, 2017 18:55
TypeScript class for Bitrix image from \CFile::GetFileArray();
/**
* Интерфейс картинок из бекенда битрикса.
* Требует доработки на бекенде, т.к. по умолчанию битрикс всё возвращает
* строками
*/
export class BxImage {
ID: number;
TIMESTAMP_X: string;
MODULE_ID: string;
HEIGHT: number;
@Dok11
Dok11 / hyper-comments.component.ts
Last active October 18, 2018 10:12
hypercomments for angular 2+
import {Component, ElementRef, Input, OnDestroy, OnInit, Renderer2} from '@angular/core';
declare global {
interface Window {
_hcwp: any;
}
}
@Component({
selector: 'hyper-comments',
@Dok11
Dok11 / app.component.ts
Last active March 10, 2019 03:57
Angular native href work as routerLink
export class AppComponent {
@HostListener('click', [
'$event.target',
'$event.button',
'$event.ctrlKey',
'$event.metaKey',
])
private onClick(
eventTarget: HTMLElement,
button: number,
@Dok11
Dok11 / OpenDoor.cpp
Created February 21, 2019 17:52
UE4 APawn Bug
// Copyright Oleg Postoev
#include "OpenDoor.h"
#include "GameFramework/Actor.h"
// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
@Dok11
Dok11 / js-log-error.php
Created May 31, 2018 08:38
Angular ReportingErrorHandlerService (partical copy from angular/angular)
<?php
$input = file_get_contents('php://input');
$request = $input ? json_decode($input, true) : $_REQUEST;
if ($request['error']) {
$logPath = $_SERVER['DOCUMENT_ROOT'] . '/js-log-error.txt';
$date = date('Y.m.d H:i:s');
$message = $date . PHP_EOL . var_export($request, true) . PHP_EOL . PHP_EOL;
@Dok11
Dok11 / package.json
Last active March 10, 2019 03:59
Angular package.json commands to work with bitrix
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json -sm --aot",
"start-hmr": "ng serve --proxy-config proxy.conf.json -sm --hmr -e=hmr",
"build-dev": "ng build --dev --op=../../public_html/f/main-dev/ -dop false --oh none -sm false",
"build": "ng build --prod --op=../../public_html/f/main/ -dop false --oh none",
"test": "ng test --sourcemaps=false",
"lint": "ng lint --type-check",
"e2e": "ng e2e"
@Dok11
Dok11 / app.service.ts
Created April 23, 2018 14:12
Angular. Get plural code (1,2,5)
/**
* Метод возвращает нужный код числительного для разных цифр.
* Возможные коды ответа: 1, 2, 5
* Например, 1 - для 1 товар, 2 - товара, 5 - товаров
*/
public getPluralCode(n: number): number {
return (n % 10 === 1) && (n % 100 !== 11)
? 1
: (n % 10 >= 2)
&& (n % 10 <= 4)
@Dok11
Dok11 / app.ts
Created April 23, 2018 09:46
tslint feature disable
/* tslint:disable:max-line-length */
import {LongServiceNameService} from '../long/path/to/service/somwhere/in/project/long-service-name.service';
/* tslint:enable:max-line-length */
@Dok11
Dok11 / app.component.ts
Created April 6, 2018 15:15
Angular 5. Href links inside SPA
export class AppComponent {
@HostListener('click', [
'$event.target',
'$event.button',
'$event.ctrlKey',
'$event.metaKey',
])
private onClick(
eventTarget: HTMLElement,
button: number,
@Dok11
Dok11 / Angular 6 HMR
Last active June 18, 2019 11:21
Angular 6. Instruction for HMR installation
`npm install --save-dev @angularclass/hmr`
`src/environments/environment.prod.ts`
Add rule: `hmr: false`
`src/environments/environment.ts`
Add rule: `hmr: true`