Last active
June 13, 2025 14:12
-
-
Save ukdave/26f835e035047ed0064c640f681ab6cb to your computer and use it in GitHub Desktop.
Calculator for the retriable gem (https://github.com/kamui/retriable).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <title>Page Title</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4Q6Gf2aSP4eDXB8Miphtr37CMZZQ5oXLH2yaXMJ2w8e2ZtHTl7GptT4jmndRuHDT" crossorigin="anonymous"> | |
| <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> | |
| <style> | |
| label { font-weight: bold; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Retriable Calculator</h1> | |
| <p>Calculator for the <a href="https://github.com/kamui/retriable">retriable</a> gem.</p> | |
| <div style="width: 30em;" x-data="{ baseInterval: 0.5, multiplier: 1.5, randFactor: 0.5, tries: 10 }"> | |
| <form> | |
| <div class="input-group mb-3"> | |
| <label class="input-group-text" style="width: 8em;">Base Interval</label> | |
| <input class="form-control" name="baseInterval" type="number" min="0" step="0.25" x-model="baseInterval"> | |
| </div> | |
| <div class="input-group mb-3"> | |
| <label class="input-group-text" style="width: 8em;">Multiplier</label> | |
| <input class="form-control" name="baseInterval" type="number" min="0" step="0.25" x-model="multiplier"> | |
| </div> | |
| <div class="input-group mb-3"> | |
| <label class="input-group-text" style="width: 8em;">Rand Factor</label> | |
| <input class="form-control" name="baseInterval" type="number" min="0" step="0.25" x-model="randFactor"> | |
| </div> | |
| <div class="input-group mb-3"> | |
| <label class="input-group-text" style="width: 8em;">Tries</label> | |
| <input class="form-control" name="baseInterval" type="number" min="1" x-model="tries"> | |
| </div> | |
| </form> | |
| <table class="table table-striped text-end"> | |
| <thead> | |
| <tr> | |
| <th style="width: 25%">Retry #</th> | |
| <th style="width: 25%">Min</th> | |
| <th style="width: 25%">Average</th> | |
| <th style="width: 25%">Max</th> | |
| </tr> | |
| </thead> | |
| <tbody class="font-monospace"> | |
| <template x-for="i in parseInt(tries) - 1" :key="i"> | |
| <tr> | |
| <td x-text="i"></td> | |
| <td x-text="(parseFloat(baseInterval) * Math.pow(parseFloat(multiplier), i-1) * (1 - parseFloat(randFactor))).toFixed(3)"></td> | |
| <td x-text="(parseFloat(baseInterval) * Math.pow(parseFloat(multiplier), i-1)).toFixed(3)"></td> | |
| <td x-text="(parseFloat(baseInterval) * Math.pow(parseFloat(multiplier), i-1) * (1 + parseFloat(randFactor))).toFixed(3)"></td> | |
| </tr> | |
| </template> | |
| <tr> | |
| <td x-text="tries"></td> | |
| <td>stop</td> | |
| <td>stop</td> | |
| <td>stop</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment