|
Ok!
|
|
|
Ok!
|
---|---|---|---|---|
209 | const generateMinsRange = (min, max) => { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; }; | интервал, минуты | 1000043 | сгенерить произвольно несколько минут или секунд в пределах от и до |
181 | SELECT * FROM shoutbox WHERE CONCAT(name, foo, bar, baz) LIKE '%$search%' | поиск, mysql, по колонкам | 340900 | Поиск по нескольким колонкам |
237 | <? #$APPLICATION->AddHeadScript(PROTOCOL.$_SERVER['SERVER_NAME']."/js/2gis.js") ?> <? #$APPLICATION->AddHeadScript("https://maps.api.2gis.ru/2.0/loader.js?pkg=full") ?> <? #$APPLICATION->AddHeadScript(SITE_TEMPLATE_PATH."/js/gis-init.js") ?> | 2gis | 200900 | Установка 2gis |
252 | !CSite::InDir("/shop/") | папка, Битрикс | 190080 | Проверка текущей папки в Битрикс |
184 | <span class="mc-stars" style="display:none"> <span class="mc-star" data-origin="star_o" data-color="#ffaf02" data-star="1" data-hover=""> <svg width="24" height="24" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ffaf02"></path></svg></span><span class="mc-star" data-origin="star_o" data-color="#ffaf02" data-star="2" data-hover=""> <svg width="24" height="24" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ffaf02"></path></svg></span><span class="mc-star" data-origin="star_o" data-color="#ffaf02" data-star="3" data-hover=""> <svg width="24" height="24" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ffaf02"></path></svg></span><span class="mc-star" data-origin="star_o" data-color="#ffaf02" data-star="4" data-hover=""> <svg width="24" height="24" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ffaf02"></path></svg></span><span class="mc-star" data-origin="star_o" data-color="#ffaf02" data-star="5" data-hover=""> <svg width="24" height="24" viewBox="0 0 1792 1792"><path d="M1201 1004l306-297-422-62-189-382-189 382-422 62 306 297-73 421 378-199 377 199zm527-357q0 22-26 48l-363 354 86 500q1 7 1 20 0 50-41 50-19 0-40-12l-449-236-449 236q-22 12-40 12-21 0-31.5-14.5t-10.5-35.5q0-6 2-20l86-500-364-354q-25-27-25-48 0-37 56-46l502-73 225-455q19-41 49-41t49 41l225 455 502 73q56 9 56 46z" fill="#ffaf02"></path></svg></span></span> | рейтинг, 5 звезд | 130900 | рейтинг в 5 пустых звезд |
176 | В htaccess добавить <IfModule mod_headers.c> <FilesMatch ".(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$"> Header set Access-Control-Allow-Origin "*" </FilesMatch> </IfModule> | cors, allow origin | 100600 | No Access-Control-Allow-Origin header при подключении шрифтов |
224 | ₽ | рубль, html | 100500 | символ рубля в html |
226 | var player = {score: 1, name: 'Jeff'}; var newPlayer = Object.assign({}, player, {score: 2}); // or var newPlayer = {...player, score: 2}; | create new object, js | 100300 | Создать новый объект из старого в Javascript |
162 | li:not(:last-child):not(:first-child) | ни первый ни послеадний, css | 100200 | ни первый ни послеадний из скписка |
177 | <script type="text/javascript">$(document).ready(function () { var div = $("#rec241218811").find(".t-video-lazyload"); var iframe = div.find('iframe'); var height = div.width() * 0.5625; div.height(height); iframe.height(height); $('.t223').bind('displayChanged', function () { height = div.width() * 0.5625; div.height(height); iframe.height(height); }); $(window).bind('scroll', t_throttle(function () { height = div.width() * 0.5625; div.height(height); iframe.height(height); }, 200)); });</script> | lazyload, youtube | 90890 | Лэйзилоуд для ютьюб роликов на страницу |
260 | Рейтинг рассчитывается по формуле Экслера: рейтинг = (сумма всех оценок + 31,25) / (число проголосовавших + 10) | рейтинг | 43590 | Как считать рейтинг |
259 | function readFileLineByLine($filename) { $file = fopen($filename, 'r'); while (!feof($file)) { yield fgets($file); } fclose($file); } foreach (readFileLineByLine('large_file.txt') as $line) { echo $line . "<br>"; } | генератор, php | 40010 | Генераторы особенно полезны в сценариях обработки больших файлов или потоков данных, например при построчном считывании большого файла |
178 | [checkbox* checkbox-41 id:agree-2 class:agree label_first use_label_element "Да"] | согласие, чекбокс | 34090 | Чекбокс согласия в contact forms 7 |
186 | if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443){ $protocol = 'https://'; }else{ $protocol = 'http://'; } $url = $protocol.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $urlend = strrpos($url, '?', -1); // Находим и удаляем все параметры (номер страницы, параметры фильтра и тд.) if($urlend != false){ $url = substr($url, 0, $urlend); } if(mb_substr($url, -1) == '/'){ // Тут оставляем, если ссылки на сайте не заканчиваются на /, либо удаляем, если заканчиваются на /. $url = substr($url, 0, -1); } echo '<link rel="canonical" href="'.$url.'"/>'; | php, canonical | 32090 | php link rel canonical |
235 | $to = '[email protected]'; $subject = 'Сообщение с сайта' . $_SERVER['HTTP_HOST']; $message = 'Заправлены в планшеты космические карты'; $headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-type: text/html; charset=utf-8' . " "; $headers .= 'To: Admin <' . $to . '>' . " "; $headers .= 'From: Site <' . $to . '>' . " "; mail( $to, $subject, $message, $headers ); | mail, php | 30098 | Отправить письмо php |
211 | let worker = { slow(min, max) { alert(`Called with ${min},${max}`); return min + max; } }; function cachingDecorator(func, hash) { let cache = new Map(); return function() { let key = hash(arguments); // (*) if (cache.has(key)) { return cache.get(key); } let result = func.call(this, ...arguments); // (**) cache.set(key, result); return result; }; } function hash(args) { return args[0] + ',' + args[1]; } worker.slow = cachingDecorator(worker.slow, hash); alert( worker.slow(3, 5) ); // работает alert( "Again " + worker.slow(3, 5) ); // аналогично (из кеша) | caching decorator, js | 24600 | Кеширующая js функция |
219 | /** * year start count from * input @string ('1987') * return years since @string */ function year_skils($Y) { $years = date("Y") - date("Y", strtotime($Y)); $year_text = ($years%2==0|$years%3==0|$years%4==0)?"года":(($years%10==1&&$years!=11)?"год":"лет"); return $years . " " . $year_text; } | php, years, year, лет по-русски | 23090 | php сколько лет с тех пор по-русски |
213 | $monthNames = [ "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря" ]; $tilDate = date("j", strtotime('last day of this month')); $tilMonth = date("n", strtotime('last day of this month')); $til = $tilDate . " " . $monthNames[$tilMonth - 1]; | последний день месяца, php | 21090 | Последний день месяца PHP (напр. 31 мая) |
80 | <mytag> <![CDATA[Your text goes here. Btw: 5<6 and 6>5]]> </mytag> | cdata, xml, wrong tags | 20300 | Если заполнение xml параметра выдает текстовую ошибку из-за несовместимого символа, то все символы прячутся в тег CDATA |
210 | return ($month === 12 && $day >= 15) || ($month === 1 && $day < 10); | новый год, php | 20090 | Вернёт true если новогодние праздники близко |