Skip to content

Instantly share code, notes, and snippets.

@jwage
jwage / SplClassLoader.php
Last active August 16, 2024 17:36
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@augustohp
augustohp / svn2git.sh
Created June 13, 2011 22:33
SVN to GIT migration shell script
#!/bin/sh
# Migrates a SVN repository to a git repository.
#
# Author: Augusto Pascutti <[email protected]>
COMMAND=$0;
SVN=`which svn 2> /dev/null`;
GIT=`which git 2> /dev/null`;
READER="";
RETURN="";
@augustohp
augustohp / cmd_osx_apc_php53.sh
Created August 7, 2011 23:56
APC installation for OSX
#!/bin/bash
#
# Downloads and install latest APC extension to OSX php (Zend Server).
# Tested under OSX 10.6.7, more feedback is appreciated.
#
# OSX is 64bit but the PHP binary in Zend Server is compiled in 32bit mode only,
# so to have APC working with Zend Server on OSX statically compiling it with default
# recommended flags and forced i386 architecture.
# I suppose that Zend Server's binary path is already into your PATH variable and it
# is used before the native PHP binary bundled with OSX.
@henriquemoody
henriquemoody / registry.js
Created August 10, 2011 19:49
Implementação de Registry em javascript.
/**
* Implementação de Registry em javascript.
*
* @author Henrique Moody
*/
var Registry = new function Registry () {
// Dados no registry
var _data = new Array();
@henriquemoody
henriquemoody / remove-php-short-tags.sh
Created August 23, 2011 13:57
Remove PHP short tags
#! /bin/sh
ignore='\.svn';
for file in $(egrep '<\?$' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?$/<?php/g' ${file};
done;
for file in $(egrep '<\?([^px=])' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
@dhotson
dhotson / oo.php
Created December 6, 2011 12:02
PHP Object Oriented Programming Reinvented (for PHP 5.4)
<?php
// Define the 'class' class
$class = (new Obj)
->fn('new', function() {
$newClass = (new Obj($this->methods))
->fn('new', function() {
$obj = new Obj($this->imethods);
call_user_func_array(array($obj, 'init'), func_get_args());
return $obj;
@augustohp
augustohp / Doctrine.ini
Created February 1, 2012 18:15
Doctrine.ini configuration to use with Respect\Config
; Configurations
db_host = 'localhost'
db_user = 'zend'
db_passwd = ''
db_name = 'test'
db_driver = 'mysql'
;db_port = 3306
;db_charset = 'utf8'
dsn = '[db_driver]:host=[db_host];dbname=[db_name]'
dsn = 'sqlite::memory:'
#!/bin/bash
x=0;
repositories=(
"Cli"
"Config"
"Data"
"ed"
"Foundation"
"Framework"
"Http"
@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,
@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