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
// http://michalbe.blogspot.com.br/2013/03/javascript-less-known-parts-bitwise.html | |
// http://jsperf.com/bitwise-vs-math-object | |
// http://united-coders.com/christian-harms/results-for-game-for-forfeits-and-the-winner-is/ | |
// https://mudcu.be/journal/2011/11/bitwise-gems-and-other-optimizations/ | |
// https://dreaminginjavascript.wordpress.com/2009/02/09/bitwise-byte-foolish/ | |
// http://jsperf.com/math-min-max-vs-ternary-vs-if/24 | |
"use strict"; | |
var PI = Math.PI; |
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; |