Skip to content

Instantly share code, notes, and snippets.

View sanketmaru's full-sized avatar
🎧
Code & Music -- Infinite Loop

Sanket Maru sanketmaru

🎧
Code & Music -- Infinite Loop
View GitHub Profile
define([],function(){
var messages = {
'login': {
201: 'Email already taken',
400: 'Bad request',
503: 'The server is currently unavailable.'
}
};
return {
getMessage : function(prefix,statusCode) {
@sanketmaru
sanketmaru / sortable
Created October 6, 2014 17:59
Angular sortable links
http://a5hik.github.io/ng-sortable/#/sprint, https://github.com/a5hik/ng-sortable
https://github.com/angular-ui/ui-sortable/blob/master/demo/demo.js
@sanketmaru
sanketmaru / gist:aa6c32cf7e3653f5d9b6
Created October 10, 2014 14:41
query.atmosphere link
https://github.com/Atmosphere/atmosphere-samples/
@sanketmaru
sanketmaru / PermissionCheck
Created October 13, 2014 15:02
Permission Check
// Permissions.js
canAddFields: function(){
var returnVal = this.checkPermissions('isNotExternalUser','hasAddFieldsAccess');
return returnVal;
},
checkPermissions : function() {
var args = _.toArray(arguments);
var returnargs = _(args).every(lang.hitch(this, function(propName) {
return this[propName].bind(this).call();
// test for resolve
it('Should set isValid flag when user is not member of organization', function(done) {
var param = {
username: "sanketteam",
userId: 42808,
switchedOrgId: 7607 //varu@yopmail.com
}
var promise = usermanagement.checkOrganization(param); // returns a promise and uses the service code to return it
// this will be in case of resolve
@sanketmaru
sanketmaru / prototype-methods
Created May 21, 2015 03:10
Methods Constructor functionvs vs prototypes
Below is the jsperf test which creates instances when methods are defined inside constructor methods vs in prototype object.
Methods defined in prototype object is faster as each instance shares the same prototype object thats with the constructor function.
http://jsperf.com/prototype-vs-constructor-methods
@sanketmaru
sanketmaru / levenstein
Last active August 29, 2015 14:22
levenstein distance
// code has been copied from http://rosettacode.org/wiki/Levenshtein_distance#Java
package main.java;
public class Levenstein {
public static int distance(String a, String b) {
a = a.toLowerCase();
b = b.toLowerCase();
// i == 0
@sanketmaru
sanketmaru / links
Created July 7, 2015 12:27
javascript links
@sanketmaru
sanketmaru / isolated_scopes
Created July 27, 2015 16:53
Angular JS isolated scopes
JSFiddle demonstrating the isolated scopes
http://jsfiddle.net/juanmendez/k6chmnch/
@sanketmaru
sanketmaru / promise-sync-example.js
Last active July 20, 2016 12:06
promise-sync-example
Promise.map(emailParams,function(emailParam) {
logger.info('sending email to sendmail for %j', emailParam, {});
var host = "www.example.com/";
var html = jadeS.renderFile(template, {
farms: emailParam.farms,
headerImage: "image",
heading: emailParam.heading,
fieldFocusUrl: "someurl",
host: host
});