Skip to content

Instantly share code, notes, and snippets.

View muath-ye's full-sized avatar
🚀
npx muath

Muath Alsowadi muath-ye

🚀
npx muath
View GitHub Profile
@muath-ye
muath-ye / how-get-the-height-from-document-body-in-ckeditor.markdown
Created December 13, 2023 19:18
How get the height from document body in CKEDITOR
@muath-ye
muath-ye / auto-commit.bat
Created November 15, 2023 07:58
Auto commit your files with dynamic add and commit files on "app\Http\Validators" path and name the commit relatively to "app\Http\Validators" without ".php" (last for characters) [note the loop starts from "\app\Http\Validators" path]
:: Auto commit your files with dynamic add and commit files on "app\Http\Validators" path and name the commit relatively to "app\Http\Validators" without ".php" (last for characters) [note the loop starts from "\app\Http\Validators" path]
@echo off
setlocal enabledelayedexpansion
for /R .\app\Http\Validators %%i in (*.*) do (
set "relativePath=%%i"
set "relativePath=!relativePath:*\app\Http\Validators\=!"
set "relativePath=!relativePath:~0,-4!"
git add "%%i" & git commit -m "chore: update !relativePath!"
@muath-ye
muath-ye / arabic-slug-helper-for-laravel.php
Created November 5, 2023 10:37
This function works like \Str::slug of Laravel with support for Arabic strings
/**
* Generates a slug for URL from a given title.
*
* @param string $title The title to convert to a slug.
* @param string $separator The separator to use in the slug. Default is '-'.
* @param string|null $language The language to use for ASCII conversion. Default is null.
* @param array $dictionary An array of dictionary words to replace in the slug. Default is ['@' => 'at'].
* @return string The generated slug.
*/
@muath-ye
muath-ye / Setup VPS server with apache2 mysql php and phpmyadmin.md
Created September 25, 2023 20:36
Setup VPS server with apache2 mysql php and phpmyadmin

Prerequisties

Login

bmatovu@home-pc:~# ssh root@xxx.xxx.xxx.xxx

root@ubuntu-512mb-nyc3-01:~$ sudo su

root@ubuntu-512mb-nyc3-01:~#
@muath-ye
muath-ye / helpers.php
Created September 24, 2023 18:07
A Laravel helper to call a callable function conditionally
if (! function_exists('when')) {
/**
* Execute the given callback function if the condition is true.
*
* @param bool $condition
* @param callable $function
* @return mixed|null
*/
function when(bool $condition, callable $function)
{
@muath-ye
muath-ye / helpers.php
Created September 24, 2023 07:56
A Laravel help to access your models as functions like user()->first()
// Get all files from the App\Models directory
$modelFiles = glob(app_path('Models/*.php'));
foreach ($modelFiles as $modelFile) {
// Extract the filename without the .php extension for the function name
$modelName = strtolower(basename($modelFile, '.php'));
// Create the full class name
$fullClassName = "\\App\\Models\\" . ucfirst($modelName);
@muath-ye
muath-ye / about-muath.json
Last active August 22, 2023 12:29
npx about-muath => is a command to get info about me briefly :)
{
"content" : [
{
"label": "name",
"labelColor": "bright",
"value": "Muath Alsowadi",
"valueColor": "fgYellow"
},
{
"label": "email",
@muath-ye
muath-ye / TablePlus-Diagram.md
Created July 29, 2023 11:52
Generate a diagram with TablePlus

Install the plugin From Menu > Plugins > Manage Plugings or press Command + L.

image

After that, you can go to your database, choose the tables you want to generate the diagram for and right-click. You'll see the Generate diagram > Generate diagram option.

image

@muath-ye
muath-ye / Turbolinks + Laravel.MD
Created June 29, 2023 13:08 — forked from yaza-putu/Turbolinks + Laravel.MD
Install Turbolink Navigation in laravel
@muath-ye
muath-ye / google_map_example.html
Created June 22, 2023 12:14
Here is an example of using google maps
<!DOCTYPE html>
<html>
<head>
<title>Google Maps Example</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 400px;
width: 100%;