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 / 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
{
@ajaxray
ajaxray / ZipDirectory.php
Created March 23, 2024 08:36
Make Zip Archive of a directory (including all files in it recursively) in PHP
<?php
namespace App\Services;
class ZipDirectory
{
public function __construct(
private string $sourcePath,
private ?string $outputPath = null,
)
@ajaxray
ajaxray / dokan.sql
Created November 17, 2023 14:50
[Database Course] Sample schema
CREATE DATABASE `dokan`;
USE `dokan`;
CREATE TABLE customers (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100),
phone CHAR(15),
PASSWORD CHAR(32),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
@ajaxray
ajaxray / docker-compose.yml
Created November 15, 2023 08:56
[Database Course] MySQL 8.2 with Adminer
version: '3.7'
services:
db_course_mysql:
image: mysql:8.2
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: 123123
ports:
- 3309:3306
volumes:
@ajaxray
ajaxray / CreateUser.php
Last active June 11, 2023 15:14
A Laravel Artisan command for creating user with name, email and password
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
class CreateUser extends Command
{
@ajaxray
ajaxray / slatedocs_middle_clumn_code.md
Created February 7, 2023 20:03
How to show multiline code or JSON in the middle column in slatedocs/slate API Documentation

Showing multiline code or JSON in the middle column of slatedocs/slate API Documentation

Slate comes with 3 built in aside class (i.e. notice, warning and success) for showing blocked notes.

Let's a new aside class pre, that will show preformatted code in the middle column.

At the end of source/stylesheets/screen.css.scss, add the following lines:

// Style an aside like  to show code in middle column
@ajaxray
ajaxray / 1_Typora_Callout.md
Last active May 23, 2024 19:06
Making Notion style callout in Typora using custom CSS

Making Notion style callout in Typora using custom CSS

Do you want this type of callouts in typora? CleanShot 2022-12-03 at 19 02 01@2x

It's simple.

  • Copy the contents of callout.css at the bottom of your user base.user.css file.
    • You'll the find the base.user.css in typora theme folder. (Preference > Appearance > "Open theme folder")
  • If no base.user.css file is found in that folder, create one.
@ajaxray
ajaxray / backpack_customizations.css
Last active August 13, 2022 17:15
Make active/inactive status of simple filters clear and vivid (backpackforlaravel.com)
#bp-filters-navbar .nav-item[filter-type="simple"]:not(.active) a:before {
content: '️️️⬜️ '
}
#bp-filters-navbar .nav-item[filter-type="simple"].active a:before {
content: '️️️✅️ '
}