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 / secure_delete.bat
Created October 20, 2024 16:59
Bash script to securely overwrite and optionally delete files on Windows.
@echo off
setlocal
REM Function to securely overwrite a file, including binary files
:SecureOverwriteFile
echo Overwriting file: %1
set FILE_SIZE=0
for %%I in (%1) do set FILE_SIZE=%%~zI
REM Check if file size is greater than 0
@muath-ye
muath-ye / Toggle-MariaDBs-README.md
Created September 18, 2024 13:28
A complete Windows batch script to toggle between the two MariaDB services

Explanation

  1. Service Names and Paths: Sets variables for the service names and paths to their respective executables.
  2. Check Services: Uses sc query to check if each service is running.
  3. Toggle Services: If one service is running, it stops that service and starts the other. If neither service is running, it starts the first service by default.
  4. Execution: Uses sc stop and sc start to manage the services.
  5. Pause: Pauses the script at the end so you can see the output.

Save this script with a .bat extension, and run it with administrator privileges to toggle the MariaDB services.

@muath-ye
muath-ye / grim-reaper-s-used-cars-deal-wheel.markdown
Created September 17, 2024 06:27
Grim Reaper's Used Cars - Deal Wheel
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@muath-ye
muath-ye / neutral sorting.php
Created May 28, 2024 02:58
A Laravel migration to add neutral_sort function to MySQL and Postgres DB
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
@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 [email protected]

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)
{