Skip to content

Instantly share code, notes, and snippets.

@Dziuperman
Dziuperman / what-forces-layout.md
Created September 7, 2020 04:50 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@Dziuperman
Dziuperman / README.md
Created April 18, 2020 03:58 — forked from kerryboyko/README.md
VueJS Best Practices Guide

Deverus Vue.js Style Guide

Guide for developing Vue.js applications.

v. 0.0.1

Vue.js is an amazing framework, which can be as powerful as Angular or React, the two big heavy hitters in the world of front-end frameworks.

However, most of Vue's ease-of-use is due to the use of Observables - a pattern that triggers re-renders and other function calls with the reassignment of a variable.

@Dziuperman
Dziuperman / download-file.js
Created February 6, 2020 04:32
Download file #js #axios
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@Dziuperman
Dziuperman / Connection.php
Last active December 7, 2019 12:30
Query builder #php #OOP #MVC
<?php
namespace Engine\Core\Database;
use \PDO;
use Engine\Core\Config\Config;
class Connection
{
private $link;
@Dziuperman
Dziuperman / template.php
Created October 15, 2019 15:05
Каталог из разделов #bitrix #bitrix:catalog.section
<?
/***
Получаем массив коллекций, отфильтрованных умным фильтром.
Сравниваются массивы чекнутых свойств фильтра и свойства
всех товаров
***/
/*** Start Массив отфильтрованных коллекций ***/
if (CModule::IncludeModule("iblock")) {
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "PROPERTY_231", "PROPERTY_232");
$arFilter = Array("IBLOCK_ID" => 17, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
@Dziuperman
Dziuperman / init.php
Last active August 29, 2024 12:10
Bitrix -- Вывод всех товаров со скидкой #bitrix #sale
<?php
// Подключение в init.php вашего сайта
use Bitrix\Main\Loader;
use Bitrix\Main\SystemException;
class AllProductDiscount{
/**
* @return XML_ID|array
* @throws SystemException
* @throws \Bitrix\Main\LoaderException
// Добавление рубрик и меток страницам
function true_apply_categories_for_pages(){
add_meta_box( 'categorydiv', 'Категории', 'post_categories_meta_box', 'page', 'side', 'normal'); // добавляем метабокс категорий для страниц
register_taxonomy_for_object_type('category', 'page'); // регистрируем рубрики для страниц
}
// обязательно вешаем на admin_init
add_action('admin_init','true_apply_categories_for_pages');
function true_expanded_request_category($q) {
if (isset($q['category_name'])) // если в запросе присутствует параметр рубрики
add_action('kama_breadcrumbs_home_after', 'my_breadcrumbs_home_after', 10, 4);
function my_breadcrumbs_home_after( $false, $linkpatt, $sep, $ptype ){
// если мы в рубрике с ID 5 или в дочерней рубрике,
// то дополним начало крошек ссылкой на страницу с ID 7
$mec_category = get_queried_object();
if( is_archive() && ( $mec_category->taxonomy == 'mec_category' ) ){
$category = get_queried_object();
$mec_category->name;
if($category->name == $mec_category->name) {
@Dziuperman
Dziuperman / search-by-posts-by-default.php
Last active July 5, 2019 04:36
Search by posts on the search page
<?php
$args = array(
'post_type' => 'page',
'name__like' => $_GET['s'],
);
$query = new WP_Query( $args ); ?>
<?php if ( have_posts() ): ?>
<h2>Search Results for '<?php echo get_search_query(); ?>'</h2>
<ol>
@Dziuperman
Dziuperman / google-docs.html
Created July 5, 2019 04:29
Iframe for google docs
<script>
// Google docs (documents viewer)
function showDocs(oLink) {
var oBlock = oLink.getElementsByTagName('div')[0];
var oIframe = oLink.getElementsByTagName('iframe')[0];
var oIframeUrl = oLink.getAttribute('url-show');
if(oBlock.style.height == 0+'px') {
oBlock.style.height = 980+'px';
if(oIframe.src != oIframeUrl) {oIframe.src = oIframeUrl};
} else {