|
Ok!
|
|
|
Ok!
|
---|---|---|---|---|
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 |
225 | <a href="https://api.whatsapp.com/send?phone=79269946796" target="_blank" class="header__social-link" data-menu-exit> | wa, whatsapp | 200 | |
224 | ₽ | рубль, html | 100500 | символ рубля в html |
223 | public function convertImage(&$content) { if (defined('ADMIN_SECTION') || defined('WIZARD_SITE_ID')) { return; } preg_match_all('/"(/upload/[^"]*.(jpg|jpeg|png))"/i', $content, $matches1); self::convertImageToWebp($content, $matches1); preg_match_all("/'(/upload/[^']*.(jpg|jpeg|png))'/i", $content, $matches2); self::convertImageToWebp($content, $matches2); } private static function convertImageToWebp(&$content, $matches) { if (!empty($matches[1])) { foreach ($matches[1] as $i => $imageUrl) { $root = $_SERVER['DOCUMENT_ROOT']; $type = $matches[2][$i]; $newName = str_replace($type, 'webp', $imageUrl); if (file_exists($root . $newName)) { $content = str_replace($imageUrl, $newName, $content); continue; } if (!file_exists($root . $imageUrl)) { continue; } $type = strtolower($type); switch ($type) { case 'jpeg': case 'jpg': $img = imagecreatefromjpeg($root . $imageUrl); break; case 'png': $img = imagecreatefrompng($root . $imageUrl); imagepalettetotruecolor($img); imagealphablending($img, true); imagesavealpha($img, true); break; } if (isset($img)) { $result = imagewebp($img, $root . $newName, 75); if (!$result) { continue; } $content = str_replace($imageUrl, $newName, $content); imagedestroy($img); unset($img); } } } } | bitrix, webp, convert | 20030 | convert image to webp bitrix |
222 | echo <<<EOH ---------- ----------- -- ---------- результат значение оп тест ---------- ----------- -- ---------- EOH; | eoh, php print formated | 12090 | Форматированная строка в PHP |
221 | User-agent: * Disallow: / User-agent: Googlebot User-agent: AdsBot-Google Disallow: / | disallow all, robots | 130 | Запретить индексайцию всем роботам и рекламным ботам |
220 | // Перенаправляем пользователя на страницу оплаты Header("Location: http://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=$mrh_login&OutSum=$out_summ&InvId=$inv_id". "&InvDesc=$inv_desc&SignatureValue=$crc". "&Culture=$culture&Encoding=$encoding&Email=$email"); | header, location, php | 120 | Перенаправляем пользователя на страницу оплаты Header |
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 сколько лет с тех пор по-русски |
218 | function loadScript(url, callback) { const element = document.createElement("script"); element.type = "text/javascript"; element.src = url; element.onload = callback; document.body.appendChild(element); } loadScript("js/common.js", () => { loadScript("<https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js>", () => { console.log("timer.js ") }) }) | loadscript, js | 1200 | Скрипт чтоб загрузить другой скрипт |
217 | $len = 10; // total number of numbers $min = 100; // minimum $max = 999; // maximum $range = []; // initialize array foreach (range(0, $len - 1) as $i) { while(in_array($num = mt_rand($min, $max), $range)); $range[] = $num; } print_r($range); | exclusive random, эксклюзивный | 2040 | Эксклюзивный выбор рандомных чисел |
216 | /** * @param $limit * @return string|string[] * обрезает контент до числа слов */ function content($limit, $pid = null) { $content = explode(' ', get_the_content($pid), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/[.+]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } | контент, образает, WP | 1001 | обрезает контент до числа слов |
215 | function custom_rate($num, $id) { $line = "<div class='item_rating' data-for='" . $id . "' data-rate='" . $num[0] . "'>"; for ($i = 1; $i < 6; $i++) { if ($i <= $num[0]) { $line .= "<img src="/wp-content/uploads/2022/07/Orange_star.svg" width=24 height=24 alt="Рейтинг не менее " . $i . ""/>"; } else { $line .= "<img src="/wp-content/uploads/2022/07/Orange_star_empty.svg" width=24 height=24 alt="Рейтинг менее " . $i . ""/>"; } } return $line . "</div>"; } | stars, rating, WP, рейтинг, звездочки | 120 | Функция для Вордпресс рейтинг звездочек |
214 | [display-posts category="apartamenty" image_size="medium" include_excerpt="true" orderby="date" order="ASC" include_excerpt_dash="false"] | список записей, WP | 11090 | Плагин WP – Display Posts для вывода списка записей по критериям |
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 мая) |
212 | $(document).ready(function(){ let tilDate = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 5); let tilDay = new Date(tilDate).getDate(); let monthNames = [ "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря" ]; if($('[field="tn_text_1655377664248"]').length){ new_text = tilDay + " " + monthNames[tilDate.getMonth()]; $('[field="tn_text_1655377664248"] span').text(new_text); } }); | 5 дней, JS | 20010 | Добавит 5 дней |
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 функция |
210 | return ($month === 12 && $day >= 15) || ($month === 1 && $day < 10); | новый год, php | 20090 | Вернёт true если новогодние праздники близко |
209 | const generateMinsRange = (min, max) => { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; }; | интервал, минуты | 1000043 | сгенерить произвольно несколько минут или секунд в пределах от и до |
208 | https://view.officeapps.live.com/op/view.aspx?src=https://site.com/price/price.xlsx | просмотр эксель, excel в браузере | 100 | Ссылка на просмотр файла эксель в браузере на сайте Майкрософт https://view.officeapps.live.com |
207 | $posts = get_posts ("category=11&orderby=date&numberposts=5"); if ($posts) : $i=1; foreach ($posts as $post) : setup_postdata ($post); $i++; endforeach; endif; | get_posts, wp | 1290 | Получить посты по запросу из Вордпресс |