Skip to content

Instantly share code, notes, and snippets.

View zeroasterisk's full-sized avatar

alan blount zeroasterisk

View GitHub Profile
@zeroasterisk
zeroasterisk / REGEX CakePHP Conventions.regex
Created October 27, 2010 17:37
Find and Replace to add spaces after commas and before&after => within PHP
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 July 19, 2011 15:47
.gitconfig -- some useful aliases and configurations
[user]
name = alan bount
email = alan@zeroasterisk.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
@zeroasterisk
zeroasterisk / member.php
Created August 1, 2011 16:36
SP 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 August 1, 2011 20:41
app - /etc/nginx/nginx.conf
We couldn’t find that file to show.
@zeroasterisk
zeroasterisk / standard_location_config_cakephp
Created August 1, 2011 20:42
app - /etc/nginx/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 August 1, 2011 20:47
nginx.conf - example cakeapp
# 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;
@zeroasterisk
zeroasterisk / www.conf
Created August 1, 2011 21:00
/etc/php5/fpm/pool.d/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 August 23, 2011 18:09
~/.zshrc for Oh My ZSH (alan)
# 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 August 31, 2011 14:03
git-rmbranch script to facilitate easy branch removal, locally and on origin
#!/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 August 31, 2011 14:04
confirm.sh a simple way to add confirmation to bash scripts
# ======================================================================
#
# @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