Skip to content

Instantly share code, notes, and snippets.

View deepakshrma's full-sized avatar
🎯
Focusing

Deepak Vishwakarma deepakshrma

🎯
Focusing
View GitHub Profile
@deepakshrma
deepakshrma / Callbacks-jquery
Last active August 29, 2015 14:22
AngularJS Deferred & Promises [Part-1]- Basic Understanding
(function () {
var successHandler = function (data) {
console.info('Twitter\'s data: %j', data)
};
var ErrorHandler = function (error) {
console.info('Twitter\'s error:', error)
};
$.ajax({
url: 'https://api.twitter.com/1.1/search/tweets.json?q=%23freebandnames&since_id=24012619984051000&max_id=250126199840518145&result_type=mixed&count=4',
data: {
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Basic Vanilla JavaScript Youtube Player- With playlist</title>
</head>
<body>
<div class="player" style="width: 480px;height:360px;max-width: 50%;margin: 0 auto;">
<div id="youtube" style="width: 100%;height: 100%"></div>
<div class="controls" style="text-align: center;margin: 0 auto;">
@deepakshrma
deepakshrma / angular-network-connection.js
Last active February 24, 2016 15:25
angular-network-connection.js
/**
* @author: Deepak Vishwakarma
* @version: 0.0.1
* @copyright: deepak.m.shrma@gmail.com
*/
(function (window, document, angular, undefined) {
'use strict';
angular
.module('ngNetworkConnection', [])
@deepakshrma
deepakshrma / 1-sync-js-starving-example.js
Created July 2, 2016 21:11
Explaining sync code and slow io operation
var alert = console.info;
console.time('APP_CALL');
function firstAPI() {
alert('first api call');
var i =0;
var looptillIndex_sm =1000000;
var looptillIndex_lg =1000000000;
console.time('API_CALL')
//SyncIo
while(i < looptillIndex_lg-1){
'use strict';
var winstonConf = {};
function _define(config, name, value) {
Object.defineProperty(config, name, {
value: value,
enumerable: true,
writable: false,
configurable: false
});
@deepakshrma
deepakshrma / winston.index.js
Created July 27, 2016 15:37
Singleton logger
use strict';
var winston = require('winston');
var config = require('./winston.config');
winston.emitErrs = true;
var logger = new winston.Logger({
level: 'debug',
levels: config.defaults.levels,
handleExceptions: true,
transports: [
new winston.transports.Console(config.env[process.env.NODE_ENV] || config.env.development)
@deepakshrma
deepakshrma / .eslintrc.json
Last active December 22, 2020 14:58
.eslintrc.json- Basic configuration for ESLint
{
"env": {
"node": true
},
"globals":{
"anyglobal":true
},
"extends": "eslint:recommended",
"rules": {
"accessor-pairs": "error",
@deepakshrma
deepakshrma / Mapper.js
Last active April 9, 2020 11:19
Mapper.js - A small design pattern to avoid m x n loop back while finding some object from object array
/*
*
The MIT License (MIT)
Copyright (c) 2014 deepakshrma
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@deepakshrma
deepakshrma / PrioritySorting.js
Last active November 12, 2016 07:49
PrioritySorting
//Problem to sort and get port with minimum bandwith, based on switch priority(Select same switch first)
var ports = [{
id: 1,
switch: 'a',
availableBandWidth: 500
},{
id: 2,
switch: 'b',
availableBandWidth: 10
},{
@deepakshrma
deepakshrma / inherits.js
Created November 14, 2016 02:04
Javascript Inheritance
/**
* Created by intelligrape on 17/7/14.
*/
Function.prototype.inherits = function (parent) {
"use strict";
this.prototype = new parent();
this.constructor = this;
this.prototype.parent = parent.prototype
}
function User(name) {