Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| function tryAgain(fn, times = 2){ | |
| try { | |
| return fn(times); | |
| } catch (e) { | |
| if (times > 1) return tryAgain(fn, times-1); | |
| throw e; | |
| } | |
| } | |
| // This is part of the blog post here: https://whistlr.info/2022/abortcontroller-is-your-friend/ | |
| // ...and can be used to detect/polyfill the `signal` argument to addEventListener. | |
| // | |
| // Note that at writing, 86%+ of active browsers already support it: | |
| // https://caniuse.com/mdn-api_eventtarget_addeventlistener_options_parameter_options_signal_parameter | |
| // ...but that 92% of browsers support `AbortController` and signal. | |
| // | |
| // So there's 6% of total browsers which will fail silently when adding the `signal` argument. | |
| // Eyeballing it, this is mostly Safari 11-15 and Chrome 66-90. These snippets can help with those targets. | |
| // |
| class WeakValue extends Map { | |
| #registry = new FinalizationRegistry(key => { | |
| if (this.has(key) && !this.get(key).deref()) | |
| this.delete(key); | |
| }); | |
| get(key) { | |
| const value = super.get(key); | |
| return value && value.deref(); | |
| } | |
| set(key, value) { |
| !(function(){ | |
| var original = console; | |
| Object.defineProperty(window, 'console', { | |
| get:function(){ | |
| return original; | |
| }, | |
| set:function(value){ | |
| original.log(value) | |
| } | |
| }) |
| #!/bin/bash | |
| # Make sure you are up to date | |
| yum -y update && yum -y install wget | |
| # Install EPEL repository | |
| rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
| # Get us a clean working directory | |
| mkdir /php |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| /* | |
| * Copyright (c) 2010 Tobias Schneider | |
| * This script is freely distributable under the terms of the MIT license. | |
| */ | |
| (function(){ | |
| var UPC_SET = { | |
| "3211": '0', | |
| "2221": '1', | |
| "2122": '2', |