Skip to content

Instantly share code, notes, and snippets.

View m-ostadi's full-sized avatar

Mohammad Ostadi m-ostadi

  • Urmia, Iran
View GitHub Profile
@m-ostadi
m-ostadi / gist:e7951390738c7e40f355d1de5f067c89
Created April 20, 2024 06:48
fluentd syslog logger config for laravel
//add this to config/logging.php
'fluent' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => \Monolog\Handler\SyslogUdpHandler::class,
'handler_with' => [
'host' => env('FLUENTD_SYSLOG_HOST', '127.0.0.1'),
'port' => env('FLUENTD_SYSLOG_PORT', ''),
'rfc' => \Monolog\Handler\SyslogUdpHandler::RFC3164,
'ident' => env('FLUENTD_SYSLOG_IDENT', 'laravel'),
@m-ostadi
m-ostadi / fa_ar_num_to_en.php
Last active January 11, 2023 21:57
convert persian and arabic numbers to english in php
<?php
function number2latin($str)
{
$en_digits = ['0','0','1','1','2','2','3','3','4','4','5','5','6','6','7','7','8','8','9','9'];
$fa_ar_digits = ['٠','۰','۱','١','٢','۲','٣','۳','٤','۴','٥','۵','٦','۶','٧','۷','٨','۸','٩','۹'];
$str = str_replace($fa_ar_digits, $en_digits, $str);
return $str;
}
@m-ostadi
m-ostadi / regex.txt
Created July 1, 2022 13:43
regex for adding tailwind prefix to existing tailwind classes
in your editor (i used phpstorm ctrl+shift+f for find and replace in all files of a specific folder):
find : (?<=class=["'][^"']*)([0-9a-zA-Z_-]+\s*)(?=[^"']*["'])
replace : tw-$1
@m-ostadi
m-ostadi / PartialUpdateJson.php
Last active October 7, 2021 17:57
Laravel eloquent cast for partial updating JSON fields
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class PartialUpdateJson implements CastsAttributes
{
/**
* Cast the given value.
*
@m-ostadi
m-ostadi / php-telegram-logger.php
Created June 13, 2021 09:35
simple telegram logger in php
/**
* @param $input mixed
*/
function telegramLogger($input){
$bot_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; //get from @botfather
$id = 'xxxxxxxxxx'; //reciever telegram id (not username)
ob_start();
var_dump($input);