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 / working-with-python.md
Last active November 2, 2019 12:18
Working with python, managing versions and virtual environments
@Sarfarazsajjad
Sarfarazsajjad / angularjsenv.html
Created December 30, 2019 08:47
How to configure your AngularJS application using environment variables
<section class="posts wrapper">
<article class="post post featured">
<header>
<div class="feature"><span>Featured</span><i class="fa fa-bookmark fa-lg"></i></div>
<h2></h2>
<h1 id="posttitle"><a href="#">How to configure your AngularJS application using environment variables</a></h1>
<span>
Posted by <a href="https://twitter.com/jvandemo" target="_blank">Jurgen Van de Moere</a>
on <i class="fa fa-clock-o"></i> <time datetime="2016-02-24">February 24th, 2016</time>.
</span>
@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
@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 / 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 / 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 / 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);

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 / 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;
@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;