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 | |
use Ramsey\Uuid\Uuid; | |
$date = now()->parse("2024-01-01 00:00:00"); | |
while ($date->year < 2039) { | |
$dateProcess = (clone $date) | |
->endOfMonth() | |
->hour(23) | |
->minute(59) |
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
DELIMITER $$ | |
CREATE DEFINER = CURRENT_USER FUNCTION `uuidv7` () RETURNS UUID LANGUAGE SQL NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER | |
COMMENT 'Generate a UUID7 according to https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#variant_and_version_fields' | |
BEGIN | |
-- Obtain date with 4 milliseconds precision | |
SET @now = sysdate(4); | |
/* | |
UNIX_TIMESTAMP returns a 32bits number, so this function will not work after the Epochalypse, I am crossing my fingers and I hope that MySQL/MariaDB teams will move to 64bits timestamps before than 2038. | |
*/ | |
SET @time_sec = LPAD(HEX(TRUNCATE(UNIX_TIMESTAMP(@now), 0)), 9, '0'); |
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
/** | |
* Override Localstorage and Sessionstorage setItem prototype | |
*/ | |
Storage.prototype._setItem = Storage.prototype.setItem; | |
Storage.prototype.setItem = function(key, value) | |
{ | |
const isQuotaExceededError = (err: unknown) => err instanceof DOMException && | |
( | |
// Legacy Webkit |
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
/** | |
* Colorize helper. | |
*/ | |
class Colorize | |
{ | |
/** | |
* RGB array for a color. | |
* |
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
location /foo/ { | |
proxy_pass https://site.com/; | |
proxy_redirect off; | |
proxy_set_header Host site.com; | |
proxy_ssl_session_reuse off; | |
proxy_ssl_server_name on; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Accept-Encoding ""; | |
sub_filter "https://site.com" "https://reflected.to/foo"; |
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 | |
/** | |
* Class Model_CSVReader | |
* | |
* Parse and read CSV files as a stream keeping a low memory footprint | |
*/ | |
class Model_CSVReader | |
{ |
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 | |
function convertMemorySize($strval, string $to_unit = 'b') | |
{ | |
$strval = strtolower(str_replace(' ', '', $strval)); | |
$val = floatval($strval); | |
$to_unit = strtolower(trim($to_unit))[0]; | |
$from_unit = str_replace($val, '', $strval); | |
$from_unit = empty($from_unit) ? 'b' : trim($from_unit)[0]; | |
$units = 'kmgtph'; // (k)ilobyte, (m)egabyte, (g)igabyte and so on... |
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
// Simple upload from http://laravel-tricks.com/tricks/vuejs-simple-upload | |
<template> | |
<div> | |
<small>Change/Upload</small> | |
<input type="file" @change="onFileChange"> | |
<button class="btn btn-success btn-xs" @click="upload">Upload</button> | |
</div> | |
</template> |
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
CREATE DEFINER=`%`@`%` FUNCTION `LARAVEL_DECRYPT`( | |
`encstr` TEXT, | |
`raw_key` VARCHAR(255) | |
) | |
RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci | |
LANGUAGE SQL | |
DETERMINISTIC | |
READS SQL DATA | |
SQL SECURITY DEFINER |
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
-- Direct SELECT version | |
SELECT | |
FROM_BASE64(JSON_UNQUOTE(JSON_EXTRACT(CONVERT(FROM_BASE64(email) USING utf8), '$.iv'))) AS iv, | |
JSON_UNQUOTE(JSON_EXTRACT(CONVERT(FROM_BASE64(email) USING utf8), '$.value')) AS value, | |
FROM_BASE64('mysecretkey') AS pkey, | |
AES_DECRYPT(FROM_BASE64(JSON_UNQUOTE(JSON_EXTRACT(CONVERT(FROM_BASE64(email) USING utf8), '$.value'))), FROM_BASE64('mysecretkey'), FROM_BASE64(JSON_UNQUOTE(JSON_EXTRACT(CONVERT(FROM_BASE64(email) USING utf8), '$.iv')))) AS decrypted | |
-- Function version | |
CREATE FUNCTION `LARAVEL_DECRYPT`( |
NewerOlder