Skip to content

Instantly share code, notes, and snippets.

View hussani's full-sized avatar

Hussani Oliveira hussani

View GitHub Profile
@alganet
alganet / developerquiz.php
Created August 8, 2011 20:28
Full script for the Google Developer Day Quiz (http://developerquiz.appspot.com) in 39 lines
<?php //Run as command line. Input file as first argument.
const G_FOO = 'aeiou'; //Googlon special letters
const G_INV = 'z'; //Preposition invalidator
const G_PREP = 3; //Preposition size
const G_VERB = 8; //Verb size
const G_ORDER = 'qnbczxjtklmvhrwfsdgp'; //Letter ordering
const G_NUM_MOD = 4; //Pretty number divisor
const G_NUM_MAX = 526593; //Pretty number minimum
$textB = explode(' ', file_get_contents($argv[1]));
@johnmegahan
johnmegahan / functions.php
Created January 12, 2012 01:50
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown menus in Wordpress.
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@alganet
alganet / cli.md
Created February 14, 2012 18:20
Respect\Cli

Respect\Cli

A tool for interacting with PHP code from the command line. It is intended to be used alongside Respect\Config.

Main Actions

Usage: [action] [config] [command]

@alganet
alganet / mocks.php
Created March 27, 2012 16:57
Next-gen mocks and stubs for PHP 5.4
<?php
use FooBar\Test\Mock;
// In the sample below, $mock expects the method "sayHelloTo" to be called one time
// with the parameter $name equals "Alexandre" and return "Hello Alexandre"
$mock = (new Mock)([
'sayHelloTo' => function($name="Alexandre") {
return "Hello Alexandre";
@alganet
alganet / transform.php
Created May 20, 2012 15:15
Respect\Transform transforms data friendly to the web
<?php
use Respect\Transform\Transformer as t;
$users = array(
array("id" => 1, "first_name" => "Alexandre", "last_name" => "Silva", "location" => "São Paulo"),
array("id" => 2, "first_name" => "Satoshi", "last_name" => "Silva", "location" => "Curitiba"),
array("id" => 3, "first_name" => "Fulano", "last_name" => "Silva", "location" => "New York")
);
@alganet
alganet / href.php
Created August 25, 2012 14:55
Full RESTful/Relational Blog in less than 100 lines [Work In Progress]
<?php
use Respect\Rest\Router;
use Respect\Relational\Mapper;
use Respect\Template\Xml;
use Respect\Template\Html;
$db = new Mapper(new PDO));
$db->postsBase = $db->select('id', 'title', 'text')->posts(
$db->select('name', 'bio')->author)
@zenorocha
zenorocha / Foca no código
Created August 27, 2012 14:42
Foca no código
/* Véi, foca no código
.---.
/o o\
__(= " =)__
//\'-=-'/\\
) (_
/ `"=-._
/ \ ``"=.
<?php
class FluentCache extends \ArrayObject
{
private $cache;
public function __construct(\Doctrine\Common\Cache\Cache $cache, array $data = array())
{
$this->cache = $cache;
parent::__construct($data, static::ARRAY_AS_PROPS);