Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
d1i1m1o1n / text
Created October 6, 2016 12:16
How to disable auto-save in phpstorm
How to disable auto-save:
Go to File > Settings (Ctrl+Alt+S).
Go to Appearance & Behavior > System Settings.
Make sure the two are unchecked:
Save files on frame deactivation
Save files automatically if application is idle for x sec.
Go to Editor > General > Editor Tabs
Put a checkmark on "Mark modified files with asterisk"
(Optional but recommended) Under "Tab Closing Policy", select "Close non-modified files first". You may also want to increase the number of allowed tabs.
Click Apply > OK.
@d1i1m1o1n
d1i1m1o1n / docker-local-dev-frontend.md
Last active January 31, 2024 16:29
Local launch of frontend application via docker in development mode

Dockerfile

FROM node:16-alpine AS development
ENV NODE_ENV development
# Add a work directory
WORKDIR /app
# Cache and Install dependencies
COPY package.json .
COPY package-lock.json .
RUN npm install --force
@d1i1m1o1n
d1i1m1o1n / TimeWeb - SSH RSA Key
Created November 9, 2016 06:53 — forked from zetrider/TimeWeb - SSH RSA Key
Авторизация SSH по RSA ключу - TimeWeb
user - имя пользователя
server.timeweb.ru - сервер
1. На машине ssh-keygen -t rsa
2. Копируем, можно по FTP или одной из команд
2.1. ssh-copy-id -i ~/.ssh/id_rsa user@server.timeweb.ru
2.2. scp ~/.ssh/id_rsa.pub user@server.timeweb.ru:~
3. На сервере
[ -d ~/.ssh ] || (mkdir ~/.ssh; chmod 711 ~/.ssh) # создание директории и изменение прав
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys # добавление открытого ключа
@d1i1m1o1n
d1i1m1o1n / СНИЛС
Last active March 15, 2023 06:03
Проверка номера СНИЛС
<?php
if(!empty($_POST)){
// Массив сообщений об ошибках
$error = array();
// Удаляем тире и пробелы
$number = str_replace(array(" ", "-"),
array("", ""),
$_POST['number']);
$pattern = "|^\d{11}$|";
if(!preg_match($pattern, $number)){
@d1i1m1o1n
d1i1m1o1n / .parameters.php
Created May 30, 2016 11:47
Bitrix custom param in "bitrix:main.include" datepicker. Битрикс, параметр у компонента "bitrix:main.include" в виде календаря с возможностью выбора даты
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
$arTemplateParameters = array(
'COUNTDOWN_DATE' => array(
'NAME' => "Дата окончания",
'TYPE' => 'CUSTOM',
// свой подключаемый скрипт
'JS_FILE' => $templateFolder.'/settings.js',
// функция из подключенного скрипта JS_FILE, вызывается при отрисовке окна настроек
@d1i1m1o1n
d1i1m1o1n / d7.php
Created February 19, 2016 08:38
Bitrix(d7). DB query
<?php
use Bitrix\Main\Application;
$connection = Application::getConnection();
$sqlHelper = $connection->getSqlHelper();
$sql = "SELECT ID FROM b_user WHERE LOGIN = '".$sqlHelper->forSql($login, 50)."'";
//$connection->query($sql, $limit);
//$connection->query($sql, $offset, $limit);
@d1i1m1o1n
d1i1m1o1n / update_count_in_cart.php
Created December 7, 2015 18:58
Bitrix update quantity (count) in cart (basket) for ajax request
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("sale");
if (IntVal($_POST["id"]) > 0) {
CSaleBasket::Update($_POST["id"], array("QUANTITY" => $_POST["count"]));
}
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
@d1i1m1o1n
d1i1m1o1n / header.pug
Created February 23, 2018 21:12 — forked from lineharo/header.pug
PUG - auto version .css or another files in HTML head
- function pDate() {
- return new Date().getTime();
- }
doctype html
html(lang="ru")
head
meta(charset="utf-8")
title TITLE
@d1i1m1o1n
d1i1m1o1n / style.css
Created June 14, 2021 12:05
We can use CSS aspect-ratio today by using CSS @supports and CSS variables.
.card {
--aspect-ratio: 16/9;
padding-top: calc((1 / (var(--aspect-ratio))) * 100%);
}
@supports (aspect-ratio: 1) {
.card {
aspect-ratio: var(--aspect-ratio);
padding-top: initial;
}
@d1i1m1o1n
d1i1m1o1n / switch.js
Created February 27, 2021 10:15
Alternative to switch case
const page = 'edit';
const content = {
create: () => console.log('create'),
edit: () => console.log('edit'),
view: () => console.log('view')
}[page]()