Skip to content

Instantly share code, notes, and snippets.

@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 <[email protected]>
#
# 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,
<?php
// https://wiki.archlinux.org/index.php/Color_Bash_Prompt
$colors = array(
// regular colors
'black' => '0;30', // black
'red' => '0;31', // red
'green' => '0;32', // green
'yellow' => '0;33', // yellow
@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
@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 <[email protected]>
#
_help()
{
# Bash-Completion script for PHPUnit
#
# Created by Henrique Moody <[email protected]>
#
_phpunit()
{
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
@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',
@henriquemoody
henriquemoody / http-status-codes.php
Last active March 7, 2025 15:17
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 / br-cities.php
Last active June 1, 2020 12:50
Lista de cidades brasileiras com base nos dados o IBGE
<?php
return [
// http://www.cidades.ibge.gov.br/download/mapa_e_municipios.php?uf=ac (Thu May 14 16:30:15 BRT 2015)
'AC' => [
1200013 => 'Acrelândia',
1200054 => 'Assis Brasil',
1200104 => 'Brasiléia',
1200138 => 'Bujari',
1200179 => 'Capixaba',
#!/usr/bin/env bash
# Usage: {script} PATH
# Construct a commit message for use with rebase --autosquash.
#
# The commit message will be the subject line from the specified commit with a
# prefix of "fixup! " and will contain the changes on the PATH.
#
# --help, -h Displays this help
#
# Report bugs to Henrique Moody <[email protected]>
<?php
// Based on https://stackoverflow.com/questions/965611/forcing-access-to-php-incomplete-class-object-properties
function convertObject($object, string $from, string $to)
{
// Serialize
$serialized = serialize($object);
// Replace the object-type
$objectReplaced = preg_replace(