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 May 17, 2023 17:37
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="English" tvg-logo="https://yt3.ggpht.com/a/AATXAJyj3PyYFeTXTXREbLUXC_tsl0Of-rRCJqM7Z_UH-w=s900-c-k-c0x00ffffff-no-rj" tvg-country="US" tvg-url="" group-title="Sport",ACCDN
http://iptv1.gripfs.tk:8080/channel/3d98dcb5/index.m3u8?q=eyJ1c2VySWQiOiJhZG1pbiJ9.KzXTu4AXEXc0KBtLr1OMj2VVhkIK3OJeN8fyEW9yEfqM6FYVxqw-URTKK028zIuM-fArvKHG_hW2LevFtPa7ug
#EXTINF:-1 tvg-id="" tvg-name="" tvg-language="English" tvg-logo="https://onmilwaukee.com/images/articles/my/mythbusters/mythbusters_fullsize_story1.jpg" tvg-country="US" tvg-url="" group-title="Entertainment",Mythbusters
http://iptv1.gripfs.tk:8080/channel/52a2b78a/index.m3u8?q=eyJ1c2VySWQiOiJhZG1pbiJ9.KzXTu4AXEXc0KBtLr1OMj2VVhkIK3OJeN8fyEW9yEfqM6FYVxqw-URTKK028zIuM-fArvKHG_hW2LevF
@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/