Skip to content

Instantly share code, notes, and snippets.

View faaezahmd's full-sized avatar

Faiz Ahmed faaezahmd

View GitHub Profile
const COUNTRY_CODES = [
{
name: 'Afghanistan +93',
id: '+93',
code: 'AF',
},
{
name: 'Aland Islands +358',
id: '+358',
code: 'AX',
@faaezahmd
faaezahmd / git_workflow_best_practices.md
Created September 26, 2022 12:13 — forked from calaway/git_workflow_best_practices.md
Git Workflow Best Practices

Git Branch Merging Best Practices

  1. After you've selected a feature to work on, create a branch in your local repo to build it in.
    • $ git checkout -b calaway/short_description_of_feature
  2. Implement the requested feature, make sure all tests are passing, and commit all changes in the new branch.
  3. Checkout the master branch locally.
    • $ git checkout master
  4. Pull down the master branch from GitHub to get the most up to date changes from others. If you practice git workflow as described here you should never have a merge conflict at this step.
    • $ git pull origin master
  5. Make sure all tests are passing on master and then checkout your new branch.
  • $ git checkout calaway/short_description_of_feature
// Lets us create Taxonomy for Custom Post Type
add_action( 'init', 'jobs_custom_taxonomy', 0 );
//create a custom taxonomy name it "type" for your posts
function jobs_custom_taxonomy() {
$labels = array(
'name' => _x( 'Types', 'taxonomy general name' ),
'singular_name' => _x( 'Type', 'taxonomy singular name' ),
'search_items' => __( 'Search Types' ),
'all_items' => __( 'All Types' ),
@faaezahmd
faaezahmd / asynchronous.js
Created April 4, 2019 08:58 — forked from joepie91/asynchronous.js
PHP vs Node.js: Synchronous vs Asynchronous
console.log("Before the first file is read.");
hypotheticalFileGetContents("sample.txt", function(fileContents){
// fileContents now contains the file contents, this function is only called when the file read in the background has finished
console.log("After the first file has completed reading.");
});
// You've now told it to start the first read, but it won't 'block' your script execution. It will do the read in the background, and immediately move on with the rest of your code.
console.log("Before the second file is read.");
hypotheticalFileGetContents("sample2.txt", function(fileContents){
@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");
@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 / 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:

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 / 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) :
@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>',