Skip to content

Instantly share code, notes, and snippets.

<?php
class HttpException extends \Exception
{
/**
* List of additional headers
*
* @var array
*/
private $headers = array();
@henriquemoody
henriquemoody / http-status-codes.php
Last active January 26, 2024 10:29
List of HTTP status codes in PHP
<?php
/**
* Content from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*
* You may also want a list of unofficial codes:
*
* 103 => 'Checkpoint',
* 218 => 'This is fine', // Apache Web Server
* 419 => 'Page Expired', // Laravel Framework
@henriquemoody
henriquemoody / nl_langinfo.php
Last active December 20, 2015 06:59
nl_langinfo() constant values.
<?php
$langinfo = array(
'LC_TIME' => array(
'ABDAY_1' => 'Abbreviated name of fist day of the week',
'ABDAY_2' => 'Abbreviated name of second day of the week',
'ABDAY_3' => 'Abbreviated name of third day of the week',
'ABDAY_4' => 'Abbreviated name of fourth day of the week',
'ABDAY_5' => 'Abbreviated name of fifth day of the week',
'ABDAY_6' => 'Abbreviated name of sixth day of the week',
#!/usr/bin/env bash
MAX_LENGTH=0
DIRNAME="$(git rev-parse --show-toplevel)/.git/refs/heads"
for file_name in "${DIRNAME}"/*; do
length=$(basename "${file_name}" | wc -c | awk '{print $1}')
if [[ ${length} -gt ${MAX_LENGTH} ]]; then
MAX_LENGTH=${length}
fi
done;
@henriquemoody
henriquemoody / AbstractEnum.php
Created April 14, 2013 21:50
Abstract enumerable implementation
<?php
abstract class AbstractEnum
{
/**
* @var string
*/
private $name;
#!/usr/bin/env bash
# Usage: {script} DIRECTORY
# Find PHP's commented code and remove then.
#
# --help, -h Displays this help
#
# Report bugs to Henrique Moody <henriquemoody@gmail.com>
#
declare -r SCRIPT_NAME=$(basename ${0})
@henriquemoody
henriquemoody / phpunit.bash
Last active May 10, 2023 02:52
PHPUnit Bash Completion. sudo curl -L https://gist.githubusercontent.com/henriquemoody/5014805/raw/phpunit.bash -o /etc/bash_completion.d/phpunit && source /etc/bash_completion.d/phpunit
# Bash-Completion script for PHPUnit
#
# Created by Henrique Moody <henriquemoody@gmail.com>
#
_phpunit()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
<?php
class FluentCache implements \ArrayAccess
{
private $cache;
public function __construct(\Doctrine\Common\Cache\Cache $cache)
{
$this->cache = $cache;
@henriquemoody
henriquemoody / rename-by-date.bash
Last active December 10, 2015 03:58
Rename files by date. (OSX, only)
#!/usr/bin/env bash
# Usage: {script} FILE1 FILE2 ...
#
# --help, h Displays this help
#
# Report bugs to Henrique Moody <henriquemoody@gmail.com>
#
_help()
{
#!/usr/bin/env php
<?php
$file = array_shift($_SERVER['argv']);
$help = "Utilização de {$file} [ OPTIONS ]
-s, --say Diz alguma coisa
-t, --to Diz pra quem quer dizer alguma coisa
";
if (empty($_SERVER['argv'])) {