Skip to content

Instantly share code, notes, and snippets.

Chris O'Donnell codfish

View GitHub Profile
codfish / app.js
Last active Aug 29, 2015
AngularJS Breadcrumbs leveraging ui-router's states. Based off
View app.js
'use strict';
* App Module
* @note
* ui-router setup is def incomplete. this is just to show an
* example of the breadcrumb setup
* @ngInject
codfish / angularIgnoreRegularLinks.js
Last active Aug 29, 2015
Prevent regular links from not working once angular bootstraps.
View angularIgnoreRegularLinks.js
View angularSafeApply.js
$rootScope.safeApply = function (fn) {
var phase = this.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
if (fn && (typeof(fn) === 'function')) {
} else {
codfish /
Created Oct 29, 2014
Create and customize a Vagrant box. reference:
# choose a box as a starting point
vagrant init hashicorp/precise64
vagrant up
vagrant ssh
# customize the box to your liking, for example:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vim
sudo apt-get install apache2
codfish / get_table_sizes.sql
Last active Aug 29, 2015
Here is a super simple SQL query to determine the size of all tables in a given database. References:,
View get_table_sizes.sql
-- only thing you need to supply is the database name in the WHERE statement
round(((data_length + index_length) / 1024 / 1024), 2) AS Size_in_MB
FROM information_schema.TABLES
WHERE table_schema = '%%database%%'
codfish / msword_to_ascii.php
Last active Aug 29, 2015
This function strips incompatible iso characters from ms office documents. If no ascii conversion is found the character is ignored.
View msword_to_ascii.php
* This function strips incompatible iso characters
* from ms office documents. If no ascii conversion is found
* the character is ignored.
* @author hannuraina
* @param array|string $replace value(s) to replace
* @return array|string $items
function msword_to_ascii($replace) {
codfish /
Created Jan 5, 2015
Check DNS of a domain/subdomain to see if it's properly configured using whois & dig
# returns whois info for the domain, including name servers
# use dig to lookup any subdomain on a name server(s)
# dig will output details of the lookup. If configured properly you should see
# the details in the ANSWER SECTION ... e.g.
codfish /
Created Jan 20, 2015
Just request a page's headers using curl
curl -I
# or curl --head
codfish /
Last active Aug 29, 2015
Scenario: You use a subdomain for your WP Admin separate from your blogs main domain, i.e. You want to make sure only requests to the WP admin use this subdomain. This apache rewrite logic redirects all non-admin traffic away from admin domain to the homepage, keeping in mind that preview urls should also be included as an a…
RewriteEngine On
RewriteBase /
# "If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule,
# use the %{REQUEST_URI} variable in a RewriteCond."
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{REQUEST_URI} !^(/wp-admin|/wp-login|/wp-content|/wp-includes)
RewriteCond %{QUERY_STRING} !^(.*?)preview=true(.*?)$
RewriteRule (.*) [R=301,L] # the trailing ? after the domain makes sure to remove any query string params from the original request
codfish /
Last active Aug 29, 2015
Get apache response code counts for your site from access log
cat | awk '{print $9}' | sort | uniq -c | sort -nr
# Example Output:
# 545475 200
# 153819 304
# 99102 301
# 13346 404
# 8027 206
# 3822 302
You can’t perform that action at this time.