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
@afiqiqmal
afiqiqmal / supervisor_watchdog.sh
Created June 21, 2025 13:58
Monitor Supervisor Zombie Process
#!/bin/bash
# Variables
LOG_DIR="/var/log/supervisord_monitor"
LOG_FILE="$LOG_DIR/monitor.log"
SUPERVISORD_SERVICE="supervisord"
TIMEOUT_CMD="/usr/bin/timeout"
SUPERVISORCTL_CMD="/usr/local/bin/supervisorctl"
TIMEOUT=5 # seconds
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
@afiqiqmal
afiqiqmal / provision.sh
Created June 21, 2025 07:06
Initial setup for ubuntu + Laravel
#!/bin/bash
# Server Provisioning Script
# Edit these variables before running the script
################
### CONFIGURATION VARIABLES ###
################
USER="your_username" # Replace with desired username
USER_PASSWORD="your_secure_password" # Replace with desired user password
@afiqiqmal
afiqiqmal / default.conf
Created June 17, 2025 04:47
Nginx Configuration for Laravel
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
map $http_origin $cors_header {
default "";
~*^http://localhost:3000$ $http_origin;
}
@afiqiqmal
afiqiqmal / socso.json
Created May 19, 2025 06:57
SOSCO Rate
[
{
"min_wage": 0,
"max_wage": 30,
"employer_contribution_amount": 0.40,
"employee_contribution_amount": 0.10,
"category": "first"
},
{
"min_wage": 30.01,
@afiqiqmal
afiqiqmal / eis-rate.php
Created May 19, 2025 06:12
EIS Rate Contribution
<?php
return [
[
'min_wage' => 0,
'max_wage' => 30,
'employer_contribution_amount' => 5,
'employee_contribution_amount' => 5,
],
[
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|ide
@afiqiqmal
afiqiqmal / perfom.conf
Last active April 19, 2022 14:23
Detect Mobile Phone Agent in Nginx
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|ide
@afiqiqmal
afiqiqmal / GoogleGeocode.php
Created February 10, 2022 13:48
Helper class for geocode mapping
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Http;
class GoogleGeocode
{
private $url = "https://maps.googleapis.com/maps/api/geocode/json";
@afiqiqmal
afiqiqmal / jstimeout.js
Created November 8, 2021 00:29
SetTimeout using Vuex Store
export const state = () => ({
intervalList: []
})
export const mutations = {
addWithArgument(state, {callback, args}) {
if (callback.name === undefined) {
return;
}
@afiqiqmal
afiqiqmal / ufw.txt
Last active July 10, 2021 11:29
UFW Nginx
#Block IP
ufw insert 1 deny from 202.186.179.142 to any
#Numbered UFW
sudo ufw status numbered