Skip to content

Instantly share code, notes, and snippets.

View thearyanahmed's full-sized avatar

Aryan Ahmed thearyanahmed

View GitHub Profile
//
// In the App\Exceptions\Handler.php class,update the `render` function as following
$exceptionCode = null;
if(config('app.env') !== 'production') {
$res = [
@thearyanahmed
thearyanahmed / php74-fpm.Dockerfile
Created March 24, 2020 13:07
PHP-FPM container for laravel app
FROM php:7.4-fpm
# Starting from scratch
RUN apt-get clean
RUN apt-get -y autoremove
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Update dependencies
RUN apt-get update
@thearyanahmed
thearyanahmed / gist:6f1e6154b8d0e259f142e256ed3aeb88
Created July 14, 2020 16:01
Do you seen any security issue here?
$query = "SELECT
country.country_name_eng,
SUM(CASE WHEN call.id IS NOT NULL THEN 1 ELSE 0 END) AS calls,
AVG(ISNULL(DATEDIFF(SECOND, call.start_time, call.end_time),0)) AS avg_difference
FROM country
-- we've used left join to include also countries without any call
LEFT JOIN city ON city.country_id = country.id
LEFT JOIN customer ON city.id = customer.city_id
LEFT JOIN call ON call.customer_id = customer.id
GROUP BY
@thearyanahmed
thearyanahmed / Complexity_is_the_worst_enemy_of_security
Last active July 19, 2020 17:54
The program takes hmac,nonce and host from request and $secret from the .env. If nonce is sent from the request, the value of the secret is changed, but if the $hmac doesn't match, you can't go to the exec() command portion on line 20. You have no way of knowing the $secret from .env. Do you see the bug? How can you bypass the security exploitin…
<?php
if(empty($_POST['hmac']) || empty($_POST['host'])) {
header('HTTP/1.0 400 Bad Request');
exit;
}
$secret = getenv('SECRET');
if (isset($_POST['nonce'])) {
@thearyanahmed
thearyanahmed / gist:14108f83c49a0168f0cd9abb8cf84d01
Created August 11, 2020 10:37
curl exception message/error from response body
json_decode((string) $e->getResponse()->getBody(),true)
@thearyanahmed
thearyanahmed / main.go
Last active June 16, 2021 19:10
Enable double ctrl + c for cancel context in go
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
go func() {
select {
@thearyanahmed
thearyanahmed / main.go
Created June 22, 2021 14:30 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@thearyanahmed
thearyanahmed / deployment_guide.md
Created November 29, 2021 02:10 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel
@thearyanahmed
thearyanahmed / latency.txt
Created March 19, 2022 08:35 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@thearyanahmed
thearyanahmed / nextjs-deploy.md
Created September 20, 2022 15:25 — forked from jjcodes78/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw