Skip to content

Instantly share code, notes, and snippets.

View kptdobe's full-sized avatar
🎯
Focusing

Alexandre Capt kptdobe

🎯
Focusing
View GitHub Profile
@kptdobe
kptdobe / log.js
Last active May 5, 2023 03:38
Chrome Extension: console log in page console, not in extension console
// returns current tab
const getCurrentTab = async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
return tab;
}
// log to current page console
const log = async (...arguments) => {
const tab = await getCurrentTab();
javascript: fetch(window.location.href, { method: 'PURGE'}); document.querySelectorAll('script, link[rel="stylesheet"]').forEach((t) => { fetch(t.src || t.href, { method: 'PURGE'});}); window.location.reload();
@kptdobe
kptdobe / override.md
Last active May 13, 2019 09:28
How to select content repo based on subdomain (format: https://<owner>-<repo>.yourhost.com)
# Gets the content owner for the current strain and sets the X-Owner header
sub hlx_owner {
  set req.http.X-Trace = req.http.X-Trace + "; hlx_owner";

  set req.http.X-Owner = table.lookup(strain_owners, req.http.X-Strain);
  if (!req.http.X-Owner) {
    set req.http.X-Owner = table.lookup(strain_owners, "default");
  }
  

Keybase proof

I hereby claim:

  • I am kptdobe on github.
  • I am acapt (https://keybase.io/acapt) on keybase.
  • I have a public key ASDS00nMKjVbw4r-jy1iaSyb4M01HcD-gCOwAi1XRrP8RQo

To claim this, I am signing this object: