Skip to content

Instantly share code, notes, and snippets.

View spinscale's full-sized avatar
💻

Alexander Reelsen spinscale

💻
View GitHub Profile
@spinscale
spinscale / volume.lua
Created April 16, 2017 18:19
Hammerspoon: Configure volume via keyboard shortcuts for macbook pro (touchbar, but no keys)
function changeVolume(diff)
return function()
local current = hs.audiodevice.defaultOutputDevice():volume()
local new = math.min(100, math.max(0, math.floor(current + diff)))
if new > 0 then
hs.audiodevice.defaultOutputDevice():setMuted(false)
end
hs.alert.closeAll(0.0)
hs.alert.show("Volume " .. new .. "%", {}, 0.5)
hs.audiodevice.defaultOutputDevice():setVolume(new)
@spinscale
spinscale / example
Created January 18, 2017 14:48
Training Beispiel: SubAggregation - Scripting Terms Aggregation
DELETE nutrition
PUT nutrition/foo/_bulk
{ "index" : {} }
{ "calories" : 100, "name" : "Chips", "category" : "a" }
{ "index" : {} }
{ "calories" : 200, "name" : "Thick Chip", "category" : "a" }
{ "index" : {} }
{ "calories" : 300, "name" : "Marzipan", "category" : "b" }
DELETE foo
PUT /foo/bar/_bulk
{ "index" : { "_id" : "alex" } }
{ "name" : "Alex" }
{ "index" : { "_id" : "bert" } }
{ "name" : "Bert" }
{ "index" : {"_id" : "caesar" } }
{ "name" : "Caesar" }
{ "index" : {"_id" : "dagobert" } }
@spinscale
spinscale / ingest node example
Created January 18, 2017 11:55
ingest node example
DELETE _all
PUT _ingest/pipeline/rename_hostname
{
"processors": [
{
"rename": {
"field": "hostname",
"target_field": "host",
"ignore_missing": true
@spinscale
spinscale / console-examples
Created January 18, 2017 08:10
Queries vom Training
DELETE _all
GET index/_mapping
PUT index
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
@spinscale
spinscale / kv.json
Created December 19, 2016 14:27
kv in painless
POST _ingest/pipeline/_simulate
{
"pipeline" : {
"description": "A pipeline to do named entity extraction",
"processors": [
{
"script": {
"lang": "painless",
"inline": "ctx.params = [:] ; /&/.splitAsStream(ctx.x).forEach(pair -> { def x = /=/.split(pair); ctx.params[x[0]] = x[1]; })"
}
@spinscale
spinscale / log4j2.properties
Created November 3, 2016 08:35
colorful log4j logging properties for Elasticsearch
# Colorful output, if you are on the console only
#appender.console.layout.pattern = %highlight{[%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n}
appender.console.layout.pattern = %style{[%d{ISO8601}]}{cyan}%style{[%-5p]}{magenta}%style{[%-25c{1.}]}{green} %marker%m%n
@spinscale
spinscale / aggs.json
Created March 16, 2016 15:47
Aggregations using filtering
DELETE /hotels
POST /hotels/hotel/_bulk
{ "index" : { "_id" : 1 }}
{ "features": [ "wifi", "parking" ], "stars" : 1 }
{ "index" : { "_id" : 2 }}
{ "features": [ "pool", "parking" ], "stars" : 4 }
{ "index" : { "_id" : 3 }}
{ "features": [ "wifi", "pool" ], "stars" : 5 }
@spinscale
spinscale / index.js
Created January 11, 2016 09:02
Presentation counter
var fs = require('fs')
var _ = require('lodash')
var request = require('request')
var cheerio = require('cheerio')
var ProgressBar = require('progress');
var printf = require('printf');
var presentations = []
var data = fs.readFileSync('urls.txt', { encoding: 'UTF-8' }).split("\n")
@spinscale
spinscale / clorgrc
Created December 25, 2015 14:31
Elasticsearch clogrc configuration
# log levels
elasticsearch rule /\[INFO(\s*)]/ --> green match
elasticsearch rule /\[ERROR(\s*)]/ --> red match
elasticsearch rule /\[DEBUG(\s*)]/ --> yellow match
elasticsearch rule /\[TRACE(\s*)]/ --> yellow match
elasticsearch rule /\[WARN(\s*)]/ --> yellow match
# events
elasticsearch rule " new_master " --> bold cyan match
elasticsearch rule " added " --> bold cyan match