Skip to content

Instantly share code, notes, and snippets.

View afiqiqmal's full-sized avatar
👻
I may be slow to respond.

Hafiq afiqiqmal

👻
I may be slow to respond.
View GitHub Profile
@xmhafiz
xmhafiz / Bash alias
Last active November 6, 2017 01:38
Some lazy bash aliases (append to ~/.bash_profile)
#laravel
alias pa="php artisan"
#git
alias gi="git init"
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gac="git add .;git commit -m"
alias gp="git push"
@xmhafiz
xmhafiz / App\Http\Controllers\Controller.php
Last active November 8, 2017 14:40
Laravel 5.4 - Custom default validation error output and status code to 400
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Validation\Validator;
@nasrulhazim
nasrulhazim / abbrv.php
Created November 18, 2017 03:41
Generate Abbreviation Based on Given String
<?php
if (!function_exists('abbrv')) {
function abbrv($value)
{
$removeNonAlphanumeric = preg_replace("/[^A-Za-z0-9 ]/", '', $value);
$removeVowels = str_replace(
['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U', ' '],
'',
$removeNonAlphanumeric);
@nasrulhazim
nasrulhazim / malaysia_holidays.json
Created January 6, 2017 06:59 — forked from alienxp03/malaysia_holidays.json
Malaysia 2017 Holidays (including states)
[
{
"name": "New Years Day",
"date": "01/01/2017",
"states": [
"Kuala Lumpur",
"Labuan",
"Malacca",
"Negeri Sembilan",
"Pahang",
@nasrulhazim
nasrulhazim / generate_reference_number.php
Created November 18, 2017 03:54
Generate Document Reference Number
<?php
/**
* I use abbrv() function in https://gist.github.com/nasrulhazim/df8f4046cceb37ab61fa5d5c0c65dba6
* And for str_random() from Laravel Framework
**/
if (!function_exists('generate_reference_number')) {
function generate_reference_number($module_label, $module_component = null)
{
if (empty($module_label)) {
@afiqiqmal
afiqiqmal / ModelRouteUrlGenerator.php
Last active April 22, 2019 04:23
Leverage Eloquent To Prepare Your URLs LARAVEL
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 21/04/2019
* Time: 7:17 PM
*/
namespace App\Http\Traits;
@azraai
azraai / Fpx.php
Created July 6, 2015 07:24
Fpx.php
<?php
class Fpx {
public $merchant_id;
public $prefix;
public $order_number;
public $user_email;
public $description;
public $amount;
public $exchange_id;
@afiqiqmal
afiqiqmal / SoapRequest.php
Last active August 8, 2019 12:08
Soap Request Using PHP which focus on SOAP using WSSE Security and Basic Authenticattion
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 28/02/2018
* Time: 9:30 AM
*/
namespace App\Library;
@nasrulhazim
nasrulhazim / MinifyHtml.php
Created February 25, 2018 12:29
Minify HTML
<?php
namespace App\Http\Middleware;
use Closure;
class MinifyHtml
{
/**
* Handle an incoming request.
@crynobone
crynobone / Birthdate Parser.js
Created March 10, 2011 21:24
Malaysia Indentification Card Number to Birthdate
var ic = '090303086521';
if(ic.match(/^(\d{2})(\d{2})(\d{2})-?\d{2}-?\d{4}$/)) {
var year = RegExp.$1;
var month = RegExp.$2;
var day = RegExp.$3;
console.log(year, month, day);
var now = new Date().getFullYear().toString();