Skip to content

Instantly share code, notes, and snippets.

@ricog
ricog / gist:1348166
Created November 8, 2011 15:56
Split long if statements onto several lines
<?php
if (
$something === true &&
$something_else === false
) {
//code here
}
?>
@ricog
ricog / basic-git-workflow
Created January 9, 2012 20:01
Basic Git Workflow
## Installation
get the files
git clone <repo url>
## Working on files
see what you've changed
git diff
@ricog
ricog / gist:1584681
Created January 9, 2012 20:10
Better Git Workflow

This describes a fairly simple git workflow where features are developed on descriptively named branches. These branches are pushed to github and merged into master once completed and tested by someone else. This is very similar to github flow.

Committing Changes

  1. Make some changes

  2. Commit to a new descriptively named branch

@ricog
ricog / gist:1684813
Created January 26, 2012 20:13
Vim EOL fix
" http://vim.wikia.com/wiki/VimTip1369
" Preserve noeol (missing trailing eol) when saving file. In order
" to do this we need to temporarily 'set binary' for the duration of
" file writing, and for DOS line endings, add the CRs manually.
" For Mac line endings, also must join everything to one line since it doesn't
" use a LF character anywhere and 'binary' writes everything as if it were Unix.
" This works because 'eol' is set properly no matter what file format is used,
" even if it is only used when 'binary' is set.
@ricog
ricog / gist:2022105
Created March 12, 2012 13:59
Include DebugKit on-the-fly when debug >= 3

This gist shows an easy way to include DebugKit as a new debug level in your CakePHP applications. You'll first need to install the DebugKit plugin and then add the following code:

CakePHP >= 2.0

In Config/bootstrap.php

// Load DebugKit only if debug level is greater than 3
if (Configure::read('debug') >= 3) {

CakePlugin::load("DebugKit");

@ricog
ricog / html5-skeleton
Created April 30, 2012 21:15
HTML5 skeleton
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
@ricog
ricog / deployment-workflow.md
Last active December 18, 2015 15:58
Deployment workflow

Below is a branching strategy using rebase that maintains a deployable master branch and stable staging branch for quality assurance testing.

###Branch Concepts

  • master - always deployable to production
  • staging - stable code base ready for pre-production testing, also the feature branch merge target
  • features - one branch per feature, testable in development environments, only merged to staging once stable and ready to deploy
  • patches - one branch per patch, urgent items that need applied to master branch ahead of staging and feature branches

Feature branches are agressively rebased on the staging branch by the feature developer. After completed, tested, and signed off (by at least one other developer), the feature branch is merged into staging for final testing. Patch/fix branches are derived from master and rebased if necessary before merging back in.

@ricog
ricog / vim-vundle
Created June 30, 2014 20:04
Easy Vim plugin installation using Vundle (add to your ~/.vimrc)
" ===== Vundle Setup - the vim plugin bundler =====
" This will install Vundle if not installed
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
-- Looking for records that will expire 3 or 9 months from today.
-- Original query.
-- DATE(NOW()) = DATE_SUB(`Dress`.`expiration_date`, INTERVAL 3 MONTH) OR
-- DATE(NOW()) = DATE_SUB(`Dress`.`expiration_date`, INTERVAL 9 MONTH)
-- Start a select query.
SELECT
-- PROBLEM
@ricog
ricog / gist:e5f468f24a475f89e9cf
Created October 8, 2014 17:20
Intro to Docker on OSX

Intro to Docker

Installing Docker on OSX (using boot2docker)

Look at Docker Installation or if you already have VirtualBox and Homebrew installed:

`brew update && brew install docker`

Running the Docker VM