Skip to content

Instantly share code, notes, and snippets.

View rosschapman's full-sized avatar

Ross Chapman rosschapman

View GitHub Profile
@rosschapman
rosschapman / delete-all-branches.sh
Created March 20, 2014 00:58
Delete all local git branches.
git branch | grep -v "master" | xargs git branch -D
@rosschapman
rosschapman / $proxy-example.js
Last active August 29, 2015 13:57
$.proxy Example
function SomePlugin() {
this.element = '.myDiv';
this.options = {someOption: true};
this.init();
}
SomePlugin.prototype = {
init: function() {
$.proxy(this._privateMethod(), this);
},
_privateMethod: function() {
@rosschapman
rosschapman / respond-js-partial.erb
Last active August 29, 2015 14:21
Respond.js Rails Partial
<%#
The Respond.js library polyfills media queries for IE8 (and below). Note that order of the
following statements is important. Read more: https://github.com/scottjehl/Respond.
%>
<!--[if IE 8]>
<%= javascript_include_tag 'respond' %>
<%#
Cross-domain (CDN) proxy.
Read more: https://github.com/scottjehl/Respond#cdnx-domain-setup.
@rosschapman
rosschapman / avoid-console-errors.html
Created May 31, 2015 01:05
Avoid `console` errors in browsers that lack a console.
<!--[if IE 8]>
<script>
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="200" height="230" id="FM3" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="http://www.zendesk.com/media/FM3.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /> <embed src="http://www.zendesk.com/media/FM3.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="200" height="230" name="FM3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object/>
@rosschapman
rosschapman / gist:2705595
Created May 15, 2012 22:23
Casper multi-page 404 tester
/*
* 404 Checker
*
*/
var casper = require('casper').create({
loadImages: false,
javascriptEnabled: false,
loadPlugins: false,
verbose: true,
@rosschapman
rosschapman / wp-ssl.php
Last active December 12, 2015 00:48
Sample for #wordpress SSL admin
* Force admin over SSL
*/
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
<?php
function not_foo( $class ) {
if ( get_bloginfo('name') != 'foo' ) {
$class[] = 'not_foo';
}
else {};
return $class;
}
@rosschapman
rosschapman / wp_get_category_names_for_any_post.php
Created July 1, 2013 21:06
wp_get_category_names_for_any_post.php #wordpress
<?php
function get_category_names_for_any_post(){
// Create empty array for later
$categoriesArray = array();
// Get current post type
$curentPostType = get_post_type($post->ID);
@rosschapman
rosschapman / post-no-reload.js
Created July 1, 2013 21:09
Post form data to Marketo w/o page reload (JavaScript)
function postToMarketo() {
var form = $('<form class="marketo-form" method="post" enctype="application/x-www-form-urlencoded" action="http://info.domain.com/index.php/leadCapture/save" id="mktForm_ID" name="mktForm_ID">');
var inputArr = {};
var selectedArr = {};
var key;
var inputs = $('form.leadgen input');
var selected = $('form.leadgen option[selected]');
var iframe = $('<iframe style="display:none;" id="new-form" src="/marketo_success.html"></iframe>');