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
| SRC="/opt/local/src/mongodb/LATEST/"; | |
| DEST="/opt/local/bin/"; | |
| for file in $(/bin/ls $SRC); | |
| do | |
| [[ -f $DEST$file ]] && rm $DEST$file; | |
| ln -s $SRC$file $DEST$file; | |
| done |
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 express = require("express"); | |
| var app = express.createServer(); | |
| app.listen(3000); | |
| console.log(app.address()); // { port: 3000, family: n, address: '0.0.0.0' } | |
| setTimeout((function(){ | |
| app.close() | |
| console.log(app.address()); // null | |
| }), 3000); |
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
| app.get('/', function(req, res){ | |
| var ua = req.header('user-agent'); | |
| if(/mobile/i.test(ua)) { | |
| res.render('mobile.html'); | |
| } else { | |
| res.render('desktop.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
| # logger = require('logger').create() | |
| # logger.info("blah") | |
| # => [2011-3-3T20:24:4.810 info (5021)] blah | |
| # logger.debug("boom") | |
| # => | |
| # logger.level = Logger.levels.debug | |
| # logger.debug(function() { return "booom" }) | |
| # => [2011-3-3T20:24:4.810 error (5021)] booom | |
| class Logger | |
| constructor: (options) -> |
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
| $.ajax({ | |
| type: "POST", | |
| url: url, | |
| data: dataObj, | |
| success: function(data){ }, | |
| error: function(err){ } | |
| }) |
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
| #!/usr/bin/env coffee | |
| ticks = ['▁','▂','▃','▄','▅','▆','▇','█'] | |
| exports.clark = (data) -> | |
| m = Math.min data... | |
| n = (Math.max(data...)-m)/(ticks.length - 1) | |
| (ticks[(t-m)/n >> 0] for t in data).join('') | |
| if require.main == module | |
| data = process.argv |
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 O = Hapi.Types.Object; | |
| var N = Hapi.Types.Number; | |
| var schema = { | |
| a: O({ | |
| b: N(), | |
| c: N(), | |
| d: O({ | |
| e: N(), | |
| f: N() |
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 passport = require('passport'); | |
| var Hapi = require('hapi'); | |
| var util = require('util'); | |
| var FacebookStrategy = require('passport-facebook').Strategy | |
| var server = new Hapi.Server('localhost', 8000); | |
| // Passport | |
| passport.use(new FacebookStrategy({ |
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
| /* Remember to: | |
| npm install hapi passport travelogue yar | |
| */ | |
| var Hapi = require('hapi'); | |
| var Travelogue = require('travelogue'); | |
| var Passport = require('passport'); | |
| var FacebookStrategy = require('passport-facebook').Strategy; |
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
| /* Remember to: | |
| npm install hapi passport yar travelogue | |
| */ | |
| var Hapi = require('hapi'); | |
| var Travelogue = require('travelogue'); | |
| var Passport = require('passport'); | |
| var LocalStrategy = require('passport-local').Strategy; |