Skip to content

Instantly share code, notes, and snippets.

View singhmohancs's full-sized avatar
👨‍💻
Building with JavaScript, React, Angular, NodeJs, MongoDb and AWS Serverless

Mohan Singh singhmohancs

👨‍💻
Building with JavaScript, React, Angular, NodeJs, MongoDb and AWS Serverless
View GitHub Profile
@singhmohancs
singhmohancs / matchers.js
Created December 20, 2017 13:04 — forked from tomyam1/matchers.js
Custom matchers for Protractor and Jasmine 2
"use strict";
var _ = require('lodash');
/**
* Custom matchers for protractor and jasmine 2
*
* expect(el).toBePresent();
* expect(el).toBeDisplayed();
* expect(el).toContainText('text to contain');
@sunilmadaan07
sunilmadaan07 / bind.js
Last active July 11, 2017 07:05
bind, call and apply in javascript (brief description of bind, apply and call in javascript)
//@bind, apply, call in javascript
//@description
//@Question: If you want to use an arbitrary object as value of this, how will you do that?
/***********
Answer: There are at least three different ways to doing this by using bind, call and apply.
For example, I have a method named deductMontlyFee in the object monika
and by default value of this would be monika inside the method.
************/
/***********
If I bind the deductMontlyFee of monika with another object vikas
@singhmohancs
singhmohancs / AngularJS-Cachebusting.js
Created November 30, 2016 19:25 — forked from ProLoser/AngularJS-Cachebusting.js
Elegant cache-busting for AngularJS HTML assets
anglar.module('myApp',['ui']).config(["$provide", function($provide) {
return $provide.decorator("$http", ["$delegate", function($delegate) {
var get = $delegate.get;
$delegate.get = function(url, config) {
// Check is to avoid breaking AngularUI ui-bootstrap-tpls.js: "template/accordion/accordion-group.html"
if (!~url.indexOf('template/')) {
// Append ?v=[cacheBustVersion] to url
url += (url.indexOf("?") === -1 ? "?" : "&");
url += "v=" + cacheBustVersion;
}
@tjmehta
tjmehta / javascript-object-to-querystring.js
Last active January 28, 2024 22:35
Object to Querystring - JavaScript, JS, JSON
function objectToQuerystring (obj) {
return Object.keys.reduce(function (str, key, i) {
var delimiter, val;
delimiter = (i === 0) ? '?' : '&';
key = encodeURIComponent(key);
val = encodeURIComponent(obj[key]);
return [str, delimiter, key, '=', val].join('');
}, '');
}