Instance | Branch |
---|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Utility class that pivots an array of records to an array of series | |
or an array of series to an array of records | |
Author : sfaut <https://github.com/sfaut> | |
Publication date : 2024-03-23 | |
Tested with PHP 8.3.3 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pivots an array of records | |
Author : sfaut <https://github.com/sfaut> | |
Publication date : 2023-04-09 | |
Tested with PHP 8.2.4 | |
*/ | |
function array_pivot(array $data, string $key_rows, string $key_columns, string $key_values, mixed $default_value = null): array | |
{ | |
// Transtyping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Returns the number of times pattern is matched in expression | |
-- Author : sfaut <https://github.com/sfaut> | |
-- Publication date : 2023-04-02 | |
-- Tested with MySQL 8.0.32 (@@sql_mode='ANSI,TRADITIONAL') | |
DELIMITER ;; | |
CREATE FUNCTION "REGEXP_COUNT"(expression TEXT, pattern TEXT) | |
RETURNS INT UNSIGNED | |
DETERMINISTIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get a random integer between start and stop excluded | |
-- Author : sfaut <https://github.com/sfaut> | |
-- Publication date : 2023-03-11 | |
-- Tested with MySQL 8.0.32 (@@sql_mode='ANSI,TRADITIONAL') | |
CREATE FUNCTION RANDOM_INTEGER(start INT, stop INT) | |
RETURNS INT | |
NOT DETERMINISTIC | |
NO SQL | |
COMMENT 'Get a random integer between start and stop excluded' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Converts a number of seconds since year 0 to a DATETIME | |
-- MySQL counterpart of TO_SECONDS() : https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_to-seconds | |
-- Author : sfaut <https://github.com/sfaut> | |
-- Publication date : 2023-03-05 | |
-- Tested with MySQL 8.0.32 (@@sql_mode='ANSI,TRADITIONAL') | |
CREATE FUNCTION FROM_SECONDS(seconds BIGINT) | |
RETURNS DATETIME | |
DETERMINISTIC | |
COMMENT 'Converts a number of seconds since year 0 to a DATETIME' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Removes diacritics from input string | |
-- Author : sfaut <https://github.com/sfaut> | |
-- Publication date : 2023-01-07 | |
-- Tested with MySQL 8.0.31 (@@sql_mode='ANSI,TRADITIONAL') | |
DELIMITER ;; | |
CREATE FUNCTION REMOVE_DIACRITICS(input TEXT) RETURNS TEXT CHARSET utf8mb4 | |
DETERMINISTIC | |
COMMENT 'Removes diacritics from input string' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Author : sfaut <https://github.com/sfaut> | |
// Publication date : 2022-09-06 | |
// Usage : | |
// <img src="polygon-svg.php?vertices=5" alt="A SVG pentagon!"> | |
$vertices = (int)$_GET['vertices'] ?? 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- HSL functions, manage HSL CSS colors | |
-- Author : sfaut <https://github.com/sfaut> | |
-- Publication date : 2022-09-05 | |
-- Tested with MySQL 8.0.30 (@@sql_mode='ANSI,TRADITIONAL') | |
/* | |
Summary : | |
hsl() Create a CSS HSL representation of a color |
NewerOlder