Skip to content

Instantly share code, notes, and snippets.

View ethangardner's full-sized avatar

Ethan Gardner ethangardner

View GitHub Profile
@ethangardner
ethangardner / .htaccess
Created June 12, 2017 15:08
Redirect folder to new location
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^old-dir/?(.*)$ http://example.com/$1 [L,NC,R=301]
</IfModule>
var $ = require("ko/dom");
var view = $(require("ko/views").current().get());
var languageMenu = view.findAnonymous("anonid", "statusbar-language-menu")._elements;
if (languageMenu.length > 0) {
languageMenu[0].open = true;
}
@ethangardner
ethangardner / .gitignore
Created May 23, 2017 14:19
Global gitignore file
# Languages that I don't work with...
*.o
*.lo
*.la
*.al
.libs
*.so
*.so.[0-9]*
*.a
# Python
// Macro recorded on: Wed Oct 05 2016 22:55:50 GMT-0400 (Eastern Standard Time)
komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }
(function(){
var currentView = ko.views.manager.currentView;
var scimoz = currentView.scimoz;
var path = ko.interpolate.interpolateString(["%F"]);
var project = ko.interpolate.interpolateString(["%i"]);
var platform = navigator.platform.toLowerCase();
@ethangardner
ethangardner / .maintenance
Created September 23, 2016 16:10
Throw WordPress into maintenance mode without a plugin
<?php $upgrading = time(); ?>
@ethangardner
ethangardner / posts_by_language.xsl
Last active September 16, 2016 14:04
Makes a tab-delimited file from a WordPress post export
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/">
<xsl:output encoding="UTF-8" indent="yes" cdata-section-elements="content:encoded wp:meta_value category" method="text" standalone="yes" />
@ethangardner
ethangardner / git_large_files.sh
Created September 14, 2016 21:02
Finds large files in a git repo
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -10 | awk '{print$1}')"
@ethangardner
ethangardner / wp-plugin-activation-error.php
Created September 6, 2016 14:55
Captures activation errors for WP plugins
<?php
// https://www.toddlahman.com/the-plugin-generated-x-characters-of-unexpected-output-during-activation/
function plugin_activate_save_error() {
ob_clean();
update_option( 'plugin_error', ob_get_contents() );
}
add_action( 'activated_plugin', 'plugin_activate_save_error' );
/* Then to display the error message: */
echo get_option( 'plugin_error' );
var track = {
google: {
event: function(args) {
if (typeof ga === "function") {
if (args.constructor !== [].constructor) {
new Error('This function takes an array as the argument. You passed a ' + typeof args);
}
else if( args.length < 2 || args.length > 5 ) {
new Error('This function needs an array of 2 to 5 items. You passed ' + args.length);
}
@ethangardner
ethangardner / .htaccess
Last active March 11, 2016 19:45
Redirect non-www version of a domain to www
# BEGIN Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
</IfModule>
# END Redirect