Skip to content

Instantly share code, notes, and snippets.

:octocat:
Working on his projects.

Shahzad Nawaz shahzadns

:octocat:
Working on his projects.
Block or report user

Report or block shahzadns

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
@shahzadns
shahzadns / $scope.$watch
Last active Dec 22, 2017
Watcher demonstration on angular 1.x scope properties - using built-in set, get of objects.
View $scope.$watch
/**
* Created on: Dec 22 2017
* Created by: Shahzad Nawaz
* Derived from different sources, Stakoverflow, Blogs, experience.
*/
console.clear(); //--snippets - clear prev run log
/* rocking Scope class for $watch only */
function Scope() {
@shahzadns
shahzadns / REST APIs response format
Last active Oct 14, 2017
Provides response format for RESTful APIs for both success and error scenarios.
View REST APIs response format
/**
* Created on: Oct 14 2017
* Created by: Shahzad Nawaz
* Derived from different sources, Stakoverflow, Blogs, experience.
* For more advanced handling - checkout https://github.com/adnan-kamili/rest-api-response-format
*/
// success response example - http status code - always 200
var res = {
@shahzadns
shahzadns / nodejs-enhanced-cjs-pattern
Last active Jan 23, 2017
This gist proposes an enhanced CommonJS module declaration pattern for NodeJS.
View nodejs-enhanced-cjs-pattern
/*
Date: Jan 19 2017
title: NodeJS enhanced CJS module pattern
author: Shahzad Nawaz
email: shahzadscs@gmail.com
Description:
This gist proposes an enhanced CommonJS module declaration pattern for nodeJS/express modules.
*/
@shahzadns
shahzadns / Random-alphanumeric-strings
Last active Dec 21, 2017
To get an array of randomly selected alpha-numeric characters, in JavaScript.
View Random-alphanumeric-strings
/**
* @title: Random-alphanumeric-strings
* @author: Shahzad Nawaz
* @dated: 7/16/2015.
*/
//e.g #1
var sixLenstrings = getRandomStrings(6, 2);
console.log(sixLenstrings);
// output: ["UlTl14", "JZRbSS"]
@shahzadns
shahzadns / AngularJS-BaseController.js
Last active Feb 16, 2019
This is an example for using a "Base Controller" in an AngularJS application, to get done some basic tasks like destroying $rootscope listeners, or any third-party component.
View AngularJS-BaseController.js
/**
* @title: `setting up BaseCtrl` in AngularJS 1.3.x
* @author: Shahzad Nawaz
* @dated: 2/28/2015.
*/
(function () {
'use strict';
/*Base Controller starts*/
You can’t perform that action at this time.