Skip to content

Instantly share code, notes, and snippets.

View chandanch's full-sized avatar
📘
Design, Build, Transform, Graph, Nxt Gen Solutions 😀

Chandan CH chandanch

📘
Design, Build, Transform, Graph, Nxt Gen Solutions 😀
View GitHub Profile
//What will be the output of the following code:
var myObject = {
foo: "bar",
func: function() {
var self = this;
console.log("outer func: this.foo = " + this.foo);
console.log("outer func: self.foo = " + self.foo);
(function() {
console.log("inner func: this.foo = " + this.foo);
console.log("inner func: self.foo = " + self.foo);
@chandanch
chandanch / API.md
Last active July 13, 2021 10:18 — forked from iros/API.md
Documenting your REST API

Show User

Returns json data about a single user.

  • URL

    /users/:id

  • Method:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body ng-app="demo" >
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
<script src="https://cdn.jsdelivr.net/chart.js/latest/Chart.min.js"></script>

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@chandanch
chandanch / server.js
Created March 2, 2018 05:56
Server config file for hosting static web apps
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080)
@chandanch
chandanch / dragdrop.html
Created November 20, 2017 12:56
A basic drag and drop example
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1 {
width: 350px;
height: 370px;
padding: 10px;
border: 1px solid #aaaaaa;
}
@chandanch
chandanch / index.html
Created November 16, 2017 08:33
modernizr.custom.js
<ul><li class="canvas">canvas</li><li class="cookies">cookies</li><li class="customelements">customelements</li><li class="setclasses">setclasses</li></ul>
@chandanch
chandanch / app.component.ts
Last active August 31, 2017 09:43
Handling events in root component
export class MyApp {
constructor(private platform : Platform) {
this.platform.Ready().then(() =>
this.handleEvents();
)
}
handleEvents() {
this.events.subscribe("navigation", (eventData)=> {
this.nav.push(eventData.page, eventData.data)
});
@chandanch
chandanch / NavigationService.ts
Last active August 31, 2017 08:50
Handling navigation using events
import { Injectable } from "@angular/core";
import { Events } from "ionic-angular";
/**
* @desc Handle all the navigations and modal popup using this services.
*/
@Injectable()
export class NavigationService {
constructor(events : Events) {
Injectable.providerInit( (providerCore) => {
})
<html lang = "en">
<head>
<link rel = "stylesheet"
href = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<script language = "javascript">