Skip to content

Instantly share code, notes, and snippets.

@Dok11
Dok11 / (preview) Bitrix Classes Extending.php
Last active November 17, 2023 21:14
Bitrix Classes Extending
<?php
if (\Bitrix\Main\Loader::includeModule('iblock')) {
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
'CIBlockCMLImport' => __DIR__ . '/ciblockcmlimport.php',
]);
}
$pathToOriginalCode = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/iblock/classes/general/cml2.php';
$originalCode = file_get_contents($pathToOriginalCode);
@Dok11
Dok11 / train.py
Last active September 14, 2019 21:53
Shared models for keras
import tensorflow as tf
from tensorflow.python.keras import Input, Model
from tensorflow.python.keras.layers import Conv2D, MaxPooling2D, Dropout, concatenate, \
Flatten, Dense
IMG_SHAPE = (60, 90, 1)
# Defined a shared model
shared_input = Input(IMG_SHAPE)
shared_layer = Conv2D(8, (7, 7), strides=3, input_shape=IMG_SHAPE, padding='valid', activation='relu')(shared_input)
@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
interface ColorRgb {
r: number;
g: number;
b: number;
}
interface ColorHsl {
h: number;
s: number;
l: 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`
@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 / 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 */