Skip to content

Instantly share code, notes, and snippets.

View spinscale's full-sized avatar
💻

Alexander Reelsen spinscale

💻
View GitHub Profile
@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 / filebeat.yml
Created February 14, 2020 16:35
Use filebeat to read CSV data
# Data is from https://www.sciencedirect.com/science/article/pii/S2352340918315191
filebeat.inputs:
- type: stdin
setup.template.overwrite: true
setup.template.append_fields:
- name: arrival_date
type: date
@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 / 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 {
@spinscale
spinscale / init.lua
Created May 16, 2018 08:52
hammerspoon - german umlauts on us keyboard
-- Umlaute without the hassle, hell yeah
hs.hotkey.bind({'alt'}, 'u', function ()
hs.eventtap.keyStrokes('ü')
end)
hs.hotkey.bind({'shift', 'alt'}, 'u', function ()
hs.eventtap.keyStrokes('Ü')
end)
hs.hotkey.bind({'alt'}, 'a', function ()
@spinscale
spinscale / training-examples.json
Created December 14, 2017 09:43
Training Examples (Zurich)
##### decompounder example
DELETE decompound
PUT decompound
{
"settings": {
"analysis": {
"analyzer": {
"my_decompound_analyzer" : {
"type" : "custom",
@spinscale
spinscale / example.json
Created October 12, 2017 07:29
Training Copenhagen: Stored fields example
DELETE sample
PUT sample
{
"mappings": {
"foo" : {
"_source": { "enabled": false },
"properties": {
"my_field" : {
"type": "text",