Skip to content

Instantly share code, notes, and snippets.

View andsel's full-sized avatar

Andrea Selva andsel

  • Trento area
View GitHub Profile
@yaauie
yaauie / downcase-field-names.logstash-filter-ruby.rb
Created October 14, 2020 16:00
A script for a Logstash Ruby Filter to transform field names to all lowercase
###############################################################################
# downcase-field-names.logstash-filter-ruby.rb
# ---------------------------------
# A script for a Logstash Ruby Filter to transform field names to all lowercase
###############################################################################
#
# Copyright 2020 Ry Biesemeyer
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@yaauie
yaauie / delete-emtpy-nodes.logstash-filter-ruby.rb
Last active July 19, 2021 09:46
A script for a Logstash Ruby Filter to delete empty nodes from an event; by default, crawls the entire event recursively, but it can be configured to limit the scope.
###############################################################################
# delete-emtpy-nodes.logstash-filter-ruby.rb
# ---------------------------------
# A script for a Logstash Ruby Filter to delete empty nodes from an event; by
# default, crawls the entire event recursively, but it can be configured to
# limit the scope.
###############################################################################
#
# Copyright 2018 Ry Biesemeyer
#
@colinsurprenant
colinsurprenant / alternate_compact_event.rb
Last active March 4, 2021 01:42
This is an example of using the new file based Ruby filter to create a filter that removes keys with nil values from an event.
# this is an alternate compact function implementation which also removes keys with empty string values
# writing the tests for this is left as an excercise to the reader :D
def compact(h)
h.inject({}) do |result, (k, v)|
if v.is_a?(Hash)
result[k] = compact(v)
elsif v.is_a?(String)
result[k] = v unless v.empty?
elsif !v.nil?
@jsvd
jsvd / lpv.rb
Last active March 18, 2021 10:51
logstash plugin version
#!/usr/bin/env ruby
# use ./lpv.rb logstash_version plugin_name
#
# example:
# % ./lpv.rb 5.2.0 logstash-output-elasticsearch
# logstash-output-elasticsearch 6.2.4 https://github.com/logstash-plugins/logstash-output-elasticsearch/tree/v6.2.4
require 'net/http'
@jboner
jboner / latency.txt
Last active June 12, 2024 14:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD