- Fast development is important
- good IDEs, local development, fast servers
- linting in the IDE / as soon as possible
- live reload CSS
- Fast testing is important as well
- make it easy to see test results soon
- commit-hooks? CI server?
- Which one of these produces an incorrect document outline?
a.
<body>
<h1>My Page</h1>
<div>
<h2>My Section</h2>
</div>
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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <style> | |
| body { | |
| font-face: Sans-Serif; | |
| } | |
| h1 { | |
| font-face: "Fake-Font"; | |
| } |
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 $colors = $("#colors"); | |
| var url = "/css/sass/_colors.scss"; | |
| $.get(url, function(data) { | |
| var lines = data.split("\n"); | |
| var line = ""; | |
| var parts = []; | |
| for (var i = 0; i < lines.length; i++) { | |
| line = lines[i].trim(); | |
| if (!line.match(/^\$/)) continue; |
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
| // map reduce way is slow for querying a count, but fast for creating a new table (~20s) | |
| map = function() { | |
| if (this.alerts && this.alerts.length > 0 && this.apns) { | |
| emit(new ObjectId(), {alerts: this.alerts, uuid: this.uuid, hiddenChannels: this.hiddenChannels, provider: this.provider}) | |
| } | |
| } | |
| reduce = function(){} | |
| options = {out:{replace:"alertingUsers"}} | |
| db.users.mapReduce(map, reduce, options) | |
| db.alertingUsers.count() // 34554 |
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
| // use it as a middleware like this | |
| app.use(logger.db('appName')) // by default logs to a db and console.log | |
| app.use(logger.db('appName', false)) // don't log to console.log | |
| // logger.js | |
| var express = require('express') | |
| var logger = express.logger | |
| var RequestLog = require('reports/model/RequestLog') | |
| express.logger.token('route', function(req, res) { | |
| var route = req.route || {} |
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
| // middleware | |
| app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/public/uploads" })) | |
| // later | |
| app.get('/photos', uploadFile, addPhoto) | |
| // file is automatically saved to /public/uploads, let's just set | |
| function uploadFile(req, res, next) { | |
| if (req.files) { | |
| req.body.url = "http://myawesomesite.com/" + req.files.file.path.split("/").slice(-2).join("/") |
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
| // use like this | |
| // var logger = require('connect-db-logger') | |
| // app.use(logger.db("AppName")) | |
| // RequestLog is super simple, but I don't provide it here | |
| var express = require('express') | |
| var logger = express.logger | |
| var RequestLog = require('reports/model/RequestLog') | |
| express.logger.token('route', function(req, res){ | |
| return req.route.path; |