Skip to content

Instantly share code, notes, and snippets.

View IgorDePaula's full-sized avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile
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();

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

If you reached this page, means you've hit this SSL error when trying to

# in case of conflict with local nginx:
# make sure in all *.confs (
# also in default and example to avoid error like
# 'nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)'
# )
# set for instance "listen 127.0.0.1:80" instead of "listen *:80"
# docker & network settings
DOCKER_IMAGE_NAME="maxexcloo/nginx-php" # build of nginx-php - for example
DOCKER_CONTAINERS_NAME="nginx_bridged" # our container's name
/*
* This code requires both RabbitMQ and delayed message plugin is installed.
* The plugin can be found here https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/
*
* Refeence: https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq/
*/
'use strict';
var amqp = require('amqplib'),
var cheerio = require('cheerio'),
http = require('http'),
max_articles=2,
host = 'http://painel.blogfolha.uol.com.br';
var options = {
host: host,
path: '/',
method: 'GET',
@IgorDePaula
IgorDePaula / enable_mongo.sh
Created June 27, 2016 17:40 — forked from sgnn7/enable_mongo.sh
Mongodb 3.2 on Ubuntu 15.10
echo '[Unit]
Description=High-performance, schema-free document-oriented database
After=syslog.target network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
[Install]
@IgorDePaula
IgorDePaula / passport_node_acl_example.js
Created June 30, 2016 20:46 — forked from danwit/passport_node_acl_example.js
Authentication and authorization with passportjs + node_acl + mongo + express
/**
* Simple authentication and authorization example with passport, node_acl,
* MongoDB and expressjs
*
* The example shown here uses local userdata and sessions to remember a
* logged in user. Roles are persistent all the way and applied to user
* after logging in.
*
* Usage:
* 1. Start this as server
@IgorDePaula
IgorDePaula / 1-loadolympics.cql
Created August 25, 2016 17:00 — forked from rvanbruggen/1-loadolympics.cql
Olympic Medallists
create index on :Country(name);
create index on :City(name);
create index on :Sport(name);
create index on :Discipline(name);
create index on :Athlete(name);
create index on :Event(name);
create index on :Year(name);
create index on :Gender(name);
create constraint on (c:Country) assert c.noc is unique;