I hereby claim:
- I am nmenglund on github.
- I am nme (https://keybase.io/nme) on keybase.
- I have a public key whose fingerprint is 5D8F 6D97 6BB4 3BA2 9BE2 071B 57FA 9ACC 8321 63A0
To claim this, I am signing this object:
| <?php | |
| /** | |
| * Performance improved gather_discount_coeffs function | |
| * code adapted from woocommerce-bulk-discount 2.4.5 | |
| * by Nils Magnus Englund <nme@stepone.no> | |
| * | |
| * NOTE: The code below is only compatible with WooCommerce 3.0 as-is. | |
| * Should be easy enough to backport. | |
| * |
| <?php | |
| /* | |
| * Example: | |
| * | |
| * $store = PersistentArray::load('example.json'); | |
| * echo "Key is: " . (isset($store['key']) ? $store['key'] : 'not set') . "\n"; | |
| * $store['key'] = '123'; | |
| * | |
| * Running this twice will yield: |
I hereby claim:
To claim this, I am signing this object:
| String.prototype.format = function() { | |
| var args = arguments; | |
| return this.replace(/{(\d+)}/g, function(match, number) { return ((typeof args[number] != 'undefined') ? args[number]: match); }); | |
| }; |
| // Insert a string into the given string at position idx, after removing 'rem' existing characters | |
| String.prototype.splice = function(idx, rem, s) { | |
| return (this.slice(0,idx) + s + this.slice(idx + Math.abs(rem))); | |
| } |
| // Repeat a given string 'num' times | |
| String.prototype.repeat = function(num) | |
| { | |
| if (num == 1) | |
| return this.toString(); | |
| else if (num < 1) | |
| return ""; | |
| else | |
| return new Array(+num + 1).join(this.toString()); | |
| } |
| // Nordic number formatter; using , as decimal point when precision>0, | |
| // and space as thousand separator otherwise | |
| Number.prototype.formatNordic = function(precision) { | |
| precision = precision || 0; | |
| var rounded = Math.round(+this * Math.pow(10, precision)) / Math.pow(10, precision); | |
| var result = rounded.toString().replace(".",","); | |
| if (+precision > 0) { | |
| var pos = result.indexOf(','); | |
| if (pos == -1) | |
| result += "," + '0'.repeat(precision); |