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 db = require('./config/db') | |
var mongoose = require('mongoose') | |
var Schema = mongoose.Schema | |
var Review = new Schema({ | |
article : String | |
, count : Number | |
, date : { type: Date, default: Date.now } | |
, images : [String] | |
, industry : String |
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
module.exports = { | |
user: "username", | |
pass: "password", | |
name: "yourdatabase", | |
host: "Flame.mongohq.com", | |
port: 27094 | |
} |
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 models = require('./models') | |
var mongoose = require('mongoose') | |
var Review = mongoose.model('Review') | |
var express = require('express') | |
var app = express.createServer() | |
// ... other requires | |
// ... config stuff | |
// simple route to get a paginated page by number |
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
// create polyfill | |
jQuery.fn.fakeMeter = function() { | |
// don't waste time if you don't need to | |
if (jQuery.fn.fakeMeter.supportsMeter) return $(this) | |
return $(this).each(function() { | |
var $meter = $(this) |
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
/****************** | |
* Meter PolyFill | |
******************/ | |
meter { | |
display: inline-block; | |
color: transparent; | |
height: 16px; | |
width: 100px; | |
overflow: hidden; | |
background: #ededed; /* Old browsers */ |
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
// 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; |
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
// 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 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 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 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; |