Skip to content

Instantly share code, notes, and snippets.

View nasrulhazim's full-sized avatar
🎯
Focusing

Nasrul Hazim nasrulhazim

🎯
Focusing
View GitHub Profile
@nasrulhazim
nasrulhazim / quotes.json
Created May 14, 2017 08:23
Quotes List in JSON Format
{
"quotes": [
{
"quote":"Life isn’t about getting and having, it’s about giving and being.","author":"Kevin Kruse"},
{
"quote":"Whatever the mind of man can conceive and believe, it can achieve.","author":"Napoleon Hill"},
{
"quote":"Strive not to be a success, but rather to be of value.","author":"Albert Einstein"},
{
@nasrulhazim
nasrulhazim / apidev-01.md
Last active August 25, 2026 11:31
API Basic

API Development with Vanilla PHP

In this tutorial, just want to expose the basic of API Development with plain PHP.

You should install https://www.getpostman.com/ before proceed with this tutorial.

Objectives

  1. Understand what is the headers
  2. Understand the Content-Type
@nasrulhazim
nasrulhazim / dry_n_skinny.md
Created February 17, 2017 01:37
Dry & Skinny Laravel Application

Dry & Skinny

  1. Fat Model & Skinny Controller

  2. Bus / Job Pattern

    • Command Bus > Jobs
      • A task take a small unit of work
      • NOT return a value
    • Further reading: CRUD & CQRS
    • Reusable, Skinny Controller as more reusable codes move to Job
@nasrulhazim
nasrulhazim / readme.md
Last active August 25, 2026 11:31
Using Middleware to Check Account Activation and Resend Activation E-mail
@nasrulhazim
nasrulhazim / readme.md
Last active August 25, 2026 11:31
Enable Account Activation in Order to Login to the System.
@nasrulhazim
nasrulhazim / readme.md
Last active August 25, 2026 11:31
Send Welcome Email Notification with Event and Listener

Send Welcome Email Notification with Event and Listener

Step 1

Create SendWelcomeEmailNotification notification

php artisan make:notification SendWelcomeEmailNotification
@nasrulhazim
nasrulhazim / ForgotPasswordController.php
Last active May 18, 2026 22:12
Laravel: Forgot Password Controller for API
<?php
namespace App\Http\Controllers\Api\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;
class ForgotPasswordController extends Controller
@nasrulhazim
nasrulhazim / README.md
Created October 30, 2025 12:52
Generate TOC for Markdown

Ensure there's folder docs/ in root directory. Then:

  1. Copy paste the code generate-toc.php.
  2. Run script php generate-toc.php
@nasrulhazim
nasrulhazim / get-all-public-holidays-for-malaysia-states.md
Last active October 20, 2025 09:45
Get All Public Holidays for Malaysia States

Get All Public Holidays for Malaysia States

Installation

  1. Install PhantomJs
    • For Ubuntu 16.04, click here
  2. Install CasperJS
    • install globally: npm install -g casperjs

Usage

@nasrulhazim
nasrulhazim / haproxy-cors.md
Last active July 10, 2025 15:09
Setting Up CORS in HAProxy
frontend localnodes
    bind *:80
    reqadd X-Forwarded-Proto:\ http

    # Add CORS headers when Origin header is present
    capture request header origin len 128
    http-response add-header Access-Control-Allow-Origin %[capture.req.hdr(0)] if { capture.req.hdr(0) -m found }
    rspadd Access-Control-Allow-Methods:\ GET,\ HEAD,\ OPTIONS,\ POST,\ PUT  if { capture.req.hdr(0) -m found }
    rspadd Access-Control-Allow-Credentials:\ true  if { capture.req.hdr(0) -m found }