Skip to content

Instantly share code, notes, and snippets.

Avatar

alan blount zeroasterisk

View GitHub Profile
@zeroasterisk
zeroasterisk / REGEX CakePHP Conventions.regex
Created Oct 27, 2010
Find and Replace to add spaces after commas and before&after => within PHP
View REGEX CakePHP Conventions.regex
find:
(\"[^,\n\"\'\(]+\"|\'[^,\n\"\'\(]+\'|\$[a-zA-Z0-9\_\-\>]+|[0-9]+|\'\'|\"\"|null|false|true|\)|\]|\/[a-z]*),([a-zA-Z0-9\'\"\$\)\(\[])
replace:
$1, $2
find:
(\"[^,\n\"\'\(]+\"|\'[^,\n\"\'\(]+\'|\$[a-zA-Z0-9\_\-\>]+|[0-9]+|\'\'|\"\"|null|false|true|\)|\]|\/[a-z]*)=>([a-zA-Z0-9\'\"\$\)\(\[])
replace:
@zeroasterisk
zeroasterisk / .gitconfig
Created Jul 19, 2011
.gitconfig -- some useful aliases and configurations
View .gitconfig
[user]
name = alan bount
email = alan@zeroasterisk.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
View member.php
public function isCta($user=null) {
if (isset($user['MemberCta']['is_active'])) {
return (!empty($user['MemberCta']['is_active'])); // fast if easy
}
if (is_numeric($user) && !empty($user)) {
if (isset($this) && is_object($this->Member)) {
$user = $this->find('first', array('contain' => array('MemberCta'), 'conditions' => array('Member.id' => $user)));
} else {
$MemberCta =& ClassRegistry::init('Member')->find('first', array('contain' => array('MemberCta'), 'conditions' => array('Member.id' => $user)));
}
@zeroasterisk
zeroasterisk / gist:1118940
Created Aug 1, 2011
app - /etc/nginx/nginx.conf
We couldn’t find that file to show.
@zeroasterisk
zeroasterisk / standard_location_config_cakephp
Created Aug 1, 2011
app - /etc/nginx/standard_location_config_cakephp
View standard_location_config_cakephp
#
# These are standard location configs which should be setup in all CakePHP apps
# basic php functionality
# basic document resolution configuration
# basic security
# basic optimization
#
#PHP Magic
location ~ \.php(.*)$ {
@zeroasterisk
zeroasterisk / example_cakeapp.conf
Created Aug 1, 2011
nginx.conf - example cakeapp
View example_cakeapp.conf
# Example CakePHP App config
server {
listen 80;
server_name domain.com www.domain.com asset.domain.com;
access_log /var/log/nginx/domain.access.log main;
error_log /var/log/nginx/domain.errors.log info;
root /var/www/prod/domain/app/webroot;
index index.php index.html index.htm;
include standard_location_config_cakephp;
View www.conf
; Start a new pool named 'www'.
[www]
listen = /var/run/php5-fpm.socket
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
user = www-data
@zeroasterisk
zeroasterisk / .zshrc
Created Aug 23, 2011
~/.zshrc for Oh My ZSH (alan)
View .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="alanpeabody"
#ZSH_THEME="dieter"
#ZSH_THEME="eastwood"
@zeroasterisk
zeroasterisk / git-rmbranch
Created Aug 31, 2011
git-rmbranch script to facilitate easy branch removal, locally and on origin
View git-rmbranch
#!/bin/bash
# -----------------------------------------------------------
# @requires confirm.sh in the same location as this script
# @link http://wuhrr.wordpress.com/2010/01/13/adding-confirmation-to-bash/
# -----------------------------------------------------------
# usage:
# git rmbranch branchname [branchname ...]
# will force delete N number of branches locally and on origin
SCRIPT="$(readlink -nf ${0#./})"
@zeroasterisk
zeroasterisk / confirm.sh
Created Aug 31, 2011
confirm.sh a simple way to add confirmation to bash scripts
View confirm.sh
# ======================================================================
#
# @link http://wuhrr.wordpress.com/2010/01/13/adding-confirmation-to-bash/#comment-3540
#
# Function: confirm
# Asks the user to confirm an action, If the user does not answer yes,
# then the script will immediately exit.
#
# Parameters:
# $@ - The confirmation message