Skip to content

Instantly share code, notes, and snippets.

View uberspeck's full-sized avatar
🏠
Working from home

Brian Campbell uberspeck

🏠
Working from home
  • Degreed
  • Colorado
View GitHub Profile
@jtomaszewski
jtomaszewski / rt-stateful-component.ts
Created January 11, 2019 11:05
Example implementation of StatefulComponent in Angular
// Code authored by [Recruitee](https://recruitee.com)
// License: MIT
import { Injectable, ChangeDetectorRef } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
const immutableStateInvariantMiddleware = process.env.NODE_ENV !== 'production'
? require('redux-immutable-state-invariant').default
: null;
export interface RtStatefulComponent<State> {
@thomseddon
thomseddon / gist:3511330
Last active March 8, 2023 03:39
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];
}
});