Skip to content

Instantly share code, notes, and snippets.

View sushiljainam's full-sized avatar
💻
Working from home

Sushil Jain sushiljainam

💻
Working from home
View GitHub Profile
@sushiljainam
sushiljainam / rules.js
Created January 19, 2017 12:02
array of rules
var autoSelect = {};
autoSelect.rules = [
{"playerChipsRange": [1000, 10000], "stakes":[25, 50], "buyIn":[0,2000]},
{"playerChipsRange": [10001, 25000], "stakes":[50, 100], "buyIn":[0,2000]},
{"playerChipsRange": [25001, 50000], "stakes":[100, 200], "buyIn":[0,2000]},
{"playerChipsRange": [50001, 100000], "stakes":[250, 500], "buyIn":[0,2000]},
{"playerChipsRange": [100001, 250000], "stakes":[1000, 2000], "buyIn":[0,2000]},
{"playerChipsRange": [250001, 500000], "stakes":[5000, 10000], "buyIn":[0,2000]},
{"playerChipsRange": [500001, 1000000], "stakes":[10000, 20000], "buyIn":[0,2000]},
@sushiljainam
sushiljainam / arrayFilters.min.js
Last active December 27, 2016 11:08
object as filter to filter array of objects returning array of lesser objects: minified
Array.prototype.pushUnique=function(t){-1==this.indexOf(t)&&this.push(t)},Array.prototype.filterAny=function(t,n){var r=[];return this.forEach(function(n){for(var i in t)n[i]==t[i]&&r.pushUnique(n)}),"function"!=typeof n?r:void n(r)},Array.prototype.filterAll=function(t,n){var r=[];return this.forEach(function(n){var i=0;for(var o in t)n[o]==t[o]&&i++,i==Object.keys(t).length&&r.pushUnique(n)}),"function"!=typeof n?r:void n(r)};
@sushiljainam
sushiljainam / array_Filters.js
Last active December 27, 2016 11:06
object as filter to filter array of objects returning array of lesser objects
Array.prototype.pushUnique = function(elem) {
if(this.indexOf(elem) == -1){
this.push(elem);
}
}
//filters are in OR, any one true will add, array result will be returned
Array.prototype.filterAny = function (filter,callback) {
var result = [];
@sushiljainam
sushiljainam / js_array_pushUnique.js
Created December 27, 2016 09:48
enhancing array capabilities
Array.prototype.pushUnique = function(elem) {
if(this.indexOf(elem) == -1){
this.push(elem);
}
};
It's beautiful in its simplicity, as Terence Parr notes:
For the "MVC" of a web app, I make a direct analogy with the Smalltalk notion of MVC. The model is any of the logic or the database or any of the data itself. The view is simply how you lay the data out, how it is displayed. If you want a subset of some data, for example, my opinion is that is a responsibility of the model. The model knows how to make a subset. You should not be asking your graphics designer to filter a list according to age or some other criteria.
The controller in a web app is a bit more complicated, because it has two parts. The first part is the web server (such as a servlet container) that maps incoming HTTP URL requests to a particular handler for that request. The second part is those handlers themselves, which are in fact often called "controllers." So the C in a web app MVC includes both the web server "overlord" that routes requests to handlers and the logic of those handlers themselves, which pull the data from the database a