This file contains 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
/// Always forget it | |
/// Source: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm | |
relativeError = fabs((result - expectedResult) / expectedResult); | |
// If result is 99.5, and expectedResult is 100, then the relative error is 0.005. | |
// Sometimes we don’t have an ‘expected’ result, we just have two numbers that we want to compare to see if they are almost equal. // We might write a function like this: | |
// Non-optimal AlmostEqual function - not recommended. |
This file contains 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
// cart.js | |
// | |
// Copyright 2014 Jeka Kiselyov | |
// Released under the MIT license, http://opensource.org/licenses/MIT | |
// | |
// Usage: | |
// Cart.add(sku, name, 9.99, qty); | |
// Cart.remove(sku); | |
// if (Cart.has(sku)) { ... | |
// var price = Cart.priceTotal(); |
This file contains 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
Test date format:<br> | |
En: {234234|date_format:'%B %e, %Y'}<br> | |
Rus: {234234|date_format:'%e %m %Y':'':'rus'}<br> | |
Urk: {234234|date_format:'%e %m %Y':'':'ukr'}<br> | |
First parameter - php.net/strftime (%m is changed to 'января':'декабря' for Russian and 'ciчня':'грудня' for Ukrainian) | |
Second parameter - default date (if argument == '') | |
Third - 'auto', 'rus', 'ukr' | |
Works with 0F modified date_format Smarty plugin. It's below in this gist: modifier.date_format.php |
NewerOlder