Skip to content

Instantly share code, notes, and snippets.

regex=/^([1-9][0-9] +|\([1-9][0-9]\) *)[1-9]\d{2,4}[ .-]?\d{4}$/;
strings=[
/* Só numéricos com espaços que casam */
'11 9990000',
'11 99990000',
'11 999990000',
'11 999 0000',
'11 9999 0000',
'11 99999 0000',
@henriquemoody
henriquemoody / observer.php
Created April 6, 2012 18:02
Observer example
<?php
abstract class User
{
protected $_name = 'Henrique Moody';
protected $_email = 'henriquemoody@gmail.com';
public function toArray()
{
@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,
@henriquemoody
henriquemoody / bin.sh
Created May 19, 2012 16:44
I don't have a description for it now. But a have the URL http://git.io/bin
#!/usr/bin/env bash
echo "I'll do something"
@henriquemoody
henriquemoody / sorld.sh
Created June 18, 2012 12:51
Run Solr as daemon
#!/usr/bin/env bash
SOLR_RUNNING=0
SOLR_DIRECTORY="/usr/local/solr"
SOLR_LOG="${SOLR_DIRECTORY}/logs/solrd.log"
SOLR_LOCK="${SOLR_DIRECTORY}/solrd.pid"
touch "${SOLR_LOCK}"
SOLR_PID=$(cat ${SOLR_LOCK})
let SOLR_PID=SOLR_PID+0
touch "${SOLR_LOG}"
@henriquemoody
henriquemoody / cli.php
Created June 18, 2012 14:59
PHP CLI script in procedural style
<?php
function writeln($message = '', $stream = STDOUT)
{
fwrite($stream, $message . PHP_EOL);
}
$arg_options = array(
'help' => array(
'required' => false,
#!/bin/sh
command="/usr/local/sublimetext-2/sublime_text"
if [ -d "${1}" ] || [ -f "${1}" ]
then
${command} -a "${1}" 2>/dev/null 1>&2 &
else
${command} $@
fi
@henriquemoody
henriquemoody / content-finder.bash
Last active October 6, 2015 18:18
[content-finder] Find content into files.
#!/usr/bin/env bash
# Usage: {script} OPTIONS
# Find content into files.
#
# -h, --help Displays this help
# -a, --action Action to perform: "search", "files" or a sed pattern to
# apply to files (default "search")
# -d, --directory Directory to search (default ".")
# -e, --extension Extensions to search on (default "*")
# -x, --exclude Pattern to exclude
<?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 / sql_formater.php
Created August 7, 2012 00:12 — forked from augustohp/sql_formater.php
SQL formater for PHP by @alganet
function formatSql($sql) {
return preg_replace(
'/(select|from|(left |right |natural |inner |outer |cross |straight_)*join|where|limit|update |set|insert |values)/i',
"\n$1\n ", str_replace("\n", '', $sql)
);
}