Skip to content

Instantly share code, notes, and snippets.

View baras's full-sized avatar

Yoav Baras baras

View GitHub Profile
@baras
baras / set-input-direction.js
Last active July 27, 2021 12:26
Set input / textarea direction to rtl if the field contains RTL characters.
$(document).on('input', 'input, textarea', function () {
var $el = $(this),
val = $el.val();
if (val.length) {
$el.css({direction: isRTL(val) ? 'rtl' : 'ltr'});
} else {
$el.css({direction: ""});
}
});
@baras
baras / download.php
Last active October 20, 2021 07:00 — forked from brasofilo/download.php
Force File Download with PHP
<?php
/*
* Force File Download.
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary.
*
*/
// Grab the requested file's name.