Skip to content

Instantly share code, notes, and snippets.

@Driver86
Driver86 / 1.php
Last active June 14, 2022 20:17
Тестовые задачи
<?php
/*
Нужно написать на php функцию, которая принимает строку — текст на любом языке и
возвращает массив из 5 наиболее часто встречающихся слов в этом тексте. Ключ массива — слово,
значение — количество. Ни веб-сервер, ни база данных не понадобятся; версия php не имеет
значения.
*/
function getWords(string $string): array
@Driver86
Driver86 / 1.php
Last active July 20, 2020 14:31
Test
<?php
function getWorkingDays($startDate, $endDate, $holidays) {
$endDate = strtotime($endDate);
$startDate = strtotime($startDate);
$days = ($endDate - $startDate) / 86400 + 1;
$no_full_weeks = floor($days / 7);
$no_remaining_days = fmod($days, 7);
@Driver86
Driver86 / sticky.html
Created September 30, 2018 22:42
If the height of the browser window is less than the height of the side column, then either the bottom or the top edge of the column will stick, otherwise only the top.
<!DOCTYPE html>
<html>
<head>
<title>Sticky</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<style>
.top-0 {
top: 0 !important;
}
.bottom-0 {
@Driver86
Driver86 / config.php
Created August 20, 2016 14:20
Yii2 Config for CDN-assets with current versions from Composer
<?php
$bundles = [];
foreach(json_decode(file_get_contents(__DIR__ . '/composer.lock'))->packages as $package) {
if (!preg_match('#^bower-asset/(.+)$#', $package->name, $name) or !preg_match('#^v?(.+)$#', $package->version, $version)) {
continue;
}
$name = $name[1];
$version = $version[1];
switch ($name) {
@Driver86
Driver86 / uAPI.php
Last active April 20, 2020 12:36
uCoz API module for PHP
<?php
/**
* Набор методов для запроса к API uCoz.
*
* Пример использования на PHP-хостинге uCoz:
* <code>
* <?php
* $___notjson = 1;
* // Подключаем класс для работы с uAPI: