Skip to content

Instantly share code, notes, and snippets.

View codfish's full-sized avatar

Chris O'Donnell codfish

View GitHub Profile
@codfish
codfish / uiEqualHeights.js
Last active February 12, 2018 09:02
AngularJS Equal Height columns directive.
'use strict';
/**
* Equal Heights
*
* Attach this directive to the parent/wrapping element of
* a bunch of elements that are columns. This directive will
* calculate the height of every direct child (one level down)
* then set all of them to be the height of the tallest one.
*
@codfish
codfish / xdebug-hack.md
Last active December 19, 2017 16:14
Xdebug Hack

Xdebug tends to slow down a lot of things. Here's a hack to unload the extension by default but load it whenever it's needed (for instance, when generating php code coverage.

Prevent Xdebug from loading by default

If you use brew to install php 7, should be here: /usr/local/etc/php/<version>/conf.d/ext-xdebug.ini. Edit that file (replacing <version> with whatever version of php you're using) and comment out the line that begins with zend_extension. The code examples here assume 7.0.

;zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
@codfish
codfish / index.html
Last active November 20, 2017 17:50
AngularJS 1.x Slick Carousel Directive
<div class="slick-slider clearfix"
data-slick-carousel
data-slides="gallery.slides"
data-interstitial="gallery.interstitial"
data-settings="{}"
data-active="gallery.active"
data-onchange="gallery.onAfterChange"
data-count="gallery.slides.length"
data-interstitial-link="gallery.interstitial.link"
data-autoplay="true"
@codfish
codfish / app-controller.js
Created November 20, 2017 17:41
AngularJS 1.X Meta Service
/**
* Application Controller
*
* @ngInject
*/
function AppCtrl($rootScope, $log, $state, MetaService, configuration) {
$rootScope.$on('$stateChangeSuccess', function(event, state, params, from, fromParams) {
// set canonical based on the new state url & param values
MetaService.canonical = configuration.DOMAIN_HOST + $state.href(state, params);
});
@codfish
codfish / wp_redirect_short_links.php
Last active November 15, 2017 15:12
Wordpress short links don't automatically redirect to the post permalink, like some (me) might think they should. If you switch your permalink structure to something more SEO friendly, existing posts should automatically redirect to the proper format. However, future posts will not. If you want all "short links" (mywordpresssite.com/?p=123456) t…
@codfish
codfish / no-js-no-styles.scss
Last active September 21, 2017 13:20
Remove site styles when js is not supported
// when using modernizr or similar
.no-js body * {
display: initial !important;
opacity: 1 !important;
visibility: visible !important;
overflow: visible !important;
transform: none !important;
float: none !important;
position: static !important;
height: auto !important;
@codfish
codfish / find_string_in_repo.sh
Created May 24, 2016 17:57
Get an alphabetical list of files that a specific string is found within your repo
git grep '<string to search for>' | awk '{print $1}' | sed 's/:$//' | sort -u
@codfish
codfish / search_multi_array.php
Created May 16, 2016 13:27
Search multi-dimensional array based on key value pair. i.e. you have an array of posts, and you want to return the post with the id of `1231`
<?php
$posts = [
[
'id' => 1231,
'title' => 'Test'
],
[
'id' => 1111,
'title' => 'Test #2'
@codfish
codfish / wedding.sh
Last active March 11, 2016 03:32
Download wedding photos. Photographer put all of our photos for us and family to buy, but wasn't going to give us a digital copy. So...
#!/usr/bin/env bash
# need to set env variable for the public base url for the photos
if [[ -z "$WEDDING_URL_PREFIX" ]]; then
printf '\nError: WEDDING_URL_PREFIX needs to be set in your environment!\n'
exit 1
fi
# image filenames had two different prefixes
IMG_TOTAL=2405
@codfish
codfish / symlinkAll.sh
Last active December 28, 2015 17:59
Symlink every file in one directory into another directory
# for instance, if you want to link all of your nginx config files
# from sites-available/ to sites-enabled/ in one fell swoop
# the trick here is to go into the target directory before issuing the ln command
cd /etc/nginx/sites-enabled
sudo ln -sfnv /etc/nginx/sites-available/* .