Skip to content

Instantly share code, notes, and snippets.

View Shaz3e's full-sized avatar

Shahrukh Akhtar Shaz3e

View GitHub Profile
@Shaz3e
Shaz3e / READMME.MD
Last active November 27, 2024 22:47
Connect Private Repo

Pull github respository into cpanel and auto deploy recent chagnes

First check at cPanel SSH Access there should not be any key if there is any delete this than generate new key from terminal ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa

After generating key Go to .ssh directory and open .pub file and copy SSH Key Add this SSH Key into GITHUB REPO - Setting - Deploy Keys

Backup all files from public_html to _backup directory e.g. /home/_backup

@Shaz3e
Shaz3e / ServerMonitor.php
Last active November 24, 2024 23:53
Get Server Usage in Laravel - Unix-based systems (Linux, macOS)
<?php
// Create file inside Services folder
// php artisan make:class Services/ServerMonitor
namespace App\Services;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class ServerMonitor
{
@Shaz3e
Shaz3e / .env
Created September 10, 2024 19:32
Send Slack Notification in Laravel 11
SLACK_BOT_USER_OAUTH_TOKEN=
SLACK_BOT_USER_DEFAULT_CHANNEL=
@Shaz3e
Shaz3e / extensions.json
Last active September 23, 2024 20:42
My VS Code Extension List to code faster and easier
// .vscode/extensions.json
{
"recommendations": [
"rangav.vscode-thunder-client",
"bmewburn.vscode-intelephense-client",
"donjayamanne.githistory",
"DavidAnson.vscode-markdownlint",
"eamodio.gitlens",
"GitHub.vscode-pull-request-github",
"PKief.material-icon-theme",
@Shaz3e
Shaz3e / api.php
Last active July 25, 2024 22:19
Laravel API Versioning
<?php
// routes/api.php
use Illuminate\Support\Facades\Route;
Route::prefix('v1')->group(base_path('routes/api/v1.php'));
Route::prefix('v2')->group(base_path('routes/api/v2.php'));
@Shaz3e
Shaz3e / UserList.php
Created July 21, 2024 15:29
Pagination with Livewire without loosing serial number
// In your livewire blade
@php
// Get the current page number, default to 1 if not set
$currentPage = $dataSet->currentPage();
// Get the number of items per page
$perPage = $dataSet->perPage();
// Calculate the starting index
$i = ($currentPage - 1) * $perPage + 1;
@endphp
@Shaz3e
Shaz3e / AppServiceProvider.php
Last active July 14, 2024 21:06
Rate Limit in Laravel
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@Shaz3e
Shaz3e / readme.md
Last active November 2, 2023 13:19
How to Remove Foreign Key and Index from Database

instructions

  • Go to PHPMyAdmin
  • Select Database
  • Click Query Tab

Insert the following commands one by one make sure to change table_name with actual table name and column name with actual column name

First you need to remove foreign key from table.column

@Shaz3e
Shaz3e / WordPress Migration Update DB
Created October 29, 2023 21:22
After WordPress Migration you need to update wp.config.php and Database
#### Update the following commands in wp-config.php
```
define( 'WP_HOME', 'http://www.yoursitename.com' );
define( 'WP_SITEURL', 'http://www.yoursitename.com' );
```
#### PHPMyAdmin SQL Query
```
@Shaz3e
Shaz3e / Install Composer using MAMP's PHP.md
Created August 17, 2023 21:13 — forked from irazasyed/Install Composer using MAMP's PHP.md
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php