Skip to content

Instantly share code, notes, and snippets.

@a-axton
a-axton / strip-units.scss
Created March 29, 2017 21:33
Strip sass/scss units
@function strip-units($number) {
@return $number / ($number * 0 + 1);
}
@a-axton
a-axton / walker.js
Created January 27, 2017 00:32
DOM walker to return parent that has specific class
getInputParent (el) {
const walk = (node) => {
if (node.parentNode) {
if (node.parentNode.classList.contains('input')) {
return node.parentNode;
} else {
return walk(node.parentNode);
}
}
}
@a-axton
a-axton / ContrivedExampleComponent.js
Last active July 16, 2016 00:29
Custom route leave
import React from 'react';
import RouteLeaveConfirmation from './RouteLeaveConfirmation';
class ExampleComponent extends React.Component {
onConfirmRouteWillLeave () {
console.log('confirmed');
}
onCancelRouteWillLeave () {
console.log('cancelled');
@a-axton
a-axton / build.scss
Created June 30, 2014 01:51
Bootstrap style grid using neat and SASS maps
// replace map keys with whatever you want
// creats classes as .grid-$keyname-$col
$breakpoint-widths: (xs: 480px, sm: 768px, md: 992px, lg: 1200px);
$grid-columns: 12
// media query mixin
@mixin mq($search) {
@media (min-width: map-get($breakpoint-widths, $search)){
@content
}
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var gulp = require('gulp');
var handleErrors = require('../util/handleErrors');
var source = require('vinyl-source-stream');
function scripts(watch) {
var bundler, rebundle;
@a-axton
a-axton / gist:8a5a6cdb379655b47eff
Created May 21, 2014 17:22
Document fragments
var table = document.getElementById('t');
var tr = table.querySelector('tr');
var th = document.createElement('th');
var clone;
var df = document.createDocumentFragment();
for (var i = 0; i < 100; i++) {
// Performance tip: clone a node so that you don't reuse createElement()
clone = th.cloneNode();
@a-axton
a-axton / application.js
Last active August 29, 2015 13:57
Creating a marionette module that can be placed within other areas of the application via Foo.display
// Application.js file
var MyApp = new Backbone.Marionette.Application();
MyApp.addRegions({
someRegion: "#some-div"
});
MyApp.addInitializer(function(options){
if(options.somethingOrOther) {
MyApp.Foo.display(MyApp.someRegion);