Skip to content

Instantly share code, notes, and snippets.

View nasrulhazim's full-sized avatar
🎯
Focusing

Nasrul Hazim Bin Mohamad nasrulhazim

🎯
Focusing
View GitHub Profile
@nasrulhazim
nasrulhazim / get-all-public-holidays-for-malaysia-states.md
Last active October 4, 2023 08:08
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 / AppServiceProvider.php
Last active October 1, 2023 15:47
Laravel Base64 and Base64 Image Validator
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
@nasrulhazim
nasrulhazim / import-huge-sql.sh
Created October 29, 2020 11:59
Import Large MySQL File
# create prepend sql commands
echo "set autocommit=0;set unique_checks=0;set foreign_key_checks=0;" > prepend.sql
# prepend huge.sql above commands
cat huge.sql >> prepend.sql
# create append sql commands
echo "set autocommit=1;set unique_checks=1;set foreign_key_checks=1;" > append.sql
# prepend huge.sql with append.sql
@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 / blockchain.go
Created June 21, 2023 12:28 — forked from LordGhostX/blockchain.go
Blockchain POC with Golang
package main
import (
"crypto/sha256"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
)
@nasrulhazim
nasrulhazim / rocket-chat.reset-user-details.md
Created July 24, 2017 09:25
Rocket.Chat: Reset User Details

Connect to MongoDB

sudo /snap/rocketchat-server/current/bin/mongo

Select Rocket.Chat Database

use parties
@nasrulhazim
nasrulhazim / RouteServiceProvider.php
Last active September 25, 2022 05:15
Organise Laravel Routes
<?php
collect(
glob(base_path('/routes/web/*.php'))
)->each(function ($path) {
require $path;
});
@nasrulhazim
nasrulhazim / time_period.php
Created June 20, 2021 03:33
Simple Time Period Helper
<?php
if (! function_exists('time_period')) {
function time_period()
{
// Morning: 6 a.m.-noon
// Afternoon: noon-6 p.m.
// Evening: 6-9 p.m.
$value = (int) date('H');
@nasrulhazim
nasrulhazim / ContractException.php
Last active August 11, 2022 08:18
Custom Exception method
<?php
namespace App\Exceptions;
use Exception;
class ContractException extends Exception
{
public static function throwIf(bool $condition, string $method, ...$args)
{
@nasrulhazim
nasrulhazim / MemoryUtilisation.php
Last active April 6, 2022 08:23
Get Memory Utilisation
<?php
namespace App\Actions;
class MemoryUtilisation
{
public $units = ['B','KB','MB','GB','TB','PB'];
public $start;
public $startTime;
public $end;