Skip to content

Instantly share code, notes, and snippets.

View spinscale's full-sized avatar
💻

Alexander Reelsen spinscale

💻
View GitHub Profile
@spinscale
spinscale / data.json
Created March 31, 2021 09:06
Daily Elastic Byte - Interesting field types
#############################
## unsigned long
#############################
DELETE unsigned_long_test
PUT unsigned_long_test
{
"mappings": {
"properties": {
"my_counter": {
@spinscale
spinscale / data.json
Created March 31, 2021 09:04
Daily Elastic Byte - Tale of an aggregation
# Show the scoreboard in the contributor app
DELETE scoreboard
PUT scoreboard/_bulk?refresh
{"index":{}}
{ "score" : 1, "@timestamp" : "2021-02-28", "email":"peter@example.org", "name" : "Peter Parker"}
{"index":{}}
{ "score" : 4, "@timestamp" : "2021-02-01", "email":"peter@example.org", "name" : "Peter MiddleName Parker"}
{"index":{}}
@spinscale
spinscale / calculate-vaccinations.sh
Created January 27, 2021 09:03
Download RKI data and extrapolate full first vaccination
#!/bin/bash
# retrieve URL
url="https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile"
wget -o /dev/null $url -O out.xlsx
# convert to csv
# run 'pip3 install xlsx2csv' (or maybe pip depending on your python installation)
xlsx2csv -a out.xlsx out.csv
@spinscale
spinscale / snippets.kibana
Last active January 20, 2021 13:49
The hidden gems of Elasticsearch - Kibana Snippets
# date_range datatype
PUT range_index
{
"mappings": {
"properties": {
"time_frame": { "type": "date_range" }
}
}
}
@spinscale
spinscale / kibana.snippets
Created June 4, 2020 08:19
Elasticsearch - Hands-on Introduction (2020-06, DevClash)
###################################
## Introduction to Elasticsearch ##
###################################
#########################
## If you do not want to run Elasticsearch yourself
## Test a free 14 day trial at
## https://www.elastic.co/cloud/
#########################
@spinscale
spinscale / sample.json
Created March 4, 2020 15:56
Percolator example (training MUC)
DELETE back_in_stock_notifications
DELETE test
PUT test/_bulk?refresh
{ "index" : { "_id" : "1"}}
{ "id": "1", "title" : "T-Shirt", "size" : "XL", "color": "red", "stock" : 0 }
{ "index" : { "_id" : 2}}
{ "id": "2", "title" : "T-Shirt", "size" : "XL", "color": "green", "stock" : 1 }
{ "index" : { "_id" : 3}}
{ "id": "3", "title" : "T-Shirt", "size" : "XL", "color": "yellow", "stock" : 2 }
@spinscale
spinscale / test.sh
Created February 28, 2020 16:15
Crystal webserver dumping all HTTP requests headers/bodies
crystal eval 'port = 8080 ; require "http/server"; server = HTTP::Server.new do |ctx| req = ctx.request; req.to_io STDOUT ; STDOUT.print "\n\n" if req.body end ; server.listen 8080'
@spinscale
spinscale / sample.json
Created February 18, 2020 11:18
Inference processor with language identification
POST _ingest/pipeline/_simulate?filter_path=**.predicted_value
{
"pipeline": {
"processors": [
{
"inference": {
"model_id": "lang_ident_model_1",
"inference_config": { "classification": {}},
"field_mappings": {}
}
@spinscale
spinscale / Webserver.java
Created June 10, 2015 07:01
Undertow + jgroups-raft example
package de.spinscale.cluster;
import io.undertow.Undertow;
import io.undertow.server.handlers.PathTemplateHandler;
import io.undertow.util.HttpString;
import io.undertow.util.PathTemplateMatch;
import org.jgroups.JChannel;
import org.jgroups.raft.RaftHandle;
import org.jgroups.raft.blocks.ReplicatedStateMachine;
@spinscale
spinscale / logstash-meetup.conf
Created June 20, 2018 19:53
logstash meetup.com stream
# curl -s http://stream.meetup.com/2/rsvps | ./bin/logstash -f logstash-meetup.conf
input {
stdin {
codec => json_lines
}
}
# the lonlat array is needed for the map widget in kibana to work
# so we have to work a bit around the supplied data
filter {