Skip to content

Instantly share code, notes, and snippets.

@kevincolten
kevincolten / phpcs-newer.sh
Created January 27, 2015 22:16
Run PHP_CodeSniffer on files with uncommitted changes
if [ "$(git diff --name-only master --diff-filter=AMR | grep -Ei "^.*app\/(models|controllers)\/.*\.php$")" ]; then vendor/bin/phpcs $(git diff --name-only master --diff-filter=AMR | grep -Ei "^.*app\/(models|controllers)\/.*\.php$") --standard=PSR2; fi
@kevincolten
kevincolten / setup.sh
Last active August 29, 2015 14:07
When Setting Up a New Mac
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Update homebrew recipes
brew update
@kevincolten
kevincolten / subl.sh
Last active August 29, 2015 14:00
Launch Sublime Text from terminal
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/bin/subl
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :cor
def cor
headers["Access-Control-Allow-Origin"] = "http://localhost:8000"
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",")
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",")
head(:ok) if request.request_method == "OPTIONS"
end
@kevincolten
kevincolten / gist:8853141
Created February 6, 2014 21:46
listing all (mysql) processes and killing them
$ ps aux | grep mysql
$ sudo kill -9 629 513 #1, 5, 9 (varying levels of process killing)