Skip to content

Instantly share code, notes, and snippets.

@sdiama
sdiama / laravel-tags-ignored.php
Last active October 31, 2022 06:00
Laravel macro to add 'tagsIgnored' method at Cache, to add tags only when tags are supported by the driver, without raising error
/*
* Ads method 'tagsIgnored' at Cache
* If tags are not supported by the driver, they will be ignored, instead of raising error
* Use as tags()
* ex. Instead of: Cache::tags(['tag1', 'tag2'])->put('key', 'value', 60);
* use: Cache::tagsIgnored(['tag1', 'tag2'])->put('key', 'value', 60);
*
* Warning: Basic knowledge of Mixins required (https://tutspack.com/the-magic-of-laravel-macro-collection-and-mixins-with-examples/)
*/
/**
* Conditionally compiles an array of classes and contrainnts into a CSS class string
*
* The array key contains the classes you wish to add
* The value is a boolean expression
*
* If the array element has a numeric key, it will always be included
*/
function arrayToCssClasses($inArrClasses)
@sdiama
sdiama / geeklish.sql
Created November 28, 2022 17:55 — forked from alxarch/geeklish.sql
Greek to greeklish for MySQL
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `greeklish`(input text charset utf8) RETURNS text CHARSET utf8
BEGIN
DECLARE result text charset utf8 DEFAULT '';
DECLARE len INT(4) DEFAULT 0;
DECLARE pos INT(4) DEFAULT 1;
DECLARE letter VARCHAR(10) charset utf8;
SET input = LOWER(input);
SET len = CHAR_LENGTH(input);