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 / 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 / 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 / .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>
@nasrulhazim
nasrulhazim / haproxy-cors.md
Last active November 5, 2024 12:03
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 / ArchitectureTest.php
Created August 14, 2024 01:19
Minimal Architecture Test using PestPHP
<?php
use App\Contracts\Builder;
use App\Contracts\Menu;
it('runs on PHP 8.3 or above')
->expect(phpversion())
->toBeGreaterThanOrEqual('8.3.0');
it('does not use debugging functions')
@nasrulhazim
nasrulhazim / macosx-install-php-oracle-oci8.md
Last active September 23, 2024 13:24 — forked from gido/macosx-install-php-oracle-oci8.md
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.12.6 - homebrew environnement - on PHP 7.2

Installation

This procedure is tested on Mac OS X 10.12.6

PHP 7.2 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@nasrulhazim
nasrulhazim / install-php-mssql-drivers-in-macos-mojave.md
Last active August 13, 2024 15:04
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 / DuskTestCase.php
Created May 21, 2019 00:16
Use SQLite in Laravel Dusk
<?php
namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
use Illuminate\Contracts\Console\Kernel;