Skip to content

Instantly share code, notes, and snippets.

View celyes's full-sized avatar
🎯
Focusing

Ilyes Chouia celyes

🎯
Focusing
View GitHub Profile
<?php
function generateTable(int $rows, int $cols): array
{
$table = [];
for ($i = 0; $i < $rows; $i++) {
$row = [];
for ($j = 0; $j < $cols; $j++) {
$row[] = mt_rand() / mt_getrandmax();
}
<?php
namespace Tests\Unit\Services;
use App\Jobs\ProcessProductImage;
use App\Models\Product;
use App\Services\SpreadsheetService;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Queue;
use Mockery;
<?php
namespace App\Http\Controllers;
use App\Models\Order;
class OrderController extends Controller
{
public function index()
{
@celyes
celyes / Http.php
Created November 24, 2023 20:49
Http status codes with description and names as a PHP enum
<?php
enum Http: int
{
// Informational
case CONTINUE = 100;
case SWITCHING_PROTOCOLS = 101;
case PROCESSING = 102;
// Success
_ _ _ ____ _ _
| | | | __ _ ___| | __ | __ ) __ _ ___| | _| |
| |_| |/ _` |/ __| |/ / | _ \ / _` |/ __| |/ / |
| _ | (_| | (__| < | |_) | (_| | (__| <|_|
|_| |_|\__,_|\___|_|\_\ |____/ \__,_|\___|_|\_(_)
A DIY Guide
<?php
$single = [1,2,3,4,5,6]; // single-dimension array
$multi = [
['walid', 26, 'Laravel'],
['fatah', 28, 'React.js'],
];
$multi2 = [
['walid', '26', 'Laravel'],
<?php
function filter_text($text): string
{
return preg_replace('/[^\x{0621}-\x{064A}\x{0660}-\x{0669}a-zA-Z0-9]+/ui', ' ', $text);
}
@celyes
celyes / curl.md
Created January 27, 2021 20:59 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>email</title>
</head>
<body style='background:#EEE'>
<table style='width:800px;margin:auto;background-color:#fff;border-collapse:collapse'>
<tr>
@celyes
celyes / linux-system-cleaner.sh
Last active November 28, 2020 21:26
Delete any unneeded files / dirs in your Linux (Debian/Ubuntu) system
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs