Skip to content

Instantly share code, notes, and snippets.

View alaminfirdows's full-sized avatar
🎯

Al-Amin Firdows alaminfirdows

🎯
View GitHub Profile
@alaminfirdows
alaminfirdows / event-bus.ts
Created October 30, 2024 09:20
event-bus
export type EventType = string | symbol;
// An event handler can take an optional event argument
// and should not return a value
export type Handler<T = unknown> = (event: T) => void;
export type WildcardHandler<T = Record<string, unknown>> = (
type: keyof T,
event: T[keyof T]
) => void;
@alaminfirdows
alaminfirdows / sms-service.php
Created September 21, 2024 14:06
sms-service.php
<?php
namespace App\Services;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class TextMessageService
document.getElementById("demo").innerHTML = "Hello JavaScript!";
Subject: [PATCH] Mastering Collections
---
Index: .tinkerwell/snippets/csv_surgery.php
===================================================================
diff --git a/.tinkerwell/snippets/csv_surgery.php b/.tinkerwell/snippets/csv_surgery.php
new file mode 100644
--- /dev/null (revision b28c56a0c000c8d1e80836cc75b13980ef53310b)
+++ b/.tinkerwell/snippets/csv_surgery.php (revision b28c56a0c000c8d1e80836cc75b13980ef53310b)
@@ -0,0 +1,13 @@
+<?php
@alaminfirdows
alaminfirdows / uses-of-service-class-in-laravel.md
Created May 30, 2024 04:21
uses-of-service-class-in-laravel.md

We can use service classes in laravel -

  • ⁠To Separate Complex Business Logic
  • ⁠Third-Party Service Integration
  • ⁠Improve Code Reusability
  • ⁠Separate Logics for Testing
  • ⁠Data Transformation (Convert Data from One Format to Another)
  • ⁠Service Layer Abstraction

Here are some examples:

import React, { useState } from 'react';
import axios from 'axios';
import classNames from 'classnames';
import { usePage } from '@inertiajs/react';
import { CommentType, PageProps, PostType, User } from '@/types';
import { formatDate } from '@/utils';
import CommentBox from './CommentBox';
type CommentProps = {
@alaminfirdows
alaminfirdows / has-many-deep.md
Last active May 1, 2024 10:45
Laravel Deep Relation Data Fetching

Deep Relations in Laravel: Handling Course-Episode Relationships

In Laravel, you often deal with relationships that span multiple tables. Here's a quick guide to counting related data through deep relations:

Option 1: Using hasManyThrough

When you store a direct reference like course_id in the episodes table, you can establish a deep relation using hasManyThrough. This is perfect for counting through intermediate relationships.

// file: Topic.php
<?php
use App\Services\ScrappingService;
$service = new ScrappingService();
$data = $service->fetchRecursive('https://google.com');
var_dump($data);
@alaminfirdows
alaminfirdows / outbound-email-with-cloudflare.md
Created January 24, 2024 07:20 — forked from irazasyed/outbound-email-with-cloudflare.md
Using Gmail SMTP with Cloudflare Email Routing: A Step-by-Step Guide

Using Gmail SMTP with Cloudflare Email Routing: Step-by-Step Guide

Learn how to send emails through Gmail SMTP with Cloudflare Email Routing in this comprehensive guide.

Step 1: Enable 2-Factor Authentication

To proceed with this method, ensure that you have enabled two-factor authentication for your Google account. If you haven't done so already, you can follow the link to set it up → Enable 2FA in your Google account.

Step 2: Create an App Password for Mail

<?php
$country_list = [
[
"name" => "Afghanistan",
"currency" => "AFN",
"continent" => "AS",
"code" => "AFG",
],
[