Skip to content

Instantly share code, notes, and snippets.

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

Joram Clervius swoleengineer

🏠
Working from home
View GitHub Profile
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 April 28, 2017 14:57
Angular filter for metric from imperial ({ft + in -> cm}, {lbs -> kg})
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.';