Skip to content

Instantly share code, notes, and snippets.

Avatar

Joram Clervius swoleengineer

View GitHub Profile
View citrusbyte
const isFlat = array => {
if (!array) return true;
for (let i = 0; i < array.length; i++) {
if (array[i] instanceof Array) return false;
}
return true;
}
const makeFlat = arr => {
while (!isFlat(arr)) arr = arr.reduce((a,b) => a.concat(b), []);
@swoleengineer
swoleengineer / metric_filter.js
Last active Apr 28, 2017
Angular filter for metric from imperial ({ft + in -> cm}, {lbs -> kg})
View metric_filter.js
app.filter('metric', function(authToken){
return function(input, type, inch) {
var isMetric = authToken.getMetric();
if(isMetric) {
if(type == 'cm') {
if(isNaN(input)) {
return 'cm.';
} else {
if(inch) {
return ((((input * 12) * 1) + (inch * 1)) * 2.54).toFixed(2) + ' cm.';
You can’t perform that action at this time.