Skip to content

Instantly share code, notes, and snippets.

Avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile
View soma_dias_uteis.php
<?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--;
View gist:bb8a16815f16d488eba5

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:

View Mongoose GridFS
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),
View node-express-cors-middleware.js
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');
View README.md

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();
View load progress with d3
<!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;
}
View D3 Gantt
<div id = "container">
<div class = "svg"></div>
<div id = "tag"></div>
</div>
<style>
* {
margin: 0;
padding: 0;
}
View vhost-apache
#!/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='igordepaula@adminweb.com.br'
vhroot='/etc/apache2/sites-available'
@IgorDePaula
IgorDePaula / install_a_component_by_composer.php
Last active Dec 16, 2020
Codigo que atualizar o composer.json e instala o novo compoente atraves de uma pagina em php
View install_a_component_by_composer.php
<?php
// componentes requeridos
// composer/composer
// symfony/console
// classes requeridas
// use Composer\Command\UpdateCommand;
// use Symfony\Component\Console\Input\ArrayInput;
// use Composer\Console\Application;
View jobs.js
/*
* 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;