Skip to content

Instantly share code, notes, and snippets.

View IgorDePaula's full-sized avatar
😆

Igor C. de Paula IgorDePaula

😆
View GitHub Profile
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@kosinix
kosinix / gist:5354637
Created April 10, 2013 13:30
Get month names using a for loop and PHP date function.
<?php
for($m=1; $m<=12; ++$m){
echo date('F', mktime(0, 0, 0, $m, 1)).'<br>';
}
@benfrain
benfrain / post-receive.sh
Last active June 8, 2024 20:52
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
@danwit
danwit / passport_node_acl_example.js
Created May 1, 2014 23:23
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
@leocomelli
leocomelli / git.md
Last active July 24, 2024 04:26
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

anonymous
anonymous / soma_dias_uteis.php
Created July 8, 2014 00:29
$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--;
}
<?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--;
#!/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 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;
<?php
$vencimento = 30;
$firstPag = '30/01/2015';
$parcelas = 15;
$data = new DateTime(implode('-', array_reverse(explode('/', $firstPag))) . ' 00:00:00');
$data_parcelas = array();
while ($parcelas) {
$mes = $data->sub(new DateInterval('P2D'))->add(new DateInterval('P1M'))->format('n');