Skip to content

Instantly share code, notes, and snippets.

View haseeb2k9's full-sized avatar
🎯
Focusing

Haseeb Ashfaq haseeb2k9

🎯
Focusing
View GitHub Profile
@haseeb2k9
haseeb2k9 / install_imagemagic_with_heic.sh
Created February 27, 2024 10:00 — forked from hurricup/install_imagemagic_with_heic.sh
How to install ImageMagick 7.1.0-54 with HEIC and WEBP support on Ubuntu 20.04
# inspired by https://gist.github.com/rjnienaber/af47fccb8410926ba7ea35f96c3b87fd
# remove bundled ImageMagick
sudo apt remove imagemagick -y
# install base dependencies
sudo apt-get install -y \
build-essential \
git \
libde265-dev \
@haseeb2k9
haseeb2k9 / aws-cf-logs
Created February 12, 2021 07:41 — forked from shapeshed/aws-cf-logs
Fetch AWS Cloudfront Logs, decompress, combine into a single file and remove comments
#!/usr/bin/env bash
BUCKET=$1
CWD=$(pwd)
if [[ -n $1 ]]; then
aws s3 sync s3://$BUCKET/cf-logs .
cat *.gz > combined.log.gz
find $CWD ! -name 'combined.log.gz' -name '*.gz' -type f -exec rm -f {} +
gzip -d combined.log.gz
@haseeb2k9
haseeb2k9 / nginx-tuning.md
Created January 24, 2020 07:19 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@haseeb2k9
haseeb2k9 / nginx.conf
Created July 5, 2019 22:01 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@haseeb2k9
haseeb2k9 / axe-puppeteer-up-lambda.js
Created July 3, 2019 07:53 — forked from stephenmathieson/axe-puppeteer-up-lambda.js
An up-powered lambda fn for running axe-core
const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer');
const axeCore = require('axe-core');
const { createServer } = require('http');
const { parse: parseURL } = require('url');
const { PORT = 3000 } = process.env;
const analyze = async url => {
let browser;
# create a new user (john for this example)
# just enter a password when asked, confirm it, and the other steps are optionals
sudo adduser john
# give root user the ownership of john's home directory
sudo chown root:root /home/john
# edit the ssh configuration file
sudo vim /etc/ssh/sshd_config
@haseeb2k9
haseeb2k9 / gist:81004da966b8325731adbc5a847d65b3
Created June 9, 2018 19:41
Sublime Material theme Setting
// 1st install material theme
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/Mariana (SL).tmTheme",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
@haseeb2k9
haseeb2k9 / index.html
Created May 30, 2018 11:39
Pure CSS radial progress bar
<div class="set-size charts-container">
<div class="pie-wrapper progress-30">
<span class="label">30<span class="smaller">%</span></span>
<div class="pie">
<div class="left-side half-circle"></div>
<div class="right-side half-circle"></div>
</div>
</div>
<div class="pie-wrapper progress-60">
@haseeb2k9
haseeb2k9 / date_difference .php
Created May 21, 2018 20:47
calculate the difference between two dates using PHP
function time_diff_string($from, $to, $full = false) {
$from = new DateTime($from);
$to = new DateTime($to);
$diff = $to->diff($from);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => 'year',
@haseeb2k9
haseeb2k9 / simple-json-reponse.php
Created March 16, 2018 01:03 — forked from james2doyle/simple-json-reponse.php
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($message = null, $code = 200)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");