Skip to content

Instantly share code, notes, and snippets.

View sohag-pro's full-sized avatar
:octocat:
Busy with PHP, JS, GO 🐙 Certified Laravel Dev

Sohag Hasan sohag-pro

:octocat:
Busy with PHP, JS, GO 🐙 Certified Laravel Dev
View GitHub Profile
@sohag-pro
sohag-pro / gist:c35de3244af42761ee47bc0ad9265867
Last active July 18, 2024 05:12
Official mail for Leave Request
To Whom It May Concern,
I am writing to inform you that I have been experiencing severe headaches and joint pain since this morning. Despite having taken general medication from the first aid kit, my condition has not improved.
Therefore, I kindly request to be granted leave for today to rest and recover.
Sincerely,
Sohag Hasan
Tech Lead
MobyPay
@sohag-pro
sohag-pro / app.php
Created May 23, 2024 16:12
Laravel 11 Custom json exception in bootstrap/app.php
<?php
use Illuminate\Http\Request;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure( basePath: dirname( __DIR__ ) )
->withRouting(
web: __DIR__ . '/../routes/web.php',
@sohag-pro
sohag-pro / settings.jsonc
Created May 17, 2024 12:25 — forked from nickytonline/settings.jsonc
Latest VS Code Settings
{
// miscellaneous
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always",
"diffEditor.ignoreTrimWhitespace": false,
// window
"window.title": "🦙⚡🫡 – ${activeEditorShort}${separator}${rootName} – 🫡⚡🦙",
"window.clickThroughInactive": false,
@sohag-pro
sohag-pro / docker-compose.yml
Last active July 3, 2023 09:54
Laravel SAIL with PHPMyAdmin
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.2
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.2/app
extra_hosts:
@sohag-pro
sohag-pro / laravelTesting.sh
Created December 22, 2022 08:21
Laravel Testing Commands and Tips
# testing env
.env.testing
# In memory sqlite db
DB_CONNECTION=sqlite
DB_DATABASE=:memory: # in memory sqlite db
# Look for some text
$this->assertSee('text');
@sohag-pro
sohag-pro / csv_to_array.php
Created December 7, 2022 07:04
Read CSV to PHP Array
<?php
$file = fopen( 'file.csv', 'r' );
$csv = [];
while ( ( $row = fgetcsv( $file ) ) !== FALSE ) {
$csv[] = array_map( function ( $value ) {
return preg_replace(
['/"/', "/\r?\n/", '/[\x00-\x1F\x80-\xFF]/'],
['""', '<br>', ''],
$value
@sohag-pro
sohag-pro / MakeServiceCommand.php
Created September 8, 2022 10:47
Create "php artisan make:service ExampleService" command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\GeneratorCommand;
class MakeServiceCommand extends GeneratorCommand {
/**
* The name and signature of the console command.
@sohag-pro
sohag-pro / HasUuid.php
Created September 8, 2022 10:43
UUID helper trait for laravel. Just use it and make migration column type uuid
<?php
namespace App\Traits;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
trait HasUuid {
/**
* Get the value indicating whether the IDs are incrementing.
@sohag-pro
sohag-pro / FileService.php
Created September 8, 2022 10:35
File service to easily handle upload and delete files in Laravel
// app/Services/FileService.php
<?php
namespace App\Services;
use Illuminate\Http\File;
use Illuminate\Support\Facades\Storage;
class FileService {
/**
@sohag-pro
sohag-pro / ubuntu.sh
Last active September 30, 2023 09:11
Ubuntu usefull commands
# Change Default php version for cli
sudo update-alternatives --config php
# Update composer to V2
sudo composer self-update --2
# Update composer to V1
sudo composer self-update --1