Skip to content

Instantly share code, notes, and snippets.

View alexsandro-xpt's full-sized avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
@alexsandro-xpt
alexsandro-xpt / BusinessDaysTest.php
Created September 28, 2012 03:18 — forked from netojoaobatista/BusinessDaysTest.php
Algorítimo idiota (e caro) para cálculo de dias úteis entre duas datas.
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'businessDays.php';
/**
* businessDays() test case.
*/
class BusinessDaysTest extends PHPUnit_Framework_TestCase {
protected function setUp() {
parent::setUp();
@alexsandro-xpt
alexsandro-xpt / todo.php
Created September 28, 2012 03:17 — forked from alganet/todo.php
A very small PHP todo list that saves to the database in 32 lines
<?php
//The actual implementation is just this file. Others are usage and tests.
class TodoList extends ArrayObject
{
const CREATE = 'CREATE TABLE IF NOT EXISTS tasks (name VARCHAR(32) PRIMARY KEY, status INT)';
const SELECT = 'SELECT * FROM tasks';
const INSERT = 'INSERT INTO tasks VALUES (?,?)';
const UPDATE = 'UPDATE tasks SET status = ? WHERE name = ?';
@alexsandro-xpt
alexsandro-xpt / Array.range.js
Created August 3, 2012 01:57 — forked from netojoaobatista/Array.range.js
ECMAScript 5 implementation of Python's range function
/**
* ECMAScript 5 implementation of Python's range function.
* @see {@link http://docs.python.org/release/1.5.1p1/tut/range.html}
* @param {Number} start
* @param {Number} end
* @param {Number} step
* @return {Array}
*/
Object.defineProperty(Array, "range", {
writable: false, configurable: false, enumerable: true,
@alexsandro-xpt
alexsandro-xpt / gist:3058488
Created July 6, 2012 06:50 — forked from millermedeiros/gist:3057782
Links sobre otimização de performance (WPO)
@alexsandro-xpt
alexsandro-xpt / gist:2782358
Created May 24, 2012 15:52 — forked from vquaiato/gist:2782117
Map/Reduce no MongoDB

###Collections Salas{_id} Reservas{_id, sala_id, data}

###Preciso contar as reservas de cada sala por uma data:

map = function () {
    emit(this.sala_id, [1]);
}