Advertisement
yoursunny

Virmach valuation

Dec 8th, 2020 (edited)
1,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // unobfuscated from https://virmach.app/ , retrieved on 2020-12-09 01:20 UTC
  2. // original script archived at https://web.archive.org/web/20201208225523js_/https://virmach.app/src.a918aee7.js
  3.  
  4. function valuation(input) {
  5.     var price = Number(input['price'].match(/\d[\d.]*/)[0]);
  6.     var value = (5 * input['cpu'] + Number(input['ram']) / 1024 * 3 + input['hdd'] * (5 - Math.log(input['hdd']) / 3.0081547935525483) / 10 + 4 * (input['ips'] - 1)) / (input['virt'].match(/KVM/i) ? 1 : 2);
  7.     value *= 1.05,
  8.     input['ram'] < 256 && (value *= 0.8),
  9.     input['ram'] < 512 && (value *= 0.85),
  10.     input['ram'] < 1024 && (value *= 0.9),
  11.     input['hdd'] < 5 && (value *= 0.25),
  12.     input['bw'] < 200 && (value *= 0.25);
  13.     var percentOff = 100 - Math.floor(price / value * 100)
  14.       , annotation = '';
  15.     return !(annotation = percentOff >= 65 ? 'best' : percentOff >= 45 ? 'great' : percentOff >= 35 ? 'good' : percentOff >= 20 ? 'average' : '') && price <= 8.5 && (annotation = 'cheap'),
  16.     input['bw'] < 200 && (annotation = ''),
  17.     {
  18.         'price': price,
  19.         'percentOff': percentOff,
  20.         'value': value,
  21.         'annotation': annotation
  22.     };
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement