This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.pushUnique = function(elem) { | |
if(this.indexOf(elem) == -1){ | |
this.push(elem); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function comb(len, states, rules){ | |
if(len>16){ | |
// return "out of limit, put force if you know better"; | |
} | |
var states = states || ["0","1"]; | |
var pos = []; | |
var powers = []; | |
for (var i = 0; i < len; i++) { | |
pos.push(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @Author: Sushil Jain | |
* @Date: 2017-02-13 17:06:37 | |
* @Last Modified by: csnodejs4 | |
* @Last Modified time: 2017-02-13 19:19:49 | |
*/ | |
'use strict'; | |
var input = "sushil"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findRankByString($input){ | |
$input = strtolower($input); | |
if(strlen($input) <= 1){ | |
return 1; | |
} | |
$chars = []; | |
for ($i = 0; $i < strlen($input); $i++) { | |
array_push($chars, $input[$i]); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Solve this one! | |
Q. There were 200 fishes in an aquarium, 99% of which were red. | |
How many red fishes must be removed to make | |
the percentage of red fishes 98%? | |
Solution: | |
Initially | |
total: 200, red: 198, percent:99% | |
If we remove 1 red fish - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var node = function (value){ | |
this.value = value; | |
this.next = null; | |
return this; | |
} | |
var list = function (){ | |
this.head = null; | |
return this; | |
} |
OlderNewer