Originally from http://stackoverflow.com/questions/6725890/location-host-vs-location-hostname-and-cross-browser-compatibility/11379802#11379802
- deal with anchors to be able to copy links
- make parts contenteditable
Originally from http://stackoverflow.com/questions/6725890/location-host-vs-location-hostname-and-cross-browser-compatibility/11379802#11379802
| if (!Object.__proto__) { | |
| var sandbox = function () { | |
| // create an <iframe> | |
| var iframe = document.createElement("iframe"); | |
| iframe.style.display = "none"; | |
| document.documentElement.appendChild(iframe); | |
| return frames[frames.length - 1]; | |
| } | |
| var iframe = sandbox(); |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| /** | |
| * Bitwise Mathematics Utilities | |
| * | |
| * A collection of fast bitwise operations for integer mathematics. | |
| * These functions prioritize performance over readability and should be used | |
| * when micro-optimizations are critical (game engines, real-time applications). | |
| * | |
| * References: | |
| * - http://michalbe.blogspot.com.br/2013/03/javascript-less-known-parts-bitwise.html | |
| * - http://jsperf.com/bitwise-vs-math-object |
| function logClass(target: any) { | |
| // save a reference to the original constructor | |
| var original = target; | |
| // a utility function to generate instances of a class | |
| function construct(constructor, args) { | |
| var c : any = function () { | |
| return constructor.apply(this, args); | |
| } |
| // paste in your console | |
| speechSynthesis.onvoiceschanged = function() { | |
| var msg = new SpeechSynthesisUtterance(); | |
| msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0]; | |
| msg.text = Object.keys(window).join(' '); | |
| this.speak(msg); | |
| }; |
| Service | SSL | status | Response Type | Allowed methods | Allowed headers |
|---|
| // Compile on JDK 9 or 10 with javac -source 1.8 -target 1.8 CallDefaultMethodThroughReflection.java | |
| // Blog post here: https://blog.jooq.org/2018/03/28/correct-reflective-access-to-interface-default-methods-in-java-8-9-10 | |
| import java.lang.invoke.MethodHandles; | |
| import java.lang.invoke.MethodHandles.Lookup; | |
| import java.lang.invoke.MethodType; | |
| import java.lang.reflect.Constructor; | |
| import java.lang.reflect.Method; | |
| import java.lang.reflect.Proxy; |
| class UInt48 { | |
| constructor(n) { | |
| if (n instanceof UInt48) { | |
| Object.assign(this, n); | |
| } else if (typeof n === 'number') { | |
| let w0 = n & 0xffff; | |
| n /= 0x10000; | |
| let w1 = n & 0xffff; | |
| n /= 0x10000; |