Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block faaezahmd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
faaezahmd / asynchronous.js
Created Apr 4, 2019 — forked from joepie91/asynchronous.js
PHP vs Node.js: Synchronous vs Asynchronous
View asynchronous.js
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 / copyToClipboard.js
Created Mar 5, 2019
A function that copies content from a div to clipboard
View copyToClipboard.js
// 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);; // select content before copying
faaezahmd / install virtualenv ubuntu
Created Dec 22, 2018 — forked from Geoyi/install virtualenv ubuntu
How to install virtual environment on ubuntu 16.04
View install virtualenv ubuntu

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
faaezahmd /
Created Dec 6, 2018 — forked from tim545/
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:

View select.js
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 / functions.php
Last active Oct 3, 2018
Get WP ACF-Plugin Field value from child category
View functions.php
* Get Advanced Custom Field value from child category
$cats = get_categories('child_of='.get_query_var('cat'));
foreach ($cats as $cat) :
faaezahmd / archive-cpt.php
Created Jul 9, 2018
Wordpress: Redirect to first post from custom post type
View archive-cpt.php
* Redirect to first post from CPT
$args = array(
'orderby' => 'menu_order',
'post_type' => '<POST-NAME>',
View data.json
"salary": 30000,
"deductions": {
"personal": 200,
"rent": 2500,
"tax": 400
View functions.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') );
View colors.json
color: "red",
value: "#f00"
color: "green",
value: "#0f0"
You can’t perform that action at this time.