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 / php-pools.md
Created February 24, 2021 02:35 — forked from holmberd/php-pools.md
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
@afiqiqmal
afiqiqmal / TwoFactorAuthenticationProvider.php
Last active January 25, 2021 12:42
TwoFactorAuthenticationProvider
<?php
class TwoFactorAuthenticationProvider
{
protected $engine;
public function __construct(Google2FA $engine)
{
$this->engine = $engine;
}
@afiqiqmal
afiqiqmal / TimestampProtection.php
Last active January 25, 2021 01:04
API extra security layer with Timestamp protection using Laravel
<?php
namespace App\Http\Middleware;
use \RuntimeException;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
class TimestampProtection
{
@afiqiqmal
afiqiqmal / AvoidDuplicateConstraintSoftDelete.php
Last active December 24, 2020 11:45
use Laravel SoftDeletes as boolean and avoid unique constraint problem
<?php
namespace App\Models\Traits;
use App\Observers\AvoidDuplicateConstraintSoftDeleteObserver;
trait AvoidDuplicateConstraintSoftDelete
{
@afiqiqmal
afiqiqmal / sources.list
Created November 27, 2020 02:10 — forked from ishad0w/sources.list
Ubuntu 20.04 LTS (Focal Fossa) -- Full sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
@afiqiqmal
afiqiqmal / ResponseMacro.php
Last active January 26, 2021 06:17
Additional response as macro
<?php
namespace App\Macros\Response;
use App\Http\Factory\JsonResponse;
use App\Macros\MacroContract;
use Illuminate\Http\Client\Response as ClientResponse;
use Illuminate\Support\Facades\Response as HttpResponse;
use Illuminate\Support\MessageBag;
@afiqiqmal
afiqiqmal / ImageMaliciousDetectionRule.php
Last active June 19, 2023 23:22
Simple Laravel Validation Rule for Image Content Validation.
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class ImageMaliciousDetectionRule implements Rule
{
protected $malicious_keywords = [
'\\/bin\\/bash',
@afiqiqmal
afiqiqmal / CreateImageFromText.php
Created October 8, 2020 04:09
Create an image from Text
<?php
class CreateImageFromText
{
/**
* @param string $text_string
* @param array $request
* @return string
*/
public static function createImageFromText(string $text_string, $request = [])
@afiqiqmal
afiqiqmal / clamav-mac.md
Created September 28, 2020 16:36 — forked from mendozao/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:

@afiqiqmal
afiqiqmal / BlueprintServiceProvider.php
Last active September 28, 2020 14:43
Laravel SoftDeletesBoolean
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class BlueprintMacroProvider extends ServiceProvider
{
/**
* Bootstrap the application services.