Skip to content

Instantly share code, notes, and snippets.

View AbuzerAsif's full-sized avatar
😃
Writing Code and Having Fun :)

Abuzer Asif AbuzerAsif

😃
Writing Code and Having Fun :)
  • 127.0.0.1
View GitHub Profile
@AbuzerAsif
AbuzerAsif / gist:ad08ce03807256ead7b8b70c46c2df08
Created August 28, 2018 11:17 — 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];
}
});
@AbuzerAsif
AbuzerAsif / angularjs-interceptor.js
Last active May 8, 2018 09:36 — forked from edysegura/angularjs-interceptor.js
[angularjs] How to create an AngularJS HTTP Interceptor
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Add the interceptor to the $httpProvider.
$httpProvider.interceptors.push('MyHttpInterceptor');
})
// Intercept http calls.
.factory('MyHttpInterceptor', function ($q) {
return {
@AbuzerAsif
AbuzerAsif / .jsbeautifyrc
Created April 20, 2018 12:38 — forked from wzup/.jsbeautifyrc
.jsbeautifyrc file example
{
// The plugin looks for a .jsbeautifyrc file in the same directory as the
// source file you're prettifying (or any directory above if it doesn't exist,
// or in your home folder if everything else fails) and uses those options
// along the default ones.
// Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options
// Documentation: https://github.com/einars/js-beautify/
"html": {
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg", "dust"],