Skip to content

Instantly share code, notes, and snippets.

View faaezahmd's full-sized avatar

Faiz Ahmed faaezahmd

View GitHub Profile
@faaezahmd
faaezahmd / mail-test.php
Created August 12, 2017 13:40
Script to test php mail functionality
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "TEST@YOURDOMAIN.COM";
$to = "TEST@YOURDOMAIN.COM";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
[
{
color: "red",
value: "#f00"
},
{
color: "green",
value: "#0f0"
},
{
<?php
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );
// get_template_directory_uri() refers to parent theme root directory
// get_stylesheet_directory_uri() refers to child theme root directory
function child_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style') );
{
"name":"John",
"age":30,
"salary": 30000,
"deductions": {
"personal": 200,
"rent": 2500,
"tax": 400
}
}
@faaezahmd
faaezahmd / archive-cpt.php
Created July 9, 2018 11:32
Wordpress: Redirect to first post from custom post type
<?php
/**
* Redirect to first post from CPT
*/
wp_reset_query();
$args = array(
'orderby' => 'menu_order',
'post_type' => '<POST-NAME>',
@faaezahmd
faaezahmd / functions.php
Last active October 3, 2018 19:11
Get WP ACF-Plugin Field value from child category
<?php
/*
* Get Advanced Custom Field value from child category
*/
$cats = get_categories('child_of='.get_query_var('cat'));
foreach ($cats as $cat) :
function select(selector) {
// Checks select(01) and select('')
if(typeof selector !== 'string' || selector.length < 2) {
return false;
}
var el = document.querySelector(selector) || null;
var allEl = document.querySelectorAll(selector) || [];
if (el === null && allEl.length === 0) {
@faaezahmd
faaezahmd / lg-jquery-app-struct.md
Created December 6, 2018 22:00 — forked from tim545/lg-jquery-app-struct.md
Structuring a large jQuery application

Structuring a large jQuery application

This document assumes you are building a traditional backend-heavy application as opposed to a frontend-heavy appliction which would typically use a framework like Angular or React. The use of these frameworks make this document irrelevant, however also require a change to your application architecture and a much larger overhead in order to get content onto a page, so as a simple way to build interactive web content a simple jquery based js stack will do fine.

Directory structure

It's important you use a directory structure which is impartial to your development environment, chosen server language (Python v. Java v. C# ...), and styling framwork (Twitter Bootstrap etc). This layer of separation means you can swap out the styles or the backend with minimal changes to the Js, simple and maintainable.

Here's an example from the project root:

@faaezahmd
faaezahmd / install virtualenv ubuntu 16.04.md
Created December 22, 2018 16:35 — forked from Geoyi/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@faaezahmd
faaezahmd / copyToClipboard.js
Created March 5, 2019 07:03
A function that copies content from a div to clipboard
// copy content from a div
function copyClipboard(query) {
var elm = document.querySelector(query);
// for Internet Explorer
if(document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(elm);
range.select(); // select content before copying
document.execCommand("Copy");