Skip to content

Instantly share code, notes, and snippets.

View ajaxray's full-sized avatar
🪁
Exploring

Anis uddin Ahmad ajaxray

🪁
Exploring
View GitHub Profile
@ajaxray
ajaxray / pr-review-guide.md
Created January 29, 2026 19:37
PR Review Red Flags for PHP / Laravel Application

PR Review Red Flags (PHP / Laravel Application)

1. Model::create([...]) instead of new Model()

Why it matters: create() bypasses explicit assignment and hides mass assignment logic, making code less transparent about which fields are being set. Using new Model() followed by explicit propertyassignment makes dependencies and validation clearer, improving testability and reducing accidental mass assignment vulnerabilities.

2. Business logic in controllers

Why it matters: Controllers should orchestrate, not implement business rules. Logic in controllers couples your business rules to HTTP concerns, making them untestable without mocking the entire request/response cycle. Extract to Services/Actions for reusability across jobs, commands, and queues.

3. Auth::user() in models

Why it matters: Models should be authentication-agnostic; calling Auth::user() couples them to the framework and HTTP context. Pass the authenticated user explicitly as a parameter, allowing models

@ajaxray
ajaxray / wezterm.lua
Created December 28, 2025 12:03
My Wezterm config
local wezterm = require 'wezterm'
local ai_helper = wezterm.plugin.require 'https://github.com/Michal1993r/ai-helper.wezterm'
local workspace_switcher = wezterm.plugin.require("https://github.com/MLFlexer/smart_workspace_switcher.wezterm")
local config = wezterm.config_builder()
config.color_scheme = 'Tokyo Night (Gogh)'
config.font = wezterm.font_with_fallback({ 'MesloLGS Nerd Font Mono', 'JetBrains Mono', 'Fira Mono', 'monospace' })
config.font_size = 16.0
config.line_height = 1.1
@ajaxray
ajaxray / README.md
Last active December 11, 2025 10:45
Check health status of (all or filtered) AWS Lambda Functions

AWS Lambda Health Monitoring Bash Script

This is a robust but simple cli script to check Lambda health using most efficient way. It verifies Lambda health using two distinct signals:

  • Configuration State: Is the function Active and Successful? (Deployability check)
  • Runtime Health: Has it generated Errors in CloudWatch recently? (Operational check)

How it works

This script retrieves all functions (or filters by a pattern), checks their deployment state, and queries CloudWatch for error metrics over the last 10 minutes.

@ajaxray
ajaxray / Laravel_MySQL_backup.md
Last active January 15, 2026 12:41
Backup MySQL Database to a date-time suffixed file, gzipped, with excluding specific set of tables

Laravel MySQL Backup Script with Table Exclusions

A robust Bash script to create compressed backups of a MySQL database while excluding high-churn, non-essential tables. This is specifically optimized for Laravel applications to avoid backing up massive log tables (Telescope, Activity Log, Sessions, etc.).

Features

  • Smart Exclusions: Automatically ignores data from tables that bloat backups but aren't critical for restoration (e.g., telescope_entries, sessions, failed_jobs, audit_logs).
  • Compression: Pipes output directly to gzip to save disk space.
  • Safety:
  • Automatically creates the backup directory if it doesn't exist.
@ajaxray
ajaxray / .vimrc
Last active November 22, 2025 14:50
My VIM config (.vimrc) file
set nocompatible
set ff=unix
set number
set ruler
set visualbell
set cursorline
set encoding=utf-8
filetype plugin indent on
syntax on
let mapleader=","
@ajaxray
ajaxray / ToasterController.php
Created August 1, 2025 19:30
Bagisto Teaster Notification testing - from frontend (in Vue component) and backend (session flash). Full tutorial: https://ajaxray.com/blog/toast-notifications-in-bagisto-the-complete-guide/
<?php
namespace Company\Utils\Http\Controllers\Admin;
use Illuminate\Routing\Controller;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class ToasterController extends Controller
@ajaxray
ajaxray / laravel-bagisto-2.2.mdc
Created July 21, 2025 09:29
Cursor rules file - Comprehensive development guidelines and best practices for building Bagisto 2.2 packages, covering modular architecture, view hooks, asset management, database patterns, and Vue.js integration.
---
description: Bagisto 2.2
globs: *.php, *.js, *.html
alwaysApply: false
---
## General Guideline
- Use conventions and guidelines described in Bagisto 2.2 Documentation
- Use Bagisto and Laravel provided artisan commands for generating files as much as possible.
@ajaxray
ajaxray / 1_README.md
Created July 2, 2024 10:52
Uploading large files in Laravel (Chunked upload)
@ajaxray
ajaxray / 1_README.md
Created July 2, 2024 09:55
Upload to S3 compliant storage directly from Frontend

Upload files to object storage / CDN directly from the Frontend

This is a demonstration of uploading files to S3 compliant storage. This implementation is using Laravel (backend) and AlpineJS (frontend).

How it works

  1. User selects a file on frontend
  2. Javascript makes a request to the backend for getting a TemporaryUploadUrl.
  3. On receiving the signed, temporary URL, Javascript pushes the file to S3 directly from front-end.
@ajaxray
ajaxray / MediaPropertyService.php
Last active March 25, 2024 09:01
[Laravel] Sorting Media Collection of Spacie Media Library by a custom property.
<?php
namespace App\Services;
use Illuminate\Support\Collection;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class MediaPropertyService
{