Skip to content

Instantly share code, notes, and snippets.

Automating everything with

Ahmad Awais ⚡️ ahmadawais

Automating everything with
View GitHub Profile
ahmadawais / upload-a-file.MD
Created Jun 18, 2017 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API
View upload-a-file.MD

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

ahmadawais /
Last active Aug 5, 2022
Debug WordPress with Visual Studio Code | VSCode WordPress Debug Setup | WordPress xDebug Setup for Local by FlyWheel with VSCode | Part of the VSCode Learning Course →

VSCode WordPress Debugging Setup: WordPress Xdebug Setup for Local by FlyWheel with VSCode

Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User


  • Make sure your Local by FlyWheel WordPress install is a custom install
ahmadawais / regexCheatsheet.js
Created Jan 15, 2019 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
View regexCheatsheet.js
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
View gulpfile.js
* Gulpfile setup
* @since 1.0.0
* @authors Ahmad Awais, @digisavvy, @desaiuditd, @jb510, @dmassiani and @Maxlopez
* @package neat
* @forks _s & some-like-it-neat
ahmadawais /
Created Jul 1, 2022
The best way to install Node.js on Mac
# Node.
brew install node
brew install n
n lts
brew uninstall node # Not needed anymore from brew.
npm i -g git-open
ahmadawais / functions.php
Created Feb 20, 2015
Theme Activation Deactivation hooks for WordPress
View functions.php
* Provides activation/deactivation hook for wordpress theme.
* @author Ahmad Awais (
* Usage:
* ----------------------------------------------
* Include this file in your theme code.
* ----------------------------------------------
View Sendy NGNIX Config

Bascially all you really need is this

location / {
		try_files $uri $uri/ $uri.html $uri.php$is_args$query_string;

But to be on the safe side I added everything below:

ahmadawais /
Last active May 27, 2022
Install Sendy on DigitalOcean 2022

You can open the Marketplace tab and search for the current LAMP stack.

We will use the LAMP stack on a Basic plan for 5$/month.

php -v

# if php 8 then
ahmadawais /
Last active May 18, 2022
VSCode Node + Babel Recipe | Solves: vscode debug unexpected token import

VSCode Node + Babel Recipe

Debug Modern JavaScript with VSCode. Part of VSCode Course.

1. init a module:

npm init -y
ahmadawais / .zshrc
Created Jul 3, 2020
manpdf opens man pages as PDF
View .zshrc
# Open man page as PDF.
# USAGE: manpdf cat
function manpdf() {
man -t "${1}" | open -f -a /Applications/