Skip to content

Instantly share code, notes, and snippets.

Avatar
📟
Automating everything with NodeCLI.com

Ahmad Awais ⚡️ ahmadawais

📟
Automating everything with NodeCLI.com
View GitHub Profile
@ahmadawais
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
ahmadawais / flywheel-local-xdebug-vscode.md
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 → https://VSCode.pro
View flywheel-local-xdebug-vscode.md

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

🚅 TL;DR

  • Make sure your Local by FlyWheel WordPress install is a custom install
@ahmadawais
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
ahmadawais / node-mac.sh
Created Jul 1, 2022
The best way to install Node.js on Mac
View node-mac.sh
# Node.
brew install node
brew install n
n lts
brew uninstall node # Not needed anymore from brew.
npm i -g git-open
@ahmadawais
ahmadawais / functions.php
Created Feb 20, 2015
Theme Activation Deactivation hooks for WordPress
View functions.php
<?php
/**
* Provides activation/deactivation hook for wordpress theme.
*
* @author Ahmad Awais (http://AhmadAwais.com)
*
* Usage:
* ----------------------------------------------
* Include this file in your theme code.
* ----------------------------------------------
View Sendy NGNIX Config 2022.md

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
ahmadawais / sendy-install-digital-ocean.md
Last active May 27, 2022
Install Sendy on DigitalOcean 2022
View sendy-install-digital-ocean.md

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
ahmadawais / VSCode_Node_Babel_Recipe.md
Last active May 18, 2022
VSCode Node + Babel Recipe | Solves: vscode debug unexpected token import
View VSCode_Node_Babel_Recipe.md

VSCode Node + Babel Recipe

Debug Modern JavaScript with VSCode. Part of VSCode Course.

1. init a module:

npm init -y
@ahmadawais
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/Preview.app/
}