Skip to content

Instantly share code, notes, and snippets.

View thinog's full-sized avatar
🤙

Thiago Martins thinog

🤙
View GitHub Profile
@thinog
thinog / not-so-important-third-party-script.js
Created June 14, 2024 13:41
Script minified in https://github.com/thinog/bad-web-vitals-workshop to force people to defer the execution of non-critical scripts.
async function run() {
const delayMs = 1000;
const startedAt = Date.now();
console.log("[Workshop] Starting a third-party script not so important 😃");
if (document.currentScript.defer) {
await new Promise((resolve) => setTimeout(resolve, delayMs));
} else {
const waitUntil = Date.now() + delayMs;
@thinog
thinog / es-updating-nested-fields.txt
Created October 6, 2020 03:20
Elasticsearch - Updating nested fields
POST my-index/_update_by_query
{
"script": {
// "source" after v5.6, "inline" before
"source": """
for (item in ctx._source.nested_items) {
for(param in params.new_values) {
if (item.category == param.category) {
item.description = param.description;
}