Skip to content

Instantly share code, notes, and snippets.

View justinrainbow's full-sized avatar

Justin Rainbow justinrainbow

View GitHub Profile
require 'formula'
class Apc <Formula
url 'http://pecl.php.net/get/APC-3.1.4.tgz'
homepage 'http://php.net/manual/en/book.apc.php'
md5 ''
version '3.1.4'
def install
Dir.chdir "APC-#{version}" do
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.3.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 '5adf1a537895c2ec933fddd48e78d8a2'
<?php
// Application/HelloBundle/Author.php
class Author
{
/**
* @validation:NotBlank()
* @validation:MinLength(3)
*/
private $firstName;
<?php
// this is valid php
$foo = $bar ?: 'baz';
// it's the equivalent to
$foo = isset($bar) && $bar ? $bar : 'baz';
@justinrainbow
justinrainbow / php.rb
Created January 31, 2011 23:05
homebrew formula for installing php 5.3.3
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.3.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 '5adf1a537895c2ec933fddd48e78d8a2'
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
@justinrainbow
justinrainbow / js_method.php
Created March 3, 2011 15:54
an effort to make using the ui js modules easier {$yui->onAvailable("#myselector")->plug("flashpanel", $cfg)}
<?php
class YuiMethod
{
protected $selector;
protected $helpers;
protected $code;
public function __construct($selector, $helper = null)
{
@justinrainbow
justinrainbow / fix-smarty.php
Created April 8, 2011 19:48
Runs through a bunch of *.tpl files to update syntax from Smarty2 to Smarty3 -- no whitespace around tags
<?php
$dir = new RecursiveDirectoryIterator(dirname(__FILE__));
$iterator = new RecursiveIteratorIterator($dir);
$pattern = '~\{(.+?)\}~im';
$start_char = '{';
$end_char = '}';
@justinrainbow
justinrainbow / compl1.php
Created April 22, 2011 19:12 — forked from antirez/compl1.rb
Redis autocompletion - in php
<?php
# compl1.php - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
$redis = new Redis();
$redis->connect('127.0.0.1');
# Create the completion sorted set
if (!$redis->exists('compl')) {
# test for the git ps1 script
declare -f __git_ps1 >/dev/null
if (( $? ))
then
PS1='[\[\033[34m\w\033[0m]\n[\t \u]\$ '
else
PS1='[\[\033[34m\w\033[0m$(__git_ps1 " (\033[0;32m%s\033[0m)")]\n[\t \u]\$ '
fi