Skip to content

Instantly share code, notes, and snippets.

View VorticonCmdr's full-sized avatar
🎯
Focusing

Valentin VorticonCmdr

🎯
Focusing
View GitHub Profile
@VorticonCmdr
VorticonCmdr / extractDomainfromURL.js
Created May 12, 2023 11:16
chatGPT result on how to extract a domain from an url
function extractDomain(url) {
let domain;
// remove protocol
if (url.indexOf("://") > -1) {
domain = url.split('/')[2];
}
else {
domain = url.split('/')[0];
}
@VorticonCmdr
VorticonCmdr / hamming.js
Created March 16, 2022 07:52
Hamming distance for BigInt
function hdist(a, b) {
let one = BigInt(1);
let d = 0;
let h = a ^ b;
while (h > 0) {
d ++;
h &= h - one;
}
return d;
}
@VorticonCmdr
VorticonCmdr / tagManagerCustomFunctions.js
Last active January 10, 2022 16:30
tagManager functions for SEO
// returns textFragment
function() {
if (!performance) {
return 'n/a';
}
var p = performance.getEntriesByType('navigation');
if (p.length < 1) {
return 'navigation missing';
}
@VorticonCmdr
VorticonCmdr / scrollTo.js
Created February 18, 2021 10:57
scroll the page via #anchor
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) ) {
<!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>
@VorticonCmdr
VorticonCmdr / fetchrendertest.html
Created October 10, 2018 06:24
google search console fetch & render test
<!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>
@VorticonCmdr
VorticonCmdr / gist:63e34e04535bef8c0398
Created July 17, 2015 13:18
elasticsearch parent child sort by child value
curl -XPOST localhost:9200/test -d '{
"mappings" : {
"person" : {
"properties" : {
"name" : { "type" : "string" }
}
},
"homes" : {
"_parent":{ "type" : "person" },
"properties" : {
@VorticonCmdr
VorticonCmdr / copyright
Created December 4, 2012 16:55
hyperloglog for elasticsearch script facet plugin (alpha code)