Skip to content

Instantly share code, notes, and snippets.

View djforth's full-sized avatar

Adrian Stainforth djforth

View GitHub Profile
@adrianstainforth
adrianstainforth / pjax_setup.js.coffee
Created November 7, 2012 11:21
PJAX JavaScript
#Checks if push state is available
if (history && history.pushState)
#sets higher time out other wise pjax aborts a lot
$.pjax.defaults.timeout = 10000
$(document).pjax("a.pjax", "[data-pjax-container]").on "pjax:end", ->
#Trigger code that needs to happen on page load
@adrianstainforth
adrianstainforth / CSS3Transitions.js
Created November 7, 2012 10:35
Feature Detection
//Detect CSS3 Transitions
var cssTransitionsSupported = false;
(function() {
var div = document.createElement('div');
div.innerHTML = '<div style="-webkit-transition:color 1s linear;-moz-transition:color 1s linear;"></div>';
cssTransitionsSupported = (div.firstChild.style.webkitTransition !== undefined) || (div.firstChild.style.MozTransition !== undefined);
// console.log(cssTransitionsSupported);
delete div;
})();
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@wiemann
wiemann / carrierwave_initializer.rb
Created December 6, 2010 13:20
carrierwave minimagick quality parameter to set jpeg quality
# rails carrierwave initializer that gives you a quality option in your uploader. use:
# version :medium do
# process :resize_to_fit => [640, 480]
# process :quality => 95
# end
module CarrierWave
module MiniMagick