Skip to content

Instantly share code, notes, and snippets.

View IgorDePaula's full-sized avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile
var moment = require('moment');
var inicio = moment().set({hours:'08',minutes:'00'});
var fim = moment().set({hours:'18',minutes:'00'});
for(var interval = inicio; interval < fim; interval.add({hours:1,minutes:30})){
console.log(interval.format('HH:mm'));
}
/*
* 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'),
<?php
$datas = new DatePeriod(new DateTime('2015-01-30'), new DateInterval('P1M'), 10);
foreach ($datas as $data) {
echo $data->format('d/m/Y'), '<br>';
}
@IgorDePaula
IgorDePaula / multi-elastica.php
Created January 26, 2016 17:03
Busca de vários termos em vários campos do documento no elastic search. Usada a lib ruflin\elastica.
<?php
include 'vendor/autoload.php';
use Elastica\Client;
use Elastica\Document;
use Elastica\Query;
use Elastica\Query\MultiMatch;
use Elastica\Type\Mapping;
var users =[
{
"email": "teste01@teste.com.br",
"papeis": [
{
"id_papel_usuario": 2
},
{
"id_papel_usuario": 3
}
var cheerio = require('cheerio'),
http = require('http'),
max_articles=2,
host = 'http://painel.blogfolha.uol.com.br';
var options = {
host: host,
path: '/',
method: 'GET',
var AWS = require('aws-sdk');
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var crypto = require('crypto');
AWS.config.loadFromPath('./config.json');
var Consumer = require('sqs-consumer');
var S3 = new AWS.S3();
var app = Consumer.create({
<?php
/**
* Created by PhpStorm.
* User: igor
* Date: 25/06/16
* Time: 12:15
*/
namespace Admin;
<li><a href="<?php echo $this->url('admin.servicos'); ?>"><i class="fa fa-paperclip"></i>
my generated url: http://localhost:8080/admin/servicos/index/0
@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]