Skip to content

Instantly share code, notes, and snippets.

Avatar

Ry Biesemeyer yaauie

View GitHub Profile
@yaauie
yaauie / cdlp
Last active Mar 4, 2019
Bash/Zsh-compliant utility function that allows you to cd into a local checkout of a Logstash Plugin's source code, whether or not you have previously cloned the repository
View cdlp
#!/usr/bin/env bash
#
# Utility that allows you to cd into a local checkout of a Logstash Plugin's
# source code, whether or not you have previously cloned the repository.
#
# Usage:
# cdlp <type> <qualifier>
#
# Example:
# cdlp output elasticsearch
@yaauie
yaauie / jdbc-informix-windowing.diff
Created Sep 18, 2018
Logstash JDBC Input Plugin: Informix DB Windowing Support Proof-of-Concept
View jdbc-informix-windowing.diff
diff --git a/lib/logstash/plugin_mixins/jdbc.rb b/lib/logstash/plugin_mixins/jdbc.rb
index c9bc547..934a4f1 100644
--- a/lib/logstash/plugin_mixins/jdbc.rb
+++ b/lib/logstash/plugin_mixins/jdbc.rb
@@ -162,6 +162,7 @@ module LogStash::PluginMixins::Jdbc
raise LogStash::ConfigurationError, "#{e}. #{message}"
end
@database = jdbc_connect()
+ @database.extension(:informix_windowing)
@database.extension(:pagination)
@yaauie
yaauie / lucene-list-fields-from-elasticsearch-index-mappings.rb
Created Sep 11, 2018
A quick and very dirty script to list the effective lucene field list from an elasticsearch index mapping
View lucene-list-fields-from-elasticsearch-index-mappings.rb
#!/usr/bin/env ruby
# A quick and very dirty script to list the effective lucene schema from an elasticsearch index mapping
#
# USAGE:
# cat index_mappings.json | lucene-list-fields-from-elasticsearch-index-mappings.rb
# cat cluster_mappings.json | jq '.["index_name"].mappings' | lucene-list-fields-from-elasticsearch-index-mappings.rb
#
#
# Copyright 2018 Ry Biesemeyer (@yaauie)
@yaauie
yaauie / years-elapsed.rb
Last active Sep 10, 2018
A Ruby function for determining the number of whole years elapsed between two `Time` objects. No dependencies. MIT License.
View years-elapsed.rb
##
# Determine the number of whole years elapsed between two [Time] objects.
# It is assumed that the provided [Time] objects are in the same time-zone
# and part of a single continuous chronology.
#
# @param time1 [Time]
# @param time2 [Time]
#
# @return [Integer]
#
@yaauie
yaauie / ensure-trailing-newline.bash
Created Apr 12, 2018
Ensure Trailing Newline: ensures that the given plaintext file ends with a newline character, appending in-place only if it is missing.
View ensure-trailing-newline.bash
#!/usr/bin/env bash -e
#
# Ensure Trailing Newline: ensures that the given plaintext file ends with a
# newline character, appending in-place only if it is missing.
#
# Portable on POSIX-based or POSIX-compatible systems, as it uses POSIX-standard
# invocations of `wc`, `tail`, and `echo`.
#
# Copyright 2018 Ry Biesemeyer
#
View keybase.md

Keybase proof

I hereby claim:

  • I am yaauie on github.
  • I am yaauie (https://keybase.io/yaauie) on keybase.
  • I have a public key whose fingerprint is 0FA5 1969 4D7F 08F0 083F A1B6 CF2C 1D14 E392 052D

To claim this, I am signing this object:

View capture-filter.rb
# Copyright 2018 Ry Biesemeyer (@yaauie)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@yaauie
yaauie / dpkg-cat
Created Apr 26, 2018
I had a need the other day to read files out of RPM and DEB packages, but wanted to avoid extracting them to my local filesystem; the following scripts cobble together the various tools I found to simply read a single file from either to stdout.
View dpkg-cat
#!/usr/bin/env bash -x
# prereq: tar
package="${1:?package}"
file="${2:?file}"
tar -xOf $package data.tar.gz | tar -zxO $file
View gzip-decode-filter.rb
# Copyright 2018 Ry Biesemeyer (@yaauie)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@yaauie
yaauie / logstash-filters-cache-common.rb
Created Jan 12, 2018
logstash-filters-cache-common
View logstash-filters-cache-common.rb
class Logstash::Filters::CacheCommon < LogStash::Filters::Base
config :get, validate: :hash, required: false
config :set, validate: :hash, required: false
def register
@get ||= {}
@set ||= {}
if (@get.empty? && @set.empty?)
You can’t perform that action at this time.