Skip to content

Instantly share code, notes, and snippets.

View RudolfHattenkofer's full-sized avatar

Rudolf Hattenkofer RudolfHattenkofer

  • Munich, Germany
View GitHub Profile
@RudolfHattenkofer
RudolfHattenkofer / jquery.offon.js
Created September 28, 2013 13:45
Automatically remove and add an event so it only exists once for an element.
(function ( $ ) {
$.fn.offon = function( name, func ) {
this.off( name ).on( name, func );
return this;
}
}(jQuery));
@RudolfHattenkofer
RudolfHattenkofer / distance.coffee
Created September 28, 2013 13:41
"Distance" between two elements in the DOM.
$node.closest( $target ).length
@RudolfHattenkofer
RudolfHattenkofer / application.rb
Created September 28, 2013 13:34
Add assets to the precompile list so they work in production. (Place in config/application.rb)
config.assets.precompile += %w(style.css)
@RudolfHattenkofer
RudolfHattenkofer / vertical-center.css
Created September 28, 2013 13:31
Vertical center hack: Position an element *really* in the center of its parent.
parent {
position: relative;
}
el {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
@RudolfHattenkofer
RudolfHattenkofer / typekit-tinymce.coffee
Created September 28, 2013 13:28
Include Typkit in TinyMCE. Don't forget the Kit ID in line 9!
tinyMCE.init
setup: ( ed ) ->
ed.on 'PreInit', (e) ->
doc = ed.getDoc()
# Create the script we will add to the header asynchronously
jscript = "(function() {\n
var config = {\n
kitId: '######'\n
};\n