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
| // models/user.js | |
| module.exports = function(bookshelf) { | |
| return bookshelf.define(/* blah blah blah */); | |
| } | |
| // app.js | |
| var bookshelf = /* connection stuff goes here */ | |
| var User = require("models/user")(bookshelf) |
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 --save-dev gulp gulp-util gulp-concat gulp-rename gulp-coffee gulp-cached gulp-remember gulp-plumber */ | |
| var gulp = require('gulp'); | |
| /* CoffeeScript compile deps */ | |
| var path = require('path'); | |
| var gutil = require('gulp-util'); | |
| var concat = require('gulp-concat'); | |
| var rename = require('gulp-rename'); | |
| var coffee = require('gulp-coffee'); |
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
| frontpageScore = (upvotes, minutes) -> | |
| maxMinutes = (48 * 60); | |
| maxMultiplier = Math.pow(1.001, maxMinutes); | |
| if minutes > maxMinutes | |
| minutes = maxMinutes | |
| factor = 1 - (Math.pow(1.001, minutes) / maxMultiplier) | |
| return factor * upvotes |
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 gulp = require('gulp'); | |
| var path = require('path'); | |
| var gutil = require('gulp-util'); | |
| var concat = require('gulp-concat'); | |
| var rename = require('gulp-rename'); | |
| var coffee = require('gulp-coffee'); | |
| var cache = require('gulp-cached'); | |
| var remember = require('gulp-remember'); | |
| var plumber = require('gulp-plumber'); |
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
| S = require "string" | |
| Promise = require "bluebird" | |
| request = require "request" | |
| libxml = require "libxmljs" | |
| longest = require "longest" | |
| module.exports = | |
| createTeaser: (input, length) -> | |
| if input.length > length | |
| re = new RegExp("^((.|[\r\n]){0,#{length}})(\\W|$)", "") |
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
| S = require "string" | |
| Promise = require "bluebird" | |
| request = require "request" | |
| libxml = require "libxmljs" | |
| longest = require "longest" | |
| cld = Promise.promisifyAll(require "cld") | |
| urlLib = require "url" | |
| module.exports = | |
| createTeaser: (input, length) -> |
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
| Promise = require "bluebird" | |
| express = require "express" | |
| router = express.Router() | |
| gm = require "gm" | |
| util = require "../util" | |
| fs = require "fs" | |
| path = require "path" | |
| moment = require "moment" | |
| request = require "request" | |
| urlLib = require "url" |
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/share/doc/lighttpd/fastcgi.txt.gz | |
| # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi | |
| server.modules += ( "mod_fastcgi" ) |
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
| module.exports = function(bookshelf) { | |
| return bookshelf.Model.prototype.saveChanges = function(options) { | |
| if (options == null) { | |
| options = {}; | |
| } | |
| options.patch = true; | |
| return this.save(this.changed, 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
| someAsyncMethod() | |
| .then (result) -> | |
| DoSomethingSynchronous() | |
| return someOtherAsyncMethod("stuff") | |
| .then (result) -> | |
| return yetAnotherAsyncMethod("things", "and stuff") | |
| .then (result) -> | |
| console.log "Whoo, we're done!" | |
| exit 0 | |