Skip to content

Instantly share code, notes, and snippets.

View Sarfarazsajjad's full-sized avatar
🤠
playing django

Sarfaraz Hussain Sarfarazsajjad

🤠
playing django
View GitHub Profile
@Sarfarazsajjad
Sarfarazsajjad / user-data.sh
Created June 14, 2021 09:58
Install Nginx and php on Amazon Linux 2
#!/bin/sh
sudo yum update -y
sudo amazon-linux-extras install nginx1 php7.4 -y
sudo yum clean metadata
sudo yum install git mariadb-server php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip} -y
# Back up existing config
sudo cp -R /etc/nginx /etc/nginx-backup
sudo chmod -R 777 /var/log
sudo chown -R ec2-user:ec2-user /usr/share/nginx/html
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php

Update 28 July 2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.

Update 23 May 2020: This guide is ALREADY OUTDATED and might no longer work with new versions of Ubuntu and VirtualBox. Please consider switching to the updated guide instead. I will no longer respond to the replies to this gist. Thank you.

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

@Sarfarazsajjad
Sarfarazsajjad / form-validation-2.html
Created September 8, 2020 04:25
Form Validation Assignment 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Form validation: Task 2</title>
<style>
body {
background-color: #fff;
color: #333;
font: 1em / 1.4 Helvetica Neue, Helvetica, Arial, sans-serif;
@Sarfarazsajjad
Sarfarazsajjad / form-validation-1.html
Created September 8, 2020 04:20
Form Validation Assignment 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Form validation: Task 1</title>
<style>
body {
background-color: #fff;
color: #333;
font: 1em / 1.4 Helvetica Neue, Helvetica, Arial, sans-serif;

How to install Xdebug on MacOS 10.15 Catalina (Xcode 11) When you try to build xdebug on macOS Catalina you will get errors like these:

phpize grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version:

@Sarfarazsajjad
Sarfarazsajjad / javascript.js
Created June 15, 2020 05:45
learning javascript
var a = 1;
let b = 2;
var c = "hello";
var d = "a";
d = 5;
d = 5.6;
var f = 5 + a;
console.log('f=',f);
@Sarfarazsajjad
Sarfarazsajjad / compress_and_upload.html
Last active June 15, 2020 03:51
html javascript compress image on browser then upload file
<!--
Preprocessing (scaling down) images on client side before uploading
Because people often upload 5MB big 3000x2000px PNGs that are then scaled down to 100x100px JPEGs on server - waste of time and bandwidth
1. user selects image(s)
2. script opens the image using FileReader API
3. script appends it to new Image object (not displayed at all actually)
4. new Image objects is drawn into new Canvas object, that is scaled down to desired dimensions
5. display the canvas, ie. a preview of the image to be uploaded
@Sarfarazsajjad
Sarfarazsajjad / ab.md
Created June 10, 2020 12:44
using apache ab for stress testing websites

Installation:

sudo apt-get install apache2-utils

GET example

ab -n 10 -c 2 http://dummy.restapiexample.com/api/v1/employees
@Sarfarazsajjad
Sarfarazsajjad / square-resizer.py
Created June 7, 2020 22:11
Resize Images into provided equal width and height. height and width of output images will be same.
import PIL
from PIL import Image
import os
import sys
def readf():
try:
input_dir = str(sys.argv[1].rstrip('/')) #path to img source folder
img_size = str(sys.argv[2]) #The image size (128, 256,etc)
output_dir = str(sys.argv[3].rstrip('/')) #output directory
print "starting...."
@Sarfarazsajjad
Sarfarazsajjad / resizer.py
Last active May 6, 2021 20:01
Resize images in multiple directories with Python
# example folder structure
# images
# ---- Tigers
# -------------1_tigers.jpg
# -------------2_tigers.jpg
# -------------2_tigers.png
# -------------n_tigers.jpg
# ---- Cats
# -------------1_cats.jpg
# -------------2_tcats.jpg