drudge's notebooks

  • Untitled - /drudge/aaaaa
    Last edited 4 months ago
    var endpoint = require("@runkit/runkit/json-endpoint/1.0.0"); endpoint(exports, async function(incomingData) { console.log(incomingData.body) return true })
  • Untitled - /drudge/test
    Last edited 4 years ago
    const TrevcoPricing = ({ price }) => {   const new_price = Math.round(price * (1.0 / (1.0 - 0.60))) - 0.01;   if (new_price < 0.0) return 0.0;   return Number(new_price.toFixed(2)); }; const regularPrice = TrevcoPricing({price: 11.50 }); console.log('Regular price: ', regularPrice); console.log('Promo price: ', Number(regularPrice - regularPrice*.15).toFixed(2));
  • Untitled - /drudge/shit
    Last edited 5 years ago
    const Uniq = require('lodash.uniq'); const StrCommon = (values = []) => { let i = 0; let brk = -1; const strs = values.filter(Boolean); if (!strs.length) { return null; } if (strs.length === 1) { return strs.pop(); } if (Uniq(strs).length === 1) { return strs[0]; } while (brk < 0) { const chars = strs .map(str => str[i]) .map(ch => (ch ? ch.toLowerCase() : ch)) if (chars.every(ch => !ch)) { break; } if (chars.some(ch => ch !== chars[0])) { brk = i; break; } i += 1; } if (brk < 0) { return null; } return strs[0].slice(0, brk); }; console.log(StrCommon([ "Blink-182", "Blink 182", "Blink 182", "Blink 182", "Blink 182", "Blink 182", "Blink 182", "Blink 182", "Blink-182", "Blink-182", "Blink 182", "Blink-182" ])) console.log(StrCommon([ "Enema of the State", "Enema of the State 2CDS", "Enema of the State", "Enema Of The State +9", "Enema of the State", "Enema Of State(Bonus Trck", "Enema Of The State (Vinyl", "Enema Of The State", "Enema of the State", "Enema Of The State", "Enema Of The State (Ltd)", "Enema Of The State (Blue) (Colv)" ]))