Skip to content

Instantly share code, notes, and snippets.

View augustohp's full-sized avatar

Augusto Pascutti augustohp

View GitHub Profile
@alganet
alganet / h.php
Created August 10, 2011 22:43
HTML generator prototype
<?php
print
h::html(
h::head(
h::title('Hi!')
),
h::body(
h::h1('Hello')->id('oi'),
h::ul(
git remote add --track master upstream git://github.com/upstreamname/projectname.git
@alganet
alganet / mocks.php
Created March 27, 2012 17:22
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('NamespaceVendor\\ClassName'))([
'sayHelloTo' => function($name="Alexandre") {
return "Hello Alexandre";
@jdp
jdp / bf2c.py
Created March 29, 2012 14:20
Naive brainfuck-to-C compiler
#!/usr/bin/env python
import argparse
import sys
def tokenize(source):
return list(source)
def parse(tokens):
@henriquemoody
henriquemoody / recterm.sh
Created May 8, 2012 21:41
Record the terminal session and replay later
#!/bin/bash
# Uses script and scriptreplay to record and playback virtual terminal.
# Copyright (C) 2007 Hean Kuan Ong <mysurface@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@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")
);
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@henriquemoody
henriquemoody / ArgoUML.sh
Created August 15, 2012 19:22
Install ArgoUML on linux
#!/bin/sh
if [ "root" != "$(whoami)" ]; then
echo "You must run this command as root" 1>&2
exit 1
fi
set -x
# Download and extract
if [ ! -z "${1}" ]; then
@nikic
nikic / password_hashing_api.md
Created September 12, 2012 15:04
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007