Skip to content

Instantly share code, notes, and snippets.

View zualex's full-sized avatar

Aleksandr Zubarev zualex

View GitHub Profile
@zualex
zualex / plus_in_loop.php
Created March 26, 2021 07:53
+ in loop
<?php
function printMemory($start, $header) {
printf(
"%s - Time: %s | Memory (current): %s KB | Memory (max): %s KB" . PHP_EOL,
$header,
number_format(round((microtime(true) - $start) * 1000, 6), 6, ',', ''),
number_format(round((memory_get_usage() / 1024), 2), 2, ',', ''),
number_format(round((memory_get_peak_usage() / 1024), 2), 2, ',', '')
);
@zualex
zualex / spread_in_loop.php
Created March 26, 2021 07:52
... in loop
<?php
function printMemory($start, $header) {
printf(
"%s - Time: %s | Memory (current): %s KB | Memory (max): %s KB" . PHP_EOL,
$header,
number_format(round((microtime(true) - $start) * 1000, 6), 6, ',', ''),
number_format(round((memory_get_usage() / 1024), 2), 2, ',', ''),
number_format(round((memory_get_peak_usage() / 1024), 2), 2, ',', '')
);
@zualex
zualex / array_merge_in_loop.php
Created March 26, 2021 07:49
Array merge in loop
<?php
function printMemory($start, $header) {
printf(
"%s - Time: %s | Memory (current): %s KB | Memory (max): %s KB" . PHP_EOL,
$header,
number_format(round((microtime(true) - $start) * 1000, 6), 6, ',', ''),
number_format(round((memory_get_usage() / 1024), 2), 2, ',', ''),
number_format(round((memory_get_peak_usage() / 1024), 2), 2, ',', '')
);
<?php
use DateTime;
use Exception;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\LoggerInterface;
use src\Integration\DataProvider;
class DataProvider
{
@zualex
zualex / declOfNum.js
Created April 21, 2016 09:01
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@zualex
zualex / EventHideOrShowItem.php
Last active May 20, 2016 18:02
Битрикс, события, код
<?php
/*
* Событие - при изменении элемента проверяем значение свойства и меняем в активность элемента
*/
/*
* Регистрация двух событий:
* OnBeforeIBlockElementAdd - перед добавление элемента
* OnBeforeIBlockElementAdd - перед изменением элемента
@zualex
zualex / atom-packages.md
Last active May 29, 2016 12:16
Atom best packages

Packages

  • auto-detect-indentation
  • tabs-to-spaces
  • emmet
  • atom-css-comb
  • language-parser3
  • atom-beautify
  • minimap
  • minimap-find-and-replace
  • minimap-pigments
@zualex
zualex / script.js
Created December 25, 2015 05:15
jQuery datepicker - исправление позиционирования
$.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});
$("#datepicker").datepicker();
@zualex
zualex / __custom.php
Last active November 13, 2015 11:44
UMI integration SDEK
<?php
abstract class __emarket_custom {
//TODO: Write here your own macroses
/*
* В файле - \classes\modules\emarket\__custom.php
* Пример вызова в TPL: <div>Стоимость доставки: %emarket newDeliveryPrice()%</div>
*/
public function newDeliveryPrice($template = 'default'){
$ini = cmsController::getInstance()->getModule("emarket");
@zualex
zualex / style.css
Last active October 2, 2015 05:19
Truncating words in CSS - This solution will show hyphens for every browser supporting it and will break lines in every other browser – perfect
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}