Skip to content

Instantly share code, notes, and snippets.

View jmmcduffie's full-sized avatar

Jeremy McDuffie jmmcduffie

View GitHub Profile
@jmmcduffie
jmmcduffie / extract-data-objects.js
Created April 8, 2015 19:06
Data Attribute Object
function extractDataObjects(node) {
var objects = {},
attributes = [].slice.call(node.attributes);
attributes.forEach(function(attribute) {
if (/^data-/.test(attribute.nodeName)) {
objects[attribute.nodeName.slice(5)] = attribute.value;
}
});
@jmmcduffie
jmmcduffie / extract-data-options.js
Last active August 29, 2015 14:18
Data Attribute Options
// Usage:
//>: extractDataOptions( $("<div data-foo='opt1:bar opt2:baz'/>").data("foo") )
//<: { opt1: "bar", opt2: "baz" }
function extractDataOptions(attr) {
var options = {};
if (!!attr) {
attr.split(" ").forEach(function(option) {
var pieces = option.split(/:(.+)?/),
@jmmcduffie
jmmcduffie / keymap.cson
Created March 30, 2015 15:59
Atom Keymap Configuration
"atom-workspace atom-text-editor:not([mini])":
"alt-shift-down": "editor:add-selection-below"
"alt-shift-up": "editor:add-selection-above"
@jmmcduffie
jmmcduffie / gist:fa09376940afdf67ebc1
Created March 25, 2015 23:00
Rails generators configuration
# in config/application.rb
config.generators do |g|
g.helper false
g.assets false
g.skip_routes true
g.controller_specs false
g.view_specs false
end
@jmmcduffie
jmmcduffie / g
Last active August 29, 2015 14:14
Bash `g` function for Git
function g {
if [[ $# > 0 ]]; then
"git" "$@"
else
git status
fi
}
@jmmcduffie
jmmcduffie / behaviors.js
Last active August 29, 2015 13:56
Progressively Enhanced Single-Page Navigation
// Add an event listener to the document
$(document).on( "click", "a[data-behavior='scrollTo']", function(event) {
// Check for a fragment on the clicked link
// `this.hash` = the fragment identifier
if ( this.hash !== "" ) {
// Animate the viewport's scroll position
$("html, body").animate({ scrollTop: $( this.hash ).offset().top }, 500);
@jmmcduffie
jmmcduffie / SassMeister-input.scss
Created November 18, 2013 22:56
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
@mixin calc($property, $value, $fallback) {
#{$property}: $fallback;
#{$property}: -webkit-calc(#{$value});
#{$property}: calc(#{$value});
}