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
@holmberd
holmberd / php-pools.md
Last active April 19, 2024 07:24
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@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)) {
@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);
@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"
@zabaala
zabaala / BindDatabaseServiceProvider.php
Last active March 2, 2021 07:50
php artisan db:log <start> <stop>
<?php
namespace App\Commands\Database;
use Illuminate\Support\ServiceProvider;
class BindDatabaseServiceProvider extends ServiceProvider
{
public function boot()
{
@mendozao
mendozao / clamav-mac.md
Last active March 27, 2024 05:38 — forked from Uchean/clamav-mac.md
Get ClamAV running on Mac OS X (using Homebrew)

Get ClamAV running on Mac OS X (using Homebrew)

The easiest way to get the ClamAV package is using Homebrew

$ brew install clamav

Before trying to start the clamd daemon, you'll need a copy of the ClamAV databases.

Inside /your/location/to/brew/etc/clamav, you'll see 2 files:

@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;
@reline
reline / AsyncGeocoder.java
Last active April 18, 2021 02:14
Async RxAndroid wrapper for Android's Geocoder
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import java.io.IOException;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
@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 / 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