Skip to content

Instantly share code, notes, and snippets.

@dnikonov
dnikonov / JAVASCRIPT: days left
Last active November 2, 2015 11:06
JAVASCRIPT: days left
var leftDaysHoursMinutes = function(){
var today = new Date();
var nextEVENT = new Date(2015, 10, 11, 0, 0, 0, 0); // месяц начинается с нуля
var msDelta = nextEVENT.getTime() - today.getTime();
if (msDelta > 0) {
// дней
var msPerDay = 24 * 60 * 60 * 1000;
var daysLeft = Math.floor(msDelta / msPerDay);
var sDaysLeft = String(daysLeft);
var sDaysText = "дней";
@dnikonov
dnikonov / HTML: IFRAME RESPONSIVE
Created May 13, 2015 10:35
HTML: IFRAME RESPONSIVE
<div class="iframe-responsive">
<img src="/upload/images/640x360.gif" alt="">
<iframe width="640" height="360" src="https://www.youtube.com/embed/CWaZrgc-g9A?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
.iframe-responsive {position: relative;}
.iframe-responsive img {display: block; width: 100%; height: auto;}
.iframe-responsive iframe {position: absolute; top:0; left: 0; width: 100%; height: 100%; display: block; vertical-align: top;}
if (!function_exists('BITGetDeclNum')) {
/**
* Функция возвращает окончание слова, в зависимости от примененного к ней числа
* Например: 5 товаров, 1 товар, 3 товара
*
* @param int $value - число, к которому необходимо применить склонение
* @param array $status - массив возможных окончаний
* @return mixed
*/
function BITGetDeclNum($value = 1, $status = array('','а','ов')) {
@dnikonov
dnikonov / JS: aspect
Last active May 18, 2016 09:29
JS: aspect
<div data-aspect="1.5"></div>
<script>
$(function($) {
var onResizeWindow = function(){
$('[data-aspect]').each(function(){
var aspect = $(this).data('aspect') || 1;
$(this).css('height', $(this).outerWidth() / aspect);
});
// ==UserScript==
// @name bitfinex
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.bitfinex.com/*
// @grant none
// ==/UserScript==
// result_modifier.php
// превью изображений
foreach ($arResult["ITEMS"] as $key => &$arItem) {
if ($arItem["PREVIEW_PICTURE"]) {
$arItem["PREVIEW_PICTURE_THUMB"] = array_change_key_case(CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"], array("width" => 500, "height" => 500), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true), CASE_UPPER);
}
if ($arItem["DISPLAY_PROPERTIES"]["SLIDER"]["VALUE"]) {
if (count($arItem["DISPLAY_PROPERTIES"]["SLIDER"]["VALUE"]) == 1) {
$arItem["DISPLAY_PROPERTIES"]["SLIDER"]["FILE_VALUE"] = array($arItem["DISPLAY_PROPERTIES"]["SLIDER"]["FILE_VALUE"]);
//init.php
if (!function_exists('custom_mail') && COption::GetOptionString("webprostor.smtp", "USE_MODULE") == "Y") {
function custom_mail($to, $subject, $message, $additional_headers='', $additional_parameters=''){
if (CModule::IncludeModule("webprostor.smtp")) {
// исправляю переносы строк в заголовках
if (!empty($additional_headers)) {
$additional_headers = str_replace("\r\n", "\n", $additional_headers); // на случай если уже нормальные переносы
$additional_headers = str_replace("\n", "\r\n", $additional_headers);
}
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
global $USER;
$USER->Authorize(1);
@unlink(__FILE__);
LocalRedirect("/bitrix/admin/");
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>
if (!function_exists('human_filesize')) {
function human_filesize($bytes, $decimals = 2) {
$sz = 'BKMGTP';
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . "&nbsp;" . @$sz[$factor] . "B";
}
}