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 sslConfig = { | |
| key: fs.readFileSync('certs/your-cert.key'), | |
| cert: fs.readFileSync('certs/your-cert.crt'), | |
| ca: [fs.readFileSync('certs/your-cert.ca.crt')] | |
| } |
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 db = require('db'); | |
| var instance = null; | |
| exports.get = function() { | |
| if(!instance) instance = new db(); | |
| return instance; | |
| } |
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
| // assuming http.get fires back err, result | |
| function curryGet = function(url) { | |
| return function(callback) { | |
| http.get(url, callback); | |
| } | |
| } | |
| async.parallel([ |
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 spawn = require('child_process').spawn; | |
| var output = require('fs').createWriteStream(__dirname + '/test.pdf'); | |
| var wk = spawn('wkhtmltopdf', ['-', '-']); | |
| wk.stdout.pipe(output); | |
| wk.stdin.end('<b>Test</b>'); |
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 spawn = require('child_process').spawn; | |
| var output = require('fs').createWriteStream(__dirname + '/test.pdf'); | |
| var wk = spawn('wkhtmltopdf', ['-', '-']); | |
| wk.stdout.pipe(output); | |
| wk.stdin.end('<b>Test</b>'); |
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
| { | |
| "targets": [ | |
| { | |
| "target_name": "wkhtmltox", | |
| "sources": [ "wkhtmltox-google.cpp" ], | |
| "include_dirs": ["/include"], | |
| "libraries": ["-lwkhtmltox"] | |
| } | |
| ] | |
| } |
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 http = require('http'); | |
| var app = express(); | |
| app.configure(function(){ | |
| app.set('port', process.env.PORT || 3000); | |
| app.use(express.logger('dev')); | |
| app.use(express.bodyParser()); | |
| app.use(express.methodOverride()); | |
| app.use(app.router); |
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
| io.sockets.on('connection', function (socket) { | |
| var timeout = false; | |
| fs.watch('public/images/slides/', {}, function(eventType, filename){ | |
| if (eventType == 'change'){ | |
| if(timeout) clearTimeout(timeout); | |
| timeout = setTimeout(function() { | |
| var base64_data = new Buffer(fs.readFileSync('public/images/slides/'+filename)).toString('base64'); | |
| socket.emit('newSlide', base64_data); | |
| }, 100); | |
| } |
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
| SELECT subscriptions.id, subscriptions.agency_id, subscriptions.expiry, | |
| CASE | |
| WHEN subscriptions.expiry > date_part('epoch'::text, now())::bigint THEN 'current'::text | |
| ELSE 'expired'::text | |
| END AS status | |
| FROM subscriptions | |
| ORDER BY subscriptions.expiry DESC; | |
| -- This returns: | |
| -- 25;1;1394321699;"current" |
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
| // mw.getUserAndAgency | |
| var middleware = function(req, res, next) { | |
| req.statsdName = 'user_middleware'; | |
| var get = cabinet | |
| .read('users', req.token.user_id) | |
| .with('agencies'); | |
| get.execute(function(err, empty, result) { |
OlderNewer