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 / 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 }
@nasrulhazim
nasrulhazim / change-mysql-data-directory-in-osx.md
Created April 8, 2017 10:20
Change MySQL Data Directory in OSX

Stop the MySQL Service

I'm using Homebrew to stop the service

brew services stop mysql

Locate MySQL Data Directory

@nasrulhazim
nasrulhazim / install-php-mssql-drivers-in-macos-mojave.md
Last active June 10, 2025 22:07
Install PHP MSSQL Driver in MacOS (Mojave)

Installing Brew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Installing MSSQL Tools

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
@nasrulhazim
nasrulhazim / tasks.yaml
Created March 8, 2025 00:13
Tasks Open API Specification
openapi: 3.1.0
info:
title: Tasks API
description: A simple CRUD API for managing tasks.
version: 1.0.0
contact:
name: API Support
email: support@tasks.com
license:
name: MIT
@nasrulhazim
nasrulhazim / chirps.yaml
Created March 8, 2025 00:05
Laravel Bootcamp Chirp OpenAPI Specification
openapi: 3.1.0
info:
title: Chirps API
description: |-
Welcome to the Laravel Bootcamp! In this guide we will walk through building a modern Laravel application from scratch. To explore the framework, we'll build a microblogging platform called Chirper.
termsOfService: http://chirps.com/terms/
contact:
email: api@chirps.com
license:
@nasrulhazim
nasrulhazim / 01.md
Last active March 4, 2025 23:55
Laravel Default API Login

Setup

Migration

Create new migration script:

php artisan make:migration add_api_token --table=users
@nasrulhazim
nasrulhazim / .htaccess
Last active December 5, 2024 01:43
Laravel .htaccess with Security & Optimisation
# Directory Listing
Options -Indexes
<IfModule mod_security.c>
# Server Information Disclosure
ServerTokens Prod
ServerSignature Off
SecServerSignature " "
</IfModule>