Skip to content

Instantly share code, notes, and snippets.

@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);
/**
* 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 / 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/)
*/
@sdiama
sdiama / laravelUpdateFieldOnce.php
Last active February 7, 2022 23:40
Laravel: Update a DB field only once
class Mymodel extends Model
{
public function setMyfieldAttribute($value)
{
if ($this->myfield) {
return;
}
$this->attributes['myfield'] = $value;
}
@sdiama
sdiama / LaravelExtensions.txt
Last active January 28, 2022 19:56
A list of must-install extensions for every Laravel project
- https://github.com/barryvdh/laravel-ide-helper
- https://github.com/barryvdh/laravel-debugbar
- https://github.com/beyondcode/laravel-query-detector
- https://github.com/spatie/laravel-backup
- https://github.com/glhd/laravel-dumper
@sdiama
sdiama / laravel-cloudflare
Created May 20, 2021 08:43
Get Real Client IP Behind Cloudflare in Laravel
/*
* @ AppServiceProvider add...
*/
use Symfony\Component\HttpFoundation\Request;
public function boot() {
/* This line set the Cloudflare's IP as a trusted proxy
Request::setTrustedProxies(
['REMOTE_ADDR'],
@sdiama
sdiama / custom1.m3u
Last active August 19, 2024 06:53
Custom Playlist 1
#EXTM3U
#EXTINF:-1 tvg-id="" tvg-name="" tvg-language="Hindi" tvg-logo="https://sportzwiki.com/wp-content/uploads/2016/07/Star-Sports.png" tvg-country="IN" tvg-url="" group-title="Sport",STAR SPORTS INDIA
https://www.youtube.com/watch?v=OByvQ3Qbhcc
#EXTINF:-1 tvg-id="" tvg-name="" tvg-language="" tvg-logo="https://images-na.ssl-images-amazon.com/images/I/71eK1Q3-dbL._AC_SL1500_.jpg" tvg-country="UN" tvg-url="" group-title="Uncategorized",NASA Live Stream Earth From Space / Real ISS Live Feed
https://www.youtube.com/watch?v=lx2CNP7kwhI
#EXTINF:-1 tvg-id="" tvg-name="" tvg-language="" tvg-logo="https://images-na.ssl-images-amazon.com/images/I/71eK1Q3-dbL._AC_SL1500_.jpg" tvg-country="UN" tvg-url="" group-title="Uncategorized",NASA Live Official Stream of NASA TV
https://www.youtube.com/watch?v=21X5lGlDOfg
#EXTINF:-1 tvg-id="" tvg-name="" tvg-language="" tvg-logo="https://images-na.ssl-images-amazon.com/images/I/71eK1Q3-dbL._AC_SL1500_.jpg" tvg-country="UN" tvg-url="" group-title="Uncategorized",NASA Live Offic
@sdiama
sdiama / adBlockDetect.html
Created May 19, 2020 10:05
Check if Adblock is present - Simple and Effective
<div class="adsbygoogle mycontent">This is my content</div>
<script>
setTimeout( function() {
if ( $('.mycontent').length > 0 ) {
if ( $('.mycontent').is(":hidden") || ! $(".mycontent").length ) {
alert('AdBlock Detected');
}
}
}, 1000);
@sdiama
sdiama / autoSizeText.js
Created May 19, 2020 09:15
Auto size text to fit within a container
/**
* @param {string} inSelector - The selector containing text to auto size.
*/
window.autoSizeText = function(inSelector) {
var el, elements, _i, _len, _results;
elements = $(inSelector);
if (elements.length < 0) {
return;
}
@sdiama
sdiama / althosting.txt
Last active October 13, 2023 21:00
A curated list of cheap "alternatives" to AWS, GCP, Azure hosting solutions
S3 Alternatives
---------------
- https://wasabi.com
- https://www.exoscale.com
- https://www.vultr.com
- https://www.arubacloud.com/
- https://www.digitalocean.com
- https://min.io/
- http://leo-project.net/
- https://www.backblaze.com/