Skip to content

Instantly share code, notes, and snippets.

View rmcveigh's full-sized avatar

Ryan McVeigh rmcveigh

View GitHub Profile
@rmcveigh
rmcveigh / download-file.js
Created June 4, 2019 21:08 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@rmcveigh
rmcveigh / _flexbox-mixins.scss
Created May 11, 2017 15:38
SCSS Flexbox Mixins for Flex items and Flex containers
// Combines some of the common flex item attributes to simplify usage.
@mixin flex-item($order: false , $flexgrow: 0 , $flexshrink: 1, $flexbasis: auto, $alignself: false) {
//values:
// $order: <integer>
// $flexgrow: <number> (default 0)
// $flexshrink: <number> (default 1)
// $flexbasis: <length> | auto (default auto)
// $alignself: auto | flex-start | flex-end | center | baseline | stretch
// We use long hand so as not to confuse IE.
@rmcveigh
rmcveigh / _css-grid-mixins.scss
Created May 11, 2017 15:35
SCSS mixin's for css grid containers and css grid items
// Combines some of the common grid item attributes to simplify usage.
@mixin grid-item($gridcolumnstart: false, $gridcolumnend: false, $gridrowstart: false, $gridrowend: false, $gridarea: false, $justifyself: false, $alignself: false) {
//values:
// $gridcolumnstart: <line> | span <number> | span <name> | auto
// $gridcolumnend: <line> | span <number> | span <name> | auto
// $gridrowstart: <line> | span <number> | span <name> | auto
// $gridrowend: <line> | span <number> | span <name> | auto
// $gridarea: <name> | <row-start> / <column-start> / <row-end> / <column-end>
// $justifyself: start | end | center | stretch
// $alignself: start | end | center | stretch
@rmcveigh
rmcveigh / superscript-check.js
Created December 8, 2015 23:33
Checks for superscript.
/**
* @file
* A JavaScript file for the theme.
* This file finds text with ®s that are dynamically add and wraps them in <sup>
*
*/
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it with an "anonymous closure". See:
// - https://drupal.org/node/1446420
@rmcveigh
rmcveigh / accordion.js
Last active December 8, 2015 17:11
Simple accordion js for Drupal. Relies on jQuery
/**
* @file
* A JavaScript file for the theme.
* This file should be used as a template for your other js files.
* It defines a drupal behavior the "Drupal way".
*
*/
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it with an "anonymous closure". See:
@rmcveigh
rmcveigh / anon-function.js
Created December 5, 2012 17:36 — forked from laustdeleuran/anon-function.js
JavaScript: Anonymous function
(function(){
// Safe, scoped JavaScript here. Phew.
})();
@rmcveigh
rmcveigh / gist:4217757
Created December 5, 2012 17:35 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}