Skip to content

Instantly share code, notes, and snippets.

View ethangardner's full-sized avatar

Ethan Gardner ethangardner

View GitHub Profile
@ethangardner
ethangardner / restart-apache.sh
Created February 2, 2016 16:08
Restart Apache without reboot
sudo service httpd restart
@ethangardner
ethangardner / rpm-repo-update.sh
Created February 2, 2016 16:07
Add most recent rpm repo to CentOS/RHEL
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm &&
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm;
<?php
// this file lives in the site's theme directory
if( defined( 'EMA_ENVIRONMENT' ) !== true || constant( 'EMA_ENVIRONMENT' ) === 'prod' ) { {
// do stuff
} ?>
@ethangardner
ethangardner / git-zip-modified-files.md
Last active January 6, 2016 21:28
Zip modified files

Last Commit

git archive --format=zip HEAD `git diff HEAD^ HEAD --name-only` > a.zip

Diffs between 2 commits

tar -czf <file> $(git diff --name-only SHA1..SHA2)
@ethangardner
ethangardner / emad-deploy-git-log-diff.md
Created December 18, 2015 16:53
Using git logs and diffs with emad to deploy

Most recent commit

git show --pretty="format:" --name-only | sort | uniq > deploy.txt && emad --env production --only 0 --files-from deploy.txt && rm deploy.txt

Modified files using diff

git diff --name-only > deploy.txt && emad --env production --only 0 --files-from deploy.txt && rm deploy.txt
@ethangardner
ethangardner / normalize_spaces.sh
Created November 25, 2015 15:11
Nomalize spaces in a directory
find . \( -name '*.scss' -o -name '*.html' -o -name '*.js' -o -name '*.php' \) ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
@ethangardner
ethangardner / jshint.config
Created November 6, 2015 16:01
JSHint config object for Gruntfile
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
@ethangardner
ethangardner / .htaccess
Created October 20, 2015 16:35
Redirect old domain to www version of a new domain
# BEGIN Redirects
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^newdomain\.com$ [NC]
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
</IfModule>
# END Redirects
@ethangardner
ethangardner / get_apache_user.sh
Created October 9, 2015 19:42
Detect user running Apache process
ps -ef | grep httpd | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}';