This file contains hidden or 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
function extractDomain(url) { | |
let domain; | |
// remove protocol | |
if (url.indexOf("://") > -1) { | |
domain = url.split('/')[2]; | |
} | |
else { | |
domain = url.split('/')[0]; | |
} |
This file contains hidden or 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
function hdist(a, b) { | |
let one = BigInt(1); | |
let d = 0; | |
let h = a ^ b; | |
while (h > 0) { | |
d ++; | |
h &= h - one; | |
} | |
return d; | |
} |
This file contains hidden or 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
// returns textFragment | |
function() { | |
if (!performance) { | |
return 'n/a'; | |
} | |
var p = performance.getEntriesByType('navigation'); | |
if (p.length < 1) { | |
return 'navigation missing'; | |
} |
This file contains hidden or 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
function scrollTo() { | |
if (navigator.userAgent.indexOf("Googlebot") == -1) { | |
return; | |
} | |
if (!window.scrollBy) { | |
return; | |
} | |
var pagePattern = /page=(?<page>\d+)/; | |
var matched = document.location.hash.match(pagePattern); | |
if (!matched || !matched.groups || (!matched.groups.page) ) { |
This file contains hidden or 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
<!doctype html> | |
<html lang="en" prefix="og: http://ogp.me/ns#"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Google Fetch and Render test</title> | |
</head> | |
<body> | |
<span>useragent</span> | |
<p id="uaOutput"></p> |
This file contains hidden or 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
<!doctype html> | |
<html lang="en" prefix="og: http://ogp.me/ns#"> | |
<head> | |
<meta charset="utf-8"/> | |
<link rel="canonical" href=" [insert your url here] "/> | |
<title>Google Fetch and Render test</title> | |
</head> | |
<body> | |
<span>time diff</span> | |
<p id="speedOutput"></p> |
This file contains hidden or 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
curl -XPOST localhost:9200/test -d '{ | |
"mappings" : { | |
"person" : { | |
"properties" : { | |
"name" : { "type" : "string" } | |
} | |
}, | |
"homes" : { | |
"_parent":{ "type" : "person" }, | |
"properties" : { |
This file contains hidden or 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
heap code: http://eloquentjavascript.net/appendix2.html | |
hyperloglog: https://github.com/sedictor/loglog | |
top k elements: http://stevehanov.ca/blog/index.php?id=122 |