Skip to content

Instantly share code, notes, and snippets.

View IgorDePaula's full-sized avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile
<?php
$diasParaSomar = 10;
$dataFinal = new DateTime('now');
while ($diasParaSomar) {
$dataFinal = $dataFinal->add(new DateInterval('P1D'));
if (in_array($dataFinal->format('w'), array(0,6))) {
continue;
}
$diasParaSomar--;

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;
}
#!/bin/bash
###Checking for user
if [ "$(whoami)" != 'root' ]; then
echo "You have no permission to run $0 as non-root user. Use sudo !!!"
exit 1
fi
###Configure emil and vhost dir
email='[email protected]'
vhroot='/etc/apache2/sites-available'
@IgorDePaula
IgorDePaula / install_a_component_by_composer.php
Last active December 16, 2020 22:24
Codigo que atualizar o composer.json e instala o novo compoente atraves de uma pagina em php
<?php
// componentes requeridos
// composer/composer
// symfony/console
// classes requeridas
// use Composer\Command\UpdateCommand;
// use Symfony\Component\Console\Input\ArrayInput;
// use Composer\Console\Application;
/*
* 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;