Skip to content

Instantly share code, notes, and snippets.

View mjawaids's full-sized avatar
🚀
Building the next generation of web applications

Muhammad Jawaid Shamshad mjawaids

🚀
Building the next generation of web applications
View GitHub Profile
@mjawaids
mjawaids / newsite
Last active October 21, 2025 14:27
`newsite` command to create new site in nginx config to be store in /usr/local/bin/newsite
#!/bin/bash
# Usage: sudo newsite project1.local /home/youruser/Sites/project1/public 8081
domain=$1
root=$2
port=${3:-8085}
conf="/etc/nginx/sites-available/$domain"
cat > "$conf" <<EOF
@mjawaids
mjawaids / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
@mjawaids
mjawaids / angular-client.html
Created September 13, 2014 09:18
Real-time AngularJS App
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.18/angular.min.js"></script>
<script src="angular-client.js"></script>