Skip to content

Instantly share code, notes, and snippets.

View IgorDePaula's full-sized avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile

Keybase proof

I hereby claim:

  • I am IgorDePaula on github.
  • I am borodin (https://keybase.io/borodin) on keybase.
  • I have a public key whose fingerprint is 8750 5CC1 0134 676D BCE6 5C0D 06FB 070B E19C D14F

To claim this, I am signing this object:

mongoose = require('mongoose');
var GridStore = mongoose.mongo.GridStore,
Grid = mongoose.mongo.Grid,
ObjectID = mongoose.mongo.BSONPure.ObjectID;
exports.getGridFile = function(id, fn) {
var db = mongoose.connection.db,
id = new ObjectID(id),
app.use(express.methodOverride());
// ## CORS middleware
//
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');

This example demonstrates how to display the progress of an asynchronous request. Rather than saying d3.json(url, callback), use d3.json(url) to first create the request object, then register a "progress" event listener with xhr.on before starting the request with xhr.get.

You can also use this pattern to listen to "load" and "success" events separately. For example:

var xhr = d3.json(url)
    .on("progress", function() { console.log("progress", d3.event.loaded); })
    .on("load", function(json) { console.log("success!", json); })
    .on("error", function(error) { console.log("failure!", error); })
 .get();
<!DOCTYPE html>
<head>
<meta HTTP-EQUIV="X-UA-COMPATIBLE" CONTENT="IE=EmulateIE9" >
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
.progress-meter .background {
fill: #ccc;
}
<div id = "container">
<div class = "svg"></div>
<div id = "tag"></div>
</div>
<style>
* {
margin: 0;
padding: 0;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* unoconv -f pdf -o ' + path1 + '.pdf ' + path1
*/
var kue = require('kue')
, jobs = kue.createQueue();
var exec = require('child_process').exec;
var kue = require('kue')
, jobs = kue.createQueue();
var spawn = require('child_process').spawn;
kue.app.listen(3000); //painel de acompanhamento do kue
var job = jobs.create('create slide', {
file: './lib/novo12.ppt',
title: 'create slide teste'
})
var kue = require('kue')
, jobs = kue.createQueue();
var spawn = require('child_process').spawn;
jobs.process('create slide', function (job, done) {
ppt2pdf(job.data.file, done);
console.log('Job', job.id, 'is process');
});
jobs.on('job enqueue', function (id, type) {
console.log('job %s got queued', id);
var kue = require('kue'),
jobs = kue.createQueue();
var spawn = require('child_process').spawn;
var Apresentacao = require('../models/apresentacao');
var path = require('path');
var fs = require('fs');
module.exports = function (io) {
io.on('connection', function (socket) {
jobs.process('create slide', 5, function (job, done) {
ppt2image(job.data.file, done);