Skip to content

Instantly share code, notes, and snippets.

View glenacota's full-sized avatar

Guido Lena Cota glenacota

View GitHub Profile
@glenacota
glenacota / demo.html
Created May 4, 2024 21:23
convert SFIA xlsx to JSON
<!DOCTYPE html>
<html lang="en">
<head>
<title>Convert SFIA xlsx to JSON</title>
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/xlsx.full.min.js"></script>
<style>pre { background-color: bisque; font-family: monospace; display: inline-block; }</style>
</head>
<body>
curl --location --request PUT '127.0.0.1:9200/_bulk' \
--header 'Content-Type: application/json' \
--data-binary @- << EOF
{ "create" : { "_index" : "movies", "_id" : "135569" } }
{ "id": "135569", "title" : "Star Trek Beyond", "year":2016 , "genre":["Action", "Adventure", "Sci-Fi"] }
{ "create" : { "_index" : "movies", "_id" : "122886" } }
{ "id": "122886", "title" : "Star Wars: Episode VII - The Force Awakens", "year":2015 , "genre":["Action", "Adventure", "Fantasy", "Sci-Fi", "IMAX"] }
{ "create" : { "_index" : "movies", "_id" : "109487" } }
{ "id": "109487", "title" : "Interstellar", "year":2014 , "genre":["Sci-Fi", "IMAX"] }
{ "create": { "_index" : "movies", "_id" : "58559" } }
@glenacota
glenacota / app.log
Created September 10, 2020 19:55
Open Friday 11.09.2020
xw-app-todos | INFO: 172.25.0.1:50016 - "POST /todos HTTP/1.1" 307 Temporary Redirect
xw-app-todos | [2020-09-09 15:21:19,950] INFO redisrepo - Saved the todo with id 3
xw-app-todos | INFO: 172.25.0.1:50016 - "POST /todos/ HTTP/1.1" 200 OK
xw-app-todos | [2020-09-09 15:21:24,324] INFO redisrepo - Fetched the todo with id 2
xw-app-todos | [2020-09-09 15:21:24,325] INFO redisrepo - Saved the todo with id 2
xw-app-todos | INFO: 172.25.0.1:50022 - "GET /todos/2/done HTTP/1.1" 200 OK
xw-app-todos | [2020-09-09 15:21:24,354] INFO redisrepo - Fetched the todo with id 2
xw-app-todos | [2020-09-09 15:21:24,355] INFO redisrepo - Saved the todo with id 2
xw-app-todos | INFO: 172.25.0.1:50026 - "GET /todos/2/done HTTP/1.1" 200 OK
xw-app-reports | INFO: 172.25.0.1:33568 - "GET /reporto HTTP/1.1" 404 Not Found
# Based on the query pusblished in the question, I added the following documents to the index.
[
{
"@timestamp" : "2020-01-15",
"condition" : "B",
"value" : 10,
"conditionType" : "ABCD"
},
{
@glenacota
glenacota / opendistro_select_test.json
Created September 17, 2019 19:24
yada test opendistro
POST _opendistro/_sql?format=csv&separator=%3B
{
"query": "SELECT * FROM *"
}
# ** EXAM OBJECTIVE: INSTALLATION AND CONFIGURATION **
# GOAL: Setup an Elasticsearch cluster that satisfies a given set of requirements
# REQUIRED SETUP: /
@glenacota
glenacota / elastic_exercise_alias_reindex_ingest_pipeline
Last active March 3, 2019 21:57
An exercise to practice with aliases, reindexing, and ingest pipelines in Elasticsearch.
# GOAL: Create an alias, reindex indices, and create ingest pipelines
# INITIAL SETUP: (i) a running Elasticsearch cluster with at least one node and a Kibana instance, (ii) no index or index template that starts by `hamlet`
# Copy-paste the following instructions into your Kibana console, and work directly from there
# Create the indices `hamlet-1` and `hamlet-2`, each with two primary shards and no replicas
# Add some documents to `hamlet-1` by running the following _bulk command
PUT hamlet-1/_doc/_bulk
{"index":{"_index":"hamlet-1","_id":0}}
{"line_number":"1.1.1","speaker":"BERNARDO","text_entry":"Whos there?"}
{"index":{"_index":"hamlet-1","_id":1}}
@glenacota
glenacota / elastic_exercise_index_templates
Last active March 3, 2019 21:57
An exercise to practice with index templates and dynamic templates in Elasticsearch.
# GOAL: Create index templates that satisfy a given set of requirements
# INITIAL SETUP: (i) a running Elasticsearch cluster with at least one node and a Kibana instance, (ii) no index or index template that starts by `hamlet`
# Copy-paste the following instructions into your Kibana console, and work directly from there
# Create the index template `hamlet_template`, so that the template (i) matches any index that starts by "hamlet_" or "hamlet-", (ii) allocates one primary shard and no replicas for each matching index
# Create the indices `hamlet2` and `hamlet_test`
# Verify that only `hamlet_test` applies the settings defined in `hamlet_template`
# In one request, delete both `hamlet2` and `hamlet_test`
# Update `hamlet_template` by defining a mapping for the type "_doc", so that (i) the type has three fields, named `speaker`, `line_number`, and `text_entry`, (ii) `speaker` and `line_number` map to a unanalysed string, (iii) `text_entry` uses an "english" analyzer
# Create the index `hamlet-1` and add some
@glenacota
glenacota / elastic_exercise_index_manipulation
Last active March 3, 2019 21:58
An exercise to practice with the manipulation of indices in Elasticsearch.
# GOAL: Create, update and delete indices while satisfying a given set of requirements
# INITIAL SETUP: (i) a running Elasticsearch cluster with at least one node and a Kibana instance, (ii) no index or index template that starts by `hamlet`
# Copy-paste the following instructions into your Kibana console, and work directly from there
# Create the index `hamlet-raw` with one primary shard and four replicas
# Add a document to `hamlet-raw`, so that the document (i) has id "1", (ii) has default type, (iii) has a field named `line` with value "To be, or not to be: that is the question"
# Update the document with id "1" by adding a field named `line_number` with value "3.1.64"
# Add a new document to `hamlet-raw`, so that the document (i) has no explicit id, (ii) has default type, (iii) has a field named `text_entry` with value "Whether tis nobler in the mind to suffer", (iv) has a field named `line_number` with value "3.1.66"
# Update the last document by setting the value of `line_number` to "3.1.65"
# In one
@glenacota
glenacota / elastic_exercise_cluster_admin
Last active March 3, 2019 21:56
An exercise to practice with clusters administration in Elasticsearch.
# GOAL: Backup and cross-cluster search
# INITIAL SETUP: /
# Download the latest 6.x version of Elasticsearch and Kibana
# Deploy the cluster `eoc-06-earth-cluster`, with one node named `node-earth`
# Connect a Kibana instance to `node-earth`
# Start the cluster
# Create the index `hamlet` and add some documents by running the following _bulk command
PUT hamlet/_doc/_bulk
{"index":{"_index":"hamlet","_id":0}}