This file contains hidden or 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
/* | |
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace | |
so it's better encapsulated. Now you can have multiple random number generators | |
and they won't stomp all over eachother's state. | |
If you want to use this as a substitute for Math.random(), use the random() | |
method like so: | |
var m = new MersenneTwister(); |
This file contains hidden or 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 addThree(x) {return x + 3;}; | |
function composed(func) { | |
return function(x) { | |
return func(func(x)) | |
} | |
}; | |
composed(addThree)(4); |
This file contains hidden or 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
// => means:"evaluates into" | |
true && true => true; | |
true && false => false; | |
false && true => false; | |
false && false => false | |
----------------------------------------------------------------------------------------------------------- | |
false || false => false; | |
true || false => true; | |
false || true => true; |
This file contains hidden or 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 cashRegister = { | |
total:0, | |
add: function(itemCost){ | |
this.total += itemCost; | |
}, | |
scan: function(item, quantity) { | |
switch (item) { | |
case "eggs": this.add(0.98 * quantity); break; | |
case "milk": this.add(1.23 * quantity); break; | |
case "magazine": this.add(4.99 * quantity); break; |
This file contains hidden or 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
Add app.enable('trust proxy') as I have express running behind nginx: | |
------------------------------------------------------------------------------------------------------------ | |
Express behind proxies | |
Using Express behind a reverse proxy such as Varnish or Nginx is trivial, however it does require configuration. By enabling the "trust proxy" setting via app.enable('trust proxy'), Express will have knowledge that it's sitting behind a proxy and that the X-Forwarded-* header fields may be trusted, which otherwise may be easily spoofed. | |
Enabling this setting has several subtle effects. The first of which is that X-Forwarded-Proto may be set by the reverse proxy to tell the app that it is https or simply http. This value is reflected by req.protocol. | |
The second change this makes is the req.ip and req.ips values will be populated with X-Forwarded-For's list of addresses. | |
http://expressjs.com/guide.html |
This file contains hidden or 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
npm install stylus -g | |
than after issue the following command: | |
stylus -w && nodemon app.js | |
http://learnboost.github.com/stylus/docs/executable.html |
This file contains hidden or 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
body { | |
width: 100%; | |
clearfix(); | |
} |
This file contains hidden or 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
if i have this: | |
body { | |
font: 14px/1.5 Helvetica, arial, sans-serif; | |
#logo { | |
border-radius: 5px; | |
} | |
} | |
would be the same as |
This file contains hidden or 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
///////////////// | |
// Semantic.gs // for Stylus: http://learnboost.github.com/stylus/ | |
///////////////// | |
// Defaults which you can freely override | |
column-width = 60px | |
gutter-width = 20px | |
columns = 12 | |
// Utility variable — you should never need to modify this |
This file contains hidden or 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
//first, require nib in the beginning of the file. note that requiring stylus was needed due to the second code change below: | |
, nib = require('nib') | |
, stylus = require('stylus'); | |
//second change: | |
app.use(stylus.middleware({ src: __dirname + '/public', | |
compile: compile | |
})); | |
//third change, added the function compile: |
NewerOlder