Skip to content

Instantly share code, notes, and snippets.

View dnlmelo's full-sized avatar

DevDan dnlmelo

View GitHub Profile
@dnlmelo
dnlmelo / file_mime_types.js
Last active September 26, 2017 16:38
Commom list of file mime types in javascript
var mimetypes = [
{name: 'aif', mime: 'audio/x-aiff'},
{name: 'aiff', mime: 'audio/x-aiff'},
{name: 'asf', mime: 'video/x-ms-asf'},
{name: 'asx', mime: 'video/x-ms-asx'},
{name: 'avi', mime: 'video/avi'},
{name: 'bin', mime: 'application/octet-stream'},
{name: 'bmp', mime: 'image/bmp'},
{name: 'bz', mime: 'application/x-bzip'},
{name: 'bz2', mime: 'application/x-bzip2'},
@dnlmelo
dnlmelo / gist:723aa257bcc5cdae79755c9d30802ed6
Created August 31, 2016 22:49 — forked from thomseddon/gist:3511330
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});