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 / 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) {}