Skip to content

Instantly share code, notes, and snippets.

Chris O'Donnell codfish

Block or report user

Report or block codfish

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@codfish
codfish / app.js
Last active Aug 29, 2015
AngularJS Breadcrumbs leveraging ui-router's states. Based off http://goo.gl/w0zFou
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
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')) {
fn();
}
} else {
this.$apply(fn);
}
};
@codfish
codfish / custom_vagrant.sh
Created Oct 29, 2014
Create and customize a Vagrant box. reference: http://goo.gl/NfQrL4
View custom_vagrant.sh
# 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
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: http://goo.gl/7jFF5y, http://goo.gl/cBZKWW
View get_table_sizes.sql
-- only thing you need to supply is the database name in the WHERE statement
SELECT TABLE_NAME AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) AS Size_in_MB
FROM information_schema.TABLES
WHERE table_schema = '%%database%%'
ORDER BY Size_in_MB DESC
@codfish
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
codfish / check_dns.sh
Created Jan 5, 2015
Check DNS of a domain/subdomain to see if it's properly configured using whois & dig
View check_dns.sh
# returns whois info for the domain, including name servers
whois codfish.io
# use dig to lookup any subdomain on a name server(s)
dig @ns-371.awsdns-46.com codly.codfish.io
# dig will output details of the lookup. If configured properly you should see
# the details in the ANSWER SECTION ... e.g.
;; ANSWER SECTION:
codly.codfish.io. 300 IN CNAME codly.herokuapp.com.
@codfish
codfish / curl_headers.sh
Created Jan 20, 2015
Just request a page's headers using curl
View curl_headers.sh
curl -I
# or curl --head
@codfish
codfish / wp_admin_redirect.sh
Last active Aug 29, 2015
Scenario: You use a subdomain for your WP Admin separate from your blogs main domain, i.e. admin.superblog.com. 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…
View wp_admin_redirect.sh
RewriteEngine On
RewriteBase /
# http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
# "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} ^admin.superblog.com$
RewriteCond %{REQUEST_URI} !^(/wp-admin|/wp-login|/wp-content|/wp-includes)
RewriteCond %{QUERY_STRING} !^(.*?)preview=true(.*?)$
RewriteRule (.*) http://superblog.com? [R=301,L] # the trailing ? after the domain makes sure to remove any query string params from the original request
@codfish
codfish / apache_response_code_counts.sh
Last active Aug 29, 2015
Get apache response code counts for your site from access log
View apache_response_code_counts.sh
cat example.com-access.log | 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.